Open leonardus opened 1 year ago
Specifically, it seems like the issue is that the rotation matrix being generated is transposed.
Here are the matrix results using translation of (0, 0, 0)
, rotation of (0.4301481, 0.7169136, 0.2867654, 0.4677318)
, and scale of (1, 1, 1)
:
Native (cpml.mat4.from_transform()
):
[ -0.192, +0.348, +0.917, +0.000, +0.885, +0.465, +0.009, +0.000, -0.424, +0.814, -0.398, +0.000, +0.000, +0.000, +0.000, +1.000 ]
Custom implementation using cpml.mat4.from_angle_axis(rot:to_angle_axis())
:
[ -0.192, +0.885, -0.424, +0.000, +0.348, +0.465, +0.814, +0.000, +0.917, +0.009, -0.398, +0.000, +0.000, +0.000, +0.000, +1.000 ]
cpml/modules/mat4.lua:
Something about how that rotation matrix is calculated is wrong. Because when I replace it with my own function, that gets the rotation matrix the same way
mat4.from_quaternion
computes the matrix (usingq:to_angle_axis()
), I get the correct results that I was expecting: