Skip to content

Conversation

@exequielpagliari
Copy link

@exequielpagliari exequielpagliari commented Aug 21, 2025

I detected a type error in the book and repository. The author used Length instead of SqrLength in the implementation shown in the book.

Author's implementation:

vec3 project(const vec3 &a, const vec3 &b) {
 float magBSq = len(b);
 if (magBSq < VEC3_EPSILON) {
  return vec3();
 }
 float scale = dot(a, b) / magBSq;
 return b * scale;
}

Vector projection formula (A . B / |B|^2) * B

LenSq is the calculation of the hypotenuse without radically dividing, so it can be represented as |B| ^ 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant