[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();
}
hello Spa.
i have logged a feature request for a rotation-order attribute to the quaternion objects.
our implementation is more or less derived from this website:
http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/
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
i'm not sure what you are asking.
the website i linked to has sample code.
your mxj code you posted should also work fine.
if you want to develop externals, the sdk is the place to start:
https://cycling74.com/products/sdk/
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.
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
with 6.1.3, jit.euler2quat and quat2euler have an attribute called @rotate_order, allowing you to specify the order rotations are applied.