Why Arctangent?

Hi, this is as much of a conceptual question as a technical one:

A friend of mine copied a rig of bones for a human character that has a wire parameter in the hips so that it swivels as the feet spread apart. The hip has the following expression on it:

• degToRad(atan((RF-LF)/1000)

• (RF = has the Y.pos of the right foot)
• (LF = has the Y.pos of the left foot)
• (1000 = just an arbitrary value that, through trial-and-error, worked fine in the viewport)

WHY/HOW calculating the arctangent of the difference on the position of the feet makes the hip sway that way? WHY ARCTANGENT?!?

I’m trying to study trigonometry by myself for a long time already, I know that it works, but… WHY? I still don’t grasp the concept! And just copying things without RALLY understanding doesn’t help that much…

It’s driving me crazy for som many months…
Thanks!

- Nelson Baietti

-----------------------------------------------------------------
-- how this part of the rig its done step by step:
-----------------------------------------------------------------

• Create a set of 3 bones for the right leg (thigh, calf and foot)
• Create a HI Solver (Animation, IK Solver, HI Solver) from the thigh to the foot
• Under the foot create an elliptical spline and call it “Right Foot”
• Link the IK Chain01 (the cross in the ankle created by the HI Solver) to the “Right Foot”
• Do the same for the other leg and name the spline “Left Foot” instead

• In the front view, crate a dummy, call it “Hip”, and place it between the legs, on the hip area
• Link both legs to the “Hip” (may not look good but it’s just a proof of concept)

• Now, click on the “Hip” dummy,
• Go to the tag “Motion”,
• Make sure the “Parameters” button is pressed
• Open the tab Assign Controller
• In the tree below, expand “Rotation”,
• Select “Y Rotation” and click on the button above called “Assign Controller”
• Select “Float List” from the list that opens
• Expand the Float list that has just been created on the Y Rotation
• Click on “Available”
• Click again on the “Assign Controller” button
• Select “Float Expression”

• On the new window, in the field “Name” type “RF” and click “Create”
• In the field “Name”, again, type now “LF” and click on “Create” again
• Both variables should appear on the list “Scalar” below
• On the window "Scalar", select your variable “RF”
• Click on the button just bellow called “Assign to Controller”
• Navigate on the tree until you find the object “Right Foot”:
• - Objects
• - Right Foot
• - Transform Position/Rotation
• - Position
• - Y Position: Bezier Floar
• Select it and click “Ok”
• Do the same on the other variable for the Left Foot
• On the “Expression” window type the following:

degToRad(atan((RF-LF)/1000))

• And click on Evaluate
• Move the feet back and forward, if little happens, decrease the value of 1000.
• Using “Float List” lets you rotate the hips both manually and through the expression

----------------------------------------------------------------------------------
And now, again: WHY ARCTANGENT works here?
----------------------------------------------------------------------------------

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
gruhn's picture

There is no tidy connection

There is no tidy connection between the amount of foot separation and the amount of hip rotation in terms of tangent. That is, there is no angle between the feet, no rise and run to divide. As you point out, the 1000 is an arbitrary scalar designed to make it look right. It will depend on how flexible/sexy you want your character, what your units are and whether trig functions in max are degrees or radians.

So any function could be used that maps from zero to (max rotation).

So how to pick a function? By its characteristic shape; how it varies across the domain of likely values.

http://en.wikipedia.org/wiki/Image:Arctangent_Arccotangent.svg

atan returns a zero rotation with the feet together at rest. That's a good start. Then as soon as the feet start to spread there's a bit of rotation thrown in. That's good. Then that rotation increases fairly rapidly and linearly with the increase of distance. But after a while it starts to notice that the legs can swing without having to throw the hip so far out of whack and the amount of rotation levels off and becomes more fixed. Still increasing, but less and less more as the feet move apart.

Note also that you may want to experiment with dividing the result AFTER the atan by some arbitrary amount (or multiply). This will keep the progression of rotational character as described above pretty much the same, but limit the amount that the hip can rotate.

atan((y2-y1)/1000)
base function

atan((y2-y1)/2000)
will stretch that red line out twice as wide. This makes the initial attack slower and the rate of deceleration slower. Technically it keeps the maximium amount of rotation constant (90 degrees) but your feet may never approach the amount of separation required.

atan((y2-y1)/1000)/2
will squash that red line vertically. This also makes the initial attack slower, BUT it limits the maximum to 45 degrees.

sin would have a very similar initial attack, but would start to limit itself more quickly and it would have an annoying point at which the hips start to rotate LESS as the feet move further apart.

something linear (degrees = (y2-y1)/C) would have a similar initial attack for C near 1, would never double back on itself like sin, but would increase without bound. One would hate to see hips rotated 120 degrees. "Bob, do you think we could get Mandy to take that one giant step forward WITHOUT the cartwheel?"

Nelson Baietti's picture

Hehehe, got it! Now it

Hehehe, got it!

Now it makes perfect sense! The use of arctangent itself is sort of arbitrary then, I could have used any other sort of formula or expression that could achive a similar result, and in this case the original writer just selected this one because it kinda eases in and out in a particular way he probably thought would suit his purpose well enough.

Appreciated very much the way you explained it.

Thank you very much, Gruhn!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.