PDA

View Full Version : How to rotate more than 180?


reForm
05-11-2008, 06:55 PM
If I'm setting an object rotation using:-

new_rot = (eulerangles rx ry rz)
obj.transform = translate (new_rot as matrix3) (obj.transform.translation)

how do I get the rotations to work if I use values larger than 180?
ie the following code returns 150 degrees instead of 210:-

((eulerangles 210 0 0) as quat) as eulerangles

reForm
05-12-2008, 06:40 PM
Ah… I found the solution. Apply the animation as controller values.

animate on
(
at time 100 #rotor.rotation.controller[3].controller.value = 3600
)

PEN
05-12-2008, 07:48 PM
This is always a fun topic.

Any time you are dealing with the root rotation controllers you are working with quat values. Quats can't be wound up as an euler can. If you do something like...

rot=(eulerAngles 210 0 0)
$.rotation=rot

The eulerAngle is being converted to a quat and then it is converting back to a euler. Since a quat can't have a value above 180 it gives you the closest thing taking the shortest root.

If you do...

rot=(eulerAngles 210 0 0)

--I use three different methods to get to the values here for reference. There are more.
$.rotation.controller.x_rotation=rot.x
setProperty $.rotation.controller #y_rotation rot.y
$[#transform][#rotation][#z_rotation].value=rot.z

You are creating an eulerAngle value and setting each of it's components seperatly before it gets converted. You will still see the wrong value in the transform type in, use my Active Transform editor instead of the built in one to see the values that have been set on the controller or look in the dope sheet.

When working with eulerAngles you are also going to have to deal with gimble lock, you need to know that this is going to happen and what it will do or you will start to see rotations that you didn't want. Quaternion values will not suffer from gimble problems as they don't have three seperate tracks, but instead four intertwined tracks. Animators don't like this as they don't have F curves to work with but mathmaticaly speaking they are more accurate.

CGTalk Moderation
05-12-2008, 07:48 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.