I have 2 euler’s world space orientations (both retrieved with xform -q -ws -ro)
— X ------ Y ------ Z —
-96.19 -31.15 -78.25 [first in degrees]
-98.46 -51.30 -74.87 [second in degrees]
How to get delta (rotation offset)? Maybe ordinary subtraction works in object space but not in this case(
The fact of the matter is that I have two objects with different world space orientations but
want to rotate them by the same (equal) angle in world space.
Are you trying to get the difference between them? Or to rotate them both?
For getting the difference – well in this case you could do subtraction in euler space - but only because the rotations are pretty close together. For rotations that are apart by more than 90 degrees in any axis Eulers won’t be very reliable. It’s a better idea to use quaternions. In 2016 you can do the conversion using eulerToQuat and QuatToEuler nodes instead of doing the math yourself. The subtracting one quat from the other gives you the difference between them. Unfortnately applying the rotation requires using the api…
For applying a world space rotation it’s much easier: all you need to do is use
xform(ro = (xxx), ws=True)
to apply a world rotation
[QUOTE=Theodox;28432]Are you trying to get the difference between them? Or to rotate them both?[/QUOTE]
I’m trying to make so that the control’s orientation will be coincided with each other after the rotation by a common angle was done. The problem is that their parent groups initially have a different orientation in world space.
I’m talking about the legs matching (FKIK) because the arms matching is very simple case. The arms IK, FK control’s parent groups initially have the same world space orientation. Please watch this topic.
I have an idea first to find out the rotation offset between them comparatively to the world axes and then use it to orient them equally. But now I doubt this can be done with Eulers. I’m not quite well understand the Quaternions yet but I know that they have the least drawbacks as compared to other orientation ways. So I’m going to realize this by transformation matrices.
This problem is a real headache. I wish I could be more experienced in math…
and by the way thanks for your interest Theo, you are always very considerate towards a junior tech-artists.
You can store the offset as a transform matrix. Once you have this information, you can pretty much do whatever you want in any space by multiplying by the offset matrix.
Here’s the gist of it:
To get the offset in your reference pose.
OffsetMatrix = SourceNode.WorldSpaceMatrix * TargetNode.WorldSpaceMatrix
Then to orient/position your target at any given time
TargetNode.WorldSpaceMatrix = OffsetMatrix * SourceNode.WorldSpaceMatrix
The tricky bit is storing this offset on the node so you can retrieve it when you need it. I’m not entirely familiar with Maya, but I expect you can add this as a custom attribute. In your case, your FK control can store the offset to the IK control, and vice versa. When you want to bake or apply from the other, you fetch the offset and apply as above.
my usual shortcut:
cmds.delete(cmds.orientConstraint(bone_to_match, bone_to_rotate, mo-False))