Discussion:
[Maya-Python] mirroring a matrix without busting scale
Todd Widup
2018-04-26 00:22:49 UTC
Permalink
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
***@gmail.com
--
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+***@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.
Phil Sloggett
2018-04-26 00:57:13 UTC
Permalink
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)
Post by Todd Widup
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
--
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/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 email to python_inside_maya+***@googlegroups.com.
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
2018-04-26 03:33:46 UTC
Permalink
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
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)
Post by Todd Widup
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
--
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/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
***@gmail.com
--
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+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CABBPk36AcoifYtBqckvLL73oP8-XbSWKZnZS%3DOqi-rPn4eo7pw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Michael Boon
2018-04-30 22:36:14 UTC
Permalink
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)
Post by Todd Widup
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
Post by Phil Sloggett
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
Post by Phil Sloggett
mirrored rotation.
Mirroring the rotation is the tricky part, you could do the math in
matrix
Post by Phil Sloggett
or quaternion land - then decompose to Euler. You could even just have
some
Post by Phil Sloggett
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
Post by Phil Sloggett
and use a temporary aimconstraint with 3 mirrored points. This will
probably
Post by Phil Sloggett
be slower to run ( lots of creating/ destroying constraints) but the
math
Post by Phil Sloggett
knowledge required is minimal.
Scale shouldn’t ever need to be mirrored (scale values on a “correctly”
set
Post by Phil Sloggett
up rig should be identical left to right, straight up copy and paste)
Post by Todd Widup
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
--
You received this message because you are subscribed to the Google
Groups
Post by Phil Sloggett
Post by Todd Widup
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send
an
Post by Phil Sloggett
Post by Todd Widup
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CABBPk35i9UeGvvkFGxYyEiqNB%3Da7e_O1v5fYgtAX3t97WMxaAw%40mail.gmail.com.
Post by Phil Sloggett
Post by Todd Widup
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google
Groups
Post by Phil Sloggett
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send
an
Post by Phil Sloggett
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CAPzKG6XAtZ8g8nv6Wm_6yonMNDuWE6%3Dx5h4VaK1wHq8wM%3DeEVg%40mail.gmail.com.
Post by Phil Sloggett
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+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/6f68d70c-311a-4d3b-97e6-4b349ae52c56%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Marcus Ottosson
2018-04-30 22:52:23 UTC
Permalink
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

​
Post by Michael Boon
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)
Post by Todd Widup
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
Post by Phil Sloggett
Yeah you’re probably not trying to mirror the matrix as you might
intuitively think (the way negatively scaling geometry would do),
you’re
Post by Phil Sloggett
trying to find a reflective origin point (probably just tx *-1) and
then a
Post by Phil Sloggett
mirrored rotation.
Mirroring the rotation is the tricky part, you could do the math in
matrix
Post by Phil Sloggett
or quaternion land - then decompose to Euler. You could even just have
some
Post by Phil Sloggett
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
Post by Phil Sloggett
and use a temporary aimconstraint with 3 mirrored points. This will
probably
Post by Phil Sloggett
be slower to run ( lots of creating/ destroying constraints) but the
math
Post by Phil Sloggett
knowledge required is minimal.
Scale shouldn’t ever need to be mirrored (scale values on a “correctly”
set
Post by Phil Sloggett
up rig should be identical left to right, straight up copy and paste)
Post by Todd Widup
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
--
You received this message because you are subscribed to the Google
Groups
Post by Phil Sloggett
Post by Todd Widup
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send
an
Post by Phil Sloggett
Post by Todd Widup
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CABBPk3
5i9UeGvvkFGxYyEiqNB%3Da7e_O1v5fYgtAX3t97WMxaAw%40mail.gmail.com.
Post by Phil Sloggett
Post by Todd Widup
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google
Groups
Post by Phil Sloggett
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send
an
Post by Phil Sloggett
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CAPzKG6
XAtZ8g8nv6Wm_6yonMNDuWE6%3Dx5h4VaK1wHq8wM%3DeEVg%40mail.gmail.com.
Post by Phil Sloggett
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
To view this discussion on the web visit https://groups.google.com/d/
msgid/python_inside_maya/6f68d70c-311a-4d3b-97e6-
4b349ae52c56%40googlegroups.com
<https://groups.google.com/d/msgid/python_inside_maya/6f68d70c-311a-4d3b-97e6-4b349ae52c56%40googlegroups.com?utm_medium=email&utm_source=footer>
.
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 email to python_inside_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOB5PeGvQzQaU%3Ddc2u%3D4pSipuArh4Z%2BczkoxNNfVYWDEYA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Loading...