{{ message }}

# x/mobile/exp/f32: Mat4.Rotate incorrectly rotates around axes with non-zero X values#14989

Open
opened this issue Mar 27, 2016 · 0 comments
Open

# x/mobile/exp/f32: Mat4.Rotate incorrectly rotates around axes with non-zero X values#14989

opened this issue Mar 27, 2016 · 0 comments
Labels
Milestone

### bmatsuo commented Mar 27, 2016
 I have put together the following example to demonstrate a problem with Rotate method on f32.Mat4. I attempt to rotate a vector v (edit: vector u) around the X axis. The resulting vector does not have the same length (in this extreme case the "rotation" has collapsed a unit vector to zero-length). http://play.golang.org/p/INyRQCldPm When I actually use the resulting transformation in OpenGL what I have observed is that my models gets flattened onto a plane (presumably the Y-Z plane, perpendicular to the X axis, at X=0). I believe the problem lies in how the first row of the rotation matrix is constructed. https://github.com/golang/mobile/blob/467d8559f22b81884dfbc37d1cef95d0fab78049/exp/f32/mat4.go#L157-L160 I kind of suck at this stuff. But you can see the subsequent rows in the matrix have a pattern which is not observed in the first row. So I tried changing the first row of the rotation matrix to the following. `````` { c + d*a*a, 0 + d*a*a + s*a, 0 + d*a*a - s*a, 0, } `````` And that looks like it works. The following demonstrates the altered Rotate function: http://play.golang.org/p/8ZrOpdv_AY This second example confirms rotation of [1, 0, 0] around the X axis yields [1, 0, 0]. Obviously length was preserved. The text was updated successfully, but these errors were encountered: