I'm trying to get the quaternion of an object from its global matrix.

When I run this code:

- Code: Select all
`rotMatrix = ix.api.GMathMatrix4x4d()`

matrix.extract_rotation(rotMatrix)

rotQuat = ix.api.GMathQuat()

rotQuat.set_rotation(rotMatrix)

I'm getting the following error:

- Code: Select all
`TypeError: Wrong number or type of arguments for overloaded function 'GMathQuat_set_rotation'.`

Possible C/C++ prototypes are:

GMathQuaternion< double >::set_rotation(double const &,GMathVec3d const &)

GMathQuaternion< double >::set_rotation(GMathVec3d const &,GMathVec3d const &

While in the documentation it says that we should be able to do it from a rotation matrix if I'm not wrong:

- Code: Select all
`set_rotation (const U &m)`

U The type of the input matrix. It's automatically deduced, and works with 3x3 and 4x4 matrices.

I also tried to set the rotation for each angle and rotation axis, but then I'm not quite sure how I could combine them to get the global quaternion of the object:

- Code: Select all
`rotate = ix.api.GMathVec3d()`

matrix.compute_euler_angles(rotate)

xRot = rotate[0]

yRot = rotate[1]

zRot = rotate[2]

xRotAxis = ix.api.GMathVec3d(1,0,0)

yRotAxis = ix.api.GMathVec3d(0,1,0)

zRotAxis = ix.api.GMathVec3d(0,0,1)

rotQuat = ix.api.GMathQuat()

rotQuat.set_rotation(xRot, xRotAxis)

roQquat.set_rotation(yRot, yRotAxis)

roQuat.set_rotation(zRot, zRotAxis)

So i was curious to check on this to see if you would know how to do it.

Thanks,

Jeremy