mirroring a matrix without busting scale

164 views
Skip to first unread message

Todd Widup

unread,
Apr 25, 2018, 8:22:56 PM4/25/18
to python_in...@googlegroups.com
I RARELY do matrix math and do to a bug in an animation tool, I find
myself with tasked at writing a mirror pose tool for an animation rig.

any pointers?

--
Todd Widup
Creature TD / Technical Artist
todd....@gmail.com

Phil Sloggett

unread,
Apr 25, 2018, 8:57:28 PM4/25/18
to python_in...@googlegroups.com
Yeah you’re probably not trying to mirror the matrix as you might intuitively think (the way negatively scaling geometry would do), you’re trying to find a reflective origin point (probably just tx *-1) and then a mirrored rotation.

Mirroring the rotation is the tricky part, you could do the math in matrix or quaternion land - then decompose to Euler. You could even just have some clumsy logic that interprets rotation order and rotation values and can generate the flipped rotation values. or you could do it the hacky way I do and use a temporary aimconstraint with 3 mirrored points. This will probably be slower to run ( lots of creating/ destroying constraints) but the math knowledge required is minimal.

Scale shouldn’t ever need to be mirrored (scale values on a “correctly” set up rig should be identical left to right, straight up copy and paste)
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CABBPk35i9UeGvvkFGxYyEiqNB%3Da7e_O1v5fYgtAX3t97WMxaAw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Todd Widup

unread,
Apr 25, 2018, 11:33:52 PM4/25/18
to python_in...@googlegroups.com
hey Phil..

yea, trans is no big, and agree on scale...that would be insane

rotation is the tricky one and yea, ive considered doing the temp aim
con, but was leaning towards doing it in quat land
> https://groups.google.com/d/msgid/python_inside_maya/CAPzKG6XAtZ8g8nv6Wm_6yonMNDuWE6%3Dx5h4VaK1wHq8wM%3DeEVg%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.



Michael Boon

unread,
Apr 30, 2018, 6:36:14 PM4/30/18
to Python Programming for Autodesk Maya
Mirroring quaternion rotation is actually easy. A quaternion is (for our purposes here) and axis and an angle. You just need to mirror the axis part. So if your quat is (x,y,z,w) and you want to mirror around the x axis, make it (-x, y, z, w)
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/python_inside_maya/CABBPk35i9UeGvvkFGxYyEiqNB%3Da7e_O1v5fYgtAX3t97WMxaAw%40mail.gmail.com.
>> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an

Marcus Ottosson

unread,
Apr 30, 2018, 6:52:29 PM4/30/18
to python_in...@googlegroups.com

Here’s a way to do it with matrix multiplication.

  1. Two transforms, source and target
  2. composeMatrix, with negative -Z scale
  3. multMatrix, with composeMatrix as second input (order is important)
  4. decomposeMatrix to get rotate and translate back (ignore scale)
  5. Viola


>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/python_inside_maya/CABBPk35i9UeGvvkFGxYyEiqNB%3Da7e_O1v5fYgtAX3t97WMxaAw%40mail.gmail.com.
>> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CAPzKG6XAtZ8g8nv6Wm_6yonMNDuWE6%3Dx5h4VaK1wHq8wM%3DeEVg%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.



--
Todd Widup
Creature TD / Technical Artist
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages