Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gb_float22_mul_vec2 and gb_float33_mul_vec3 seem to expect a row-major matrix #45

Closed
lwky opened this issue Oct 21, 2020 · 1 comment
Closed

Comments

@lwky
Copy link

lwky commented Oct 21, 2020

It looks like gb_float22_mul_vec2 expects a row-major matrix, instead of column-major. The gbMat struct is column-major, and the operator gbVec2 operator*(gbMat2 const& a, gbVec2 v) implies we're multiplying a matrix with a column vector (and not multiplying a row vector with a matrix).

void gb_float22_mul_vec2(gbVec2* out, float m[2][2], gbVec2 v) {
  out->x = m[0][0] * v.x + m[0][1] * v.y;
  out->y = m[1][0] * v.x + m[1][1] * v.y;
}

it think this should be:

void gb_float22_mul_vec2(gbVec2* out, float m[2][2], gbVec2 v) {
  out->x = m[0][0] * v.x + m[1][0] * v.y;
  out->y = m[0][1] * v.x + m[1][1] * v.y;
}

The same holds for gb_float33_mul_vec3

gb_float44_mul_vec4 is ok.

@lwky
Copy link
Author

lwky commented Oct 27, 2020

I see there is already a PR filed for this issue, #44
so this can be closed after merging it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants