Genete the math wizard! Simulating 3D rotation from 1 bone?

Have you come up with a good Moho trick? Need help solving an animation problem? Come on in.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Genete the math wizard! Simulating 3D rotation from 1 bone?

Post by heyvern »

My dream of replacing the springy gizmo with my flipping script was noble if misguided.

Here's the description of the situation and a question:

Your springs simulate 3D motion because the translation of the last bone is non linear. I get that. If I use straight rotation to translation it is linear.

Is there a formula that I could apply to the value of a single bone's rotation based on the angle (from 0) to create that non linear translation? .

For instance as a bone is rotated the rotation value increases and decreases from 0. Would there be a way to perform a mathematical formula to that number that would simulate the change in "acceleration" of a translation as it approaches 0 and as it reaches 90 or -90 degrees and approaches 180 or -180 degrees?

This formula could have some variable used as the base number that could be changed in a script, maybe it could be based on the length of a bone to determine the change? For instance there could be a bone off to the side that has no purpose except to set this value. By changing this bones length the value would be changed.

Or better yet, that single value could be used to calculate a whole BUNCH of different points in 3D space.

-vern
human
Posts: 688
Joined: Tue Jan 02, 2007 7:53 pm

Post by human »

I can't address your exchange with Genete, Vern, but I just wanted to point out that in general, controlling 3-D rotation with a single point control is feasible.

Just consider how often these days we use 3D rotation controlled by a single mouseover--for instance, in Poser.
User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Ha ha!!!

Genete already gave me the answer in the 3D head turn topic!!!

Woooohooooo!!!

I learned how to use SIN!!! It works perfectly!!!!

I mean... math.sin... not the biblical "sin" thing. ;)

Although... I am sure I'm guilty of using both now.

-vern
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete »

heyvern wrote:Ha ha!!!

Genete already gave me the answer in the 3D head turn topic!!!

Woooohooooo!!!

I learned how to use SIN!!! It works perfectly!!!!

I mean... math.sin... not the biblical "sin" thing. ;)

Although... I am sure I'm guilty of using both now.

-vern
That was what I thought when I readed your post this morning (at 6:50 AM!!!). Hey, human, you're right, we are completely crazy!

Just for clarify:

ONE AXIS SIMPLE ROTATION (around Y axis):

X=R*sin(alpha+alpha0) = R*cos(alpha -pi/2+alpha0)
(((You can use any of them sin or cos (and then you can be free of sins :wink:). In fact the functions sin(alpha) and cos(alpha -pi/2) are identical.)))

pi=3.14159...
alpha=the angle of the master bone and starts from 0 to 2*pi (in radians)
(when alpha = 0 then X0 = R*sin(alpha0))

alpha0= the anlgle value of the point at frame 0 (or 1 depending of your setup). If alpha0=0 then X0=R obviously.
R=The minimum distance from the point to the Y axis. Is the rotation radius.

With my springy mechanism (3+1 bones) I can control R with the scale of 2 of the bones of the springy. It can be done constraining one bone to other and scaling the other. On the other hand, with the 3+1 bones springy mechanism I cannot modify the alpha0 becasue I can only do it at frame 1 and store it at frame 0)
Both, alpha0 and R give the particular values for each point of the mesh.

So to simplify your technique you can have:

1) A master rotation bone.
2) A target (slave) bone for each point.
3) A bone to store its alpha0 and R values. For instance you can store alpha0 at its current angle value and its R to its current length.

A pair of bones are needed then to rig a point for a single axis rotation.

So if you do this with your script, you reduce the amount of bones to a half of mine what is a good advance!

BUT WITH YOUR SCRIPT YOU CAN DINAMICALLY MODIFY THE MESH!!!!! WITH MY SPRINGY I HAVE TO GO TO FRAME 0 (1) TO DO THAT WHAT IS DIFFICULT FOR THE SETUP AND FOR DINAMYC MORPHING.

PLEASE DO THE SCRIPT!!!!!

Now I have to go. Later I will give you the math functions to perform a two combined axis turn. PLEASE CREATE ANOTHER SCRIPT TO DO THAT FOR ME!. I can do the combined turn it but need almost 15 bones per point. :(

Thanks.
Last edited by Genete on Thu May 24, 2007 1:38 pm, edited 1 time in total.
User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Yeehaaa!

Already working on it. The math hurts my head but it just WORKS! This is so cool. I plug in the numbers and I look like a genius. ;)

When I added that formula you gave me to translate that bone... I got chills! It translated EXACTLY like that spring system. I was able to add in a bunch of bones translating in "3D" at different points in space based on one bone rotation.

I need some sleep... but tomorrow I plan to put together a "prototype" so you can see the results.

----------
On the Y axis motion it could be identical to the x rotation... just rotated over on its side.

Actually if the 3D space were defined as a symmetrical sphere the initial values (alpha0 and R) for the y rotation could be pulled from the same bones that define these values for the x.

All that would be needed would be to perform a different calculation in the script based on the Y rotation using the same values. No extra bones.

Maybe I'm missing something.

p.s. I LOVE SCRIPTING!!! I have increased my skills another 100%.

-vern
Post Reply