Rotation switch


#1

I have a sphere that rotates when it moves. When it moves along the X axis it rotates on its Z, when it moves along Z, it rotates on X. The problem I run into is gimbal lock. I think I know away around it but I am not sure how to implement it. My rotation order is zyx, so it works perfectly in going in Z direction because the X rotation is dominant. However the Z rotation axis and the Y rotation axis are spinning around X, so every 90 degrees they switch. So I put an if/else on the Y and Z rotation so that when it hits 45 degrees it switches which axis to rotate on for X direction from Z to Y. It works but not I need to expand it so that it works indefinitely.

Meaning after 45 the first degrees of rotation on the X (when translated in Z) and every 90 degrees afterward (next at 135 then 225, etc) it switches which axis between Z and Y to rotate when moved on the X axis.


#2

The rotation order switching idea sounds way too complicated to me.

Maybe consider grouping the sphere under a new transform. Use the new transform to move and orient the sphere in the direction it is rolling. That way you can use the original transform and will only need to rotate it on a single axis.

David


#3

I grouped the ball to itself and it still has the same gimbal lock issue. It can rotate on the X axis just fine, but the z and y axis switch places as it rotates around X, so going perpendicular to the working axis breaks it. I tried using an orient constraint but I cant apply a constraint and use an expression on the same property. I need the expression to grab the circumference of the sphere and divide 360 by it, then multiply that by the amount translated. This technique is commonly used in wheel rigs, but a tire only rolls in one direction, and I trying to rig a sphere, which needs to rotate in all the 3 directions. One direction (either X or Z) will always work but the other one and the Y axis will tumble around it the working one and switch places with the other axis. I need away of tracking that and to tell whatever the axis that is pointing vertically to not rotate.

However, I think I may be misunderstanding your instructions. Any way you can elaborate? Am I putting a orient constraint on the group around the ball or the ball itself?

BTW I am using a nurbs circle to pull the ball. My expression uses the NURBS circle’s translation to multiple with a rot measurement variable that is defined by 360/circumference of the sphere. Then the sphere is parented to the controller. The same technique is commonly used in wheel rigs.


#4

Ok. I see. You want realistic rotations in 3 axis. Well it just so happens that there is a mel script for that called “makeRoll”. You can read about it here… http://help.autodesk.com/cloudhelp/2015/ENU/Maya-Tech-Docs/Commands/makeRoll.html

David


#5

Thanks that works. It kind of seems more dynamic but I may be able to manipulate it, so far it works with the controller when I link the X and Z translation with expressions.