Genete! Help! Reverse an angle with radians?

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

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

Genete! Help! Reverse an angle with radians?

Post by heyvern »

My mirror bones tool script finally works except for this one stupid thing, and I don't really need it because why would you want to mirror bones that aren't parented to a center bone anyway? Still I want to do it right.

I apologize... I should know this by now but I'm stuck.

Imagine you have two unparented "mirrored" bones. On one side you have a bone at 180 degrees on the other 0 degrees and you rotate either bone and you want the bone on the other side to rotate in the opposite direction...

Is there a formula for this? How do you convert an angle in radians to a mirrored angle on the other side?

These bones are not parented so the rotations are "opposite" at all times. I could do it with degrees... I think... but I should do it with radians. Either way I can't figure the darn thing out.

This should be easy shouldn't it? Arrrgggghhh. My brain hurts. I know it involves PI somehow. ;)

Parented bones are a piece of cake since they are a straight reversal.


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

Post by Genete »

Mirroring movements have following rules:

1) Displacements have to be composited into parallel and perpendicular movements to the mirror axis. Parallel movements are not mirrored and perpendicular movements changes the sign.
2) Rotations are mirrored always and change it sign only. It doesn't care about how much is the rotation, only needs to change its sign. The clue is to put the bone in the right angle first. After, each rotation of the mirror bone should be the same than the original but reversed angle (change sign)

I have to go now. Please reply and I'll clarify this night.
Bye.
-G
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Nevermind!!!

5 minutes after posting I figured it out!

Here is the so so easy solution:

Code: Select all

mirroredAngle = oldAngle*-1- math.pi
I don't know what the heck is going on but it does the job.

-vern
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Well that was close but now I have to figure out how to change the axis of rotation... based on the mirrored angle.

Right now that equation "flips" only on the center of the layer. So now I need to figure out how to incorporate the center bone on unparented bones.

I am almost thinking it is pointless. If a bone is unparented it won't move with the center bone anyway so the mirroring will be "destroyed". It doesn't even make sense to have this at all.

I think I will "code it out" for now. It causes trouble because if the center bone which determines mirroring is rotated with the mirror bone tool and you try to select an unparented bone (not parented to the mirror bone) it will select the wrong bone on the other side and create a mess.

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

Post by Genete »

5 minutes after posting I figured it out!
It always happen. Anyway I'm glad to help you.

Watching your results in the forum. Good luck.
Ask me if more questions please.
-G
Post Reply