toMat4 is incorrect
bengolds opened this issue · comments
bengolds commented
The current implementation of toMat4 is incorrect; I think maybe you're running into some gimbal lock or something? Here's a repro.
I implemented the following and it worked well.
toMat4 : Quaternion -> Mat4
toMat4 q =
let
( x, y, z, w ) =
( getI q, getJ q, getK q, getScalar q )
in
Mat4.fromRecord
{ m11 = 1 - 2 * y * y - 2 * z * z
, m12 = 2 * x * y - 2 * w * z
, m13 = 2 * x * z + 2 * w * y
, m14 = 0
, m21 = 2 * x * y + 2 * w * z
, m22 = 1 - 2 * x * x - 2 * z * z
, m23 = 2 * y * z - 2 * w * x
, m24 = 0
, m31 = 2 * x * z - 2 * w * y
, m32 = 2 * y * z + 2 * w * x
, m33 = 1 - 2 * x * x - 2 * y * y
, m34 = 0
, m41 = 0
, m42 = 0
, m43 = 0
, m44 = 1
}
Conrad Parker commented
Hi,
sorry I missed the notification for this issue.
Thanks for the awesome repro and reference doc. I've applied this change and released version 2.0.1.