Community Forum

Joint Angle

Forum Overview >> Scripting

Created30.06.2009 19:17

Chris Harris (Unknown) 30.06.2009 19:21
I'm trying to make a joint with imited rotation that can be locked into position, which i managed. I am having trouble finding the angle between the two actors so i can recreate the limit when i unlock the joint. I dont quite understand the results from getrotation on the two actors (which are children of the root node) most of the time they just seem to return between -90 and 90 degs..

Stefan Geiger - GIANTS Software 01.07.2009 08:38
getRotation returns the Euler ZYX angles. Since euler angles are non-unique, there might be two completely different values, both describing the same orientation of the object. Thats why it's not practicable to use getRotation to calculate the difference between the two object orientations.

There is the function x',y',z' = localDirectionToWorld(objectId, x,y,z)

for x,y,z you can use the vector 0,0,1 (local z axis). With the two new vectors, you calculate the dot product (skalar produkt) which gets you the cos(phi), where phi is the angle between the two objects.
You can use the function Utils.dotProduct(ax, ay, az, bx, by, bz)

Chris Harris (Unknown) 01.07.2009 21:17
Thanks alot, worked perfectly.

Gh Portefait (Unknown) 14.05.2013 15:00

I am very interested with your findings Chris.
I used Stefan recommandation and found the angle between my tool and my chassis (both Dynamic)
No I want to lock my tool, and unlock it through script, as well as limiting it and I am stuck !!
Any help welcomed
BTW is there an already implemented RadToDeg function somewhere ?

Note: Log in to post. Create a new account here.