toji / gl-matrix

Javascript Matrix and Vector library for High Performance WebGL apps
glmatrix.net
MIT License
5.4k stars 725 forks source link

Mat4 get rotation does not give a valid quaternion when mat4 is scaled (also quat2.fromMat4 issue) #434

Open signorpipo opened 3 years ago

signorpipo commented 3 years ago

If u set the mat4 with a quaternion rotation, scale the mat4 and then call getRotation, u won't get the initial rotation, and normalize that result won't get it either. U need to scale it back to 1 and call getRotation if u want the rotation u put in.

This also means quat2.fromMat4 does not work if the matrix4 has a scale. This at least in the environment I work with, where the scale is not saved into the quat2 transform.