Gimbal Lock fix

hey !

I come here cause I have a question about gimbal lock and you guys seems to talk a lot about it. But i’m not on unity but it doesn’t change much

I’ve recently got a kinect, I pluged it into my pure data so I get XYZ translations of the points that mal my skeleton.

what I want is to convert it into angles.

So I made a simple algo with trigonometry wich gives me in degree from à to 360 in X Y Z rotation of my left arm. Now when I apply it to a cube it’s kind of weird. After looking a while online I found about the Gimbal Lock, so I adapted a fix in C to PureData.

The result is still buggy so I guess I did something wront.

Could someone tell me what following rotations he get after gimbal fix for

X 160 Y 90 Z 267

with Y to be the base

I get

X 0 Y 90 Z 106

I attached my PD patch in case of

1293-gimblekill.pd.txt (6.01 KB)

I’m quite new here so my answer might not be useful, but a bad answer is better than no answer I guess.

Try quarternions. I don’t really know how they work yet but you can use them in place of angles to avoid gimbal lock (which I also don’t really understand yet)

I hope this helps!

Hey !

yeah it’s what I’m already doing :slight_smile:

and that’s my question, is my quaternion transformation right.

In the meantime I found out that non when I compare my results to others on a calculator (euler/quaternion).

The part wich is wrong is calculation of RX in case of gimbal lock

this part :

RX = ((sin_X*sin_Y)*sin_Z)+(cos_X*cos_Z);
RY = (-(sin_X*sin_Y)*cos_Z)+(cos_X*sin_Z);

Z = Math.atan2(RY,RX);
Z *= RADIANS;

if anyone can correct me would be great

thanks