[Closed] Multiplying rotation values?
Hey everyone,
Not sure if this is a simple question or a hard one…Here’s my problem:
Let’s say I have 2 gears. 1 gear is bigger than the other gear, which means if the big gear is rotated, the smaller gear will rotate faster than the big gear (assuming they’re hooked together).
Which means my problem is simple…how can I have the smaller gear’s rotation be equal to that of the bigger gear’s rotation, multiplied by x.
I have done something along the lines of this:
a = $BigGear.rotation as angleaxis
a.angle *= x
$Smallgear.rotation = a as quat
But I’m getting weird results.
Also note that I’m not actually using gears…that was just to make the example/illustration easy to understand. In the case of what I need, the solution would have to work for all angles (ie…imagine an orientation constaint where the weight of the orientation constaint could be larger than 100, so that an object’s rotation could be equal to [the target object’s rotation * x])
In the case of gears, the smaller gear has to travel the same length as the large one.
Since the circumference of both is expressed as 2PiR, you have
2PiR1 = X2PiR2 –> R1 = XR2 –> X = R1/R2
So the factor depends only on the radii – if the small gear is twice as small, it will have to rotate twice as fast, or the multiplier will be 2.
You can directly access a single axis rotation.
Create one cylinder with Radius 100.
Create another one with Radius 50, touching it.
The expression would be
$Cylinder02.rotation.z_rotation = -2 * $Cylinder01.rotation.z_rotation
The minus sign is to invert the direction, 2 is the factor (R1=100/ R2 = 50)
You can get it working quickly using Wire Parameters:
Make the Cylinder02’s Z rotation dependent on the Cylinder01’s Z rotation and enter in the field
-2*Z_Rotation
Rotate the Cylinder01 and the smaller one will rotate correctly in the opposite direction with the correct speed…
Hey Tyson,
Assuming you can reliably obtain the radius of each “gear,” you could drive one gear off the other using quaternions. In this example the smaller gear is being driven by the larger. The small gear’s rotation is driven by a script controller, and in that script controller a variable named “bigGear” holds a reference to the larger gear’s rotation (as a quat value). There are also two constants, “bigGearRadius” and “smGearRadius” that hold the respective radii.
rotAxis = -1 * bigGear.axis
rotAmt = (bigGear.angle * (bigGearRadius * 2 * pi)) / 360.
angle = (360. * rotAmt) / (smGearRadius * 2 * pi)
quat angle rotAxis
It works by reversing the axis of rotation of the larger gear for the smaller gear, so they rotate against eachother. Then the rotation amount is computed by taking the bigger gear’s current rotation amount and multiplying it by its circumference, then dividing by 360. Then you can take this information and re-apply it using the smaller gear’s radius to obtain the rotation amount.
Hey d3coy and Bobo…
Thanks for your fast responses!
The precision of your response d3coy, (because it uses the radius of the objects) is a great solution for my problem. I never thought of doing it that way. And Bobo, your way is so simple! I never thought of individually accessing each axis of rotation to simplify things…I was getting myself all confused on how to properly interpret quat/angleaxis values.
I will definitely be trying both…and congrats Bobo on your recent wedding!
Glad you liked it! Have fun, make sure your radii are as accurate as possible otherwise it’ll get a little weird…
Hey d3coy…just thought I’d pop back in and say that after trying your method…it worked brilliantly!
Thanks again…I never would have figured that out myself
Dynamics challenge on simplycg? Good luck, Tyson
…and i’m still waiting for autorisation