## [request] jit.euler2quat & jit.quat2euler _ attribute for order of rotation

Sep 6, 2012 at 6:12pm

# [request] jit.euler2quat & jit.quat2euler _ attribute for order of rotation

it seems that the order of rotation used in jit.euler2quat is YZX:
first X rot, second Z rot, third Y rot
so X is the bank (tilt) axe.

there is 12 rotation order possibilities.

A convenient order of rotation for openGL, when object is facing the camera is YXZ:
first Z rot, second X rot, third Y rot
It is more logical to use this order, respect to the direction and lookat attributes of jit.anim.node that use the Z axis of the object.
so Z is the bank (tilt) axe.

Could you create an attribute for those 2 objects like: rotation_order (default: yzx, yxz etc…)
or make an object like jit.eulerYXZ2quat and jit.quat2eulerYXZ
or perhaps send me or make the code public for jit.euler2quat & jit.quat2euler, so i can adapt them.

thanks

I created a mxj for this:

public final void yxz_r(double x, double y, double z) {
// Y : heading, X : attitude, Z : bank
// enter: XYZ _ order process: YXZ
// first Z rot, second X rot, third Y rot, for jitter conveniences
// Assuming the angles are in radians.

double sx = Math.sin(x/2);
double cx = Math.cos(x/2);
double sy = Math.sin(y/2);
double cy = Math.cos(y/2);
double sz = Math.sin(z/2);
double cz = Math.cos(z/2);

// R= Qx*Qz _ first Zrot then Xrot
// double Rx = cz*sx;
//double Ry = -sz*sx;
//double Rz = sz*cx;
//double Rw = cz*cx;

// R= Qy*Qxz first XZrot then Yrot
//qx = Rx*cy+Rz*sy;
//qy = Rw*sy+Ry*cy;
//qz = -Rx*sy+Rz*cy;
//qw = Rw*cy-Ry*sy;

// R= Qy*Qx*Qz first Zrot then Xrot then Yrot
qx = cz*sx*cy+sz*cx*sy;
qy = cz*cx*sy-sz*sx*cy;
qz = -cz*sx*sy+sz*cx*cy;
qw = cz*cx*cy+sz*sx*sy;

quat_out();
}

#64260
Sep 6, 2012 at 9:58pm

Thanks Robert.

Is it possible to have a code example of these objects, so i could use them as base for developing similar objects.

thanks

#231702
Sep 6, 2012 at 11:09pm

I just wanted the jit.euler2quat and jit.quat2euler source code …
mxj seems 4 times slower than native objects, due to bridge from max to java i suppose.

#231704
Sep 11, 2012 at 1:58pm

well, i suppose it was a bit short to include it in the 6.0.7 release.
Hope it will appear in the next one.
thanxs

#231705

You must be logged in to reply to this topic.