Isotropix Forums

How to use Euler Angles/Quaternions correctly?

Clarisse Scripting related topics

How to use Euler Angles/Quaternions correctly?

Unread postby gerdhofer » Tue Jun 09, 2020 9:26 am

Hello there,

I've been going through many examples here, but still don't get how to use Euler Angles and Quaternions in Clarisse's Python :oops:. So I'm hoping that somebody here knows more than me. What I basically want to do is to get the orientation of an object in spac eto move another object along my reference object's direction given through 3 rotation angles. To make it more clearely: consider a guy with a bow. He points the bow in direction of a target and shoots. The arrow will move in direction of the target and this is exactly what I want to achieve.

I know it's possible with Clarisse's on-board tools, but I'm looking for a Python solution. I think I need Euler Angles or Quaternions to do that, but is this possible with the SDK functions in Clarisse? If yes, how do I have to use things like ix.api.GMathMatrix4x4d.compute_euler_angles?

Many thanks for any help,
Posts: 55
Joined: Thu Aug 30, 2018 11:05 am

Re: How to use Euler Angles/Quaternions correctly?

Unread postby anemoff » Mon Jun 29, 2020 4:39 pm


Sorry for the late reply.

Here is how to use the API:

py code

# the matrix you want to extract the angles from, must be of type GMathMatrix4x4d
# here, for example, get the matrix from a specified geometry
matrix = ix.get_item("path/to/geometry_object").get_module().get_global_matrix()

# create the output variable that will hold the extracted Euler angles
angles = ix.api.GMathVec3d()

# extract the angles
# the 3rd parameter "order" is optional and its default value is "ix.api.GMATH_ROTATION_ORDER_ZXY"
ix.api.GMathMatrix4x4d.compute_euler_angles(matrix, angles)

# do something with the angles...

Available rotation order values:
Code: Select all

Hope this helps,
Anthony Nemoff
R&D Engineer
User avatar
Posts: 300
Joined: Wed Jan 13, 2016 10:10 am

Re: How to use Euler Angles/Quaternions correctly?

Unread postby gerdhofer » Sat Jul 04, 2020 11:22 am

Thanks Anthony, and no worries about the late reply. Since I'm just trying to understand concepts it wasn't really urgent.

Anyway, maybe you can help me one more time as it doesn't solve my "problem" completely. What I basically want to get is a direction vector and I thought Euler angles might be useful here (but obviously they're not). An example:

When I add a basic polygrid in the XZ plane, my direction vector would point upwards along the Y axis: dir_vec = (0,1,0).
With a rotation of 90 degrees around X the direction would be along the Z axis: dir_vec = (0,0,1)

So, is there any way to extract this direction vector, perhaps from the 3 rotation angles of my plane or through a specific Python function? I was trying to use the polygrid's normals, but they keep their initial values from creation time, and don't consider any later rotations.

I hope you understand what I'm looking for. Thank you!
Posts: 55
Joined: Thu Aug 30, 2018 11:05 am

Return to Scripting