After some rotations and to from quaternion conversions I get negative scale from Matrix 4x4, is it possible? I need that scale to draw sprite on screen so I get sprite flipped, how to deal with this problem should I just handle negative scale in sprite drawing method.

if MatrixHasNegativeScale then invert scale, draw sprite with inverted scale after m4.initWithHeadPitchRoll(0, 0, 180); I already get negative scale. or something wrong with matrix class?

Edit I create transformation matrix(rotation + scale + translate) rotation around Oz by 180 and when I extract scale from it, it has negative value is it normal?

  • \$\begingroup\$ By scale are you referring to element m44 of the matrix? \$\endgroup\$ Commented Apr 25, 2013 at 21:51
  • \$\begingroup\$ By scale I refer to m00 m11 m22, m4 is variable of matrix 4x4 \$\endgroup\$
    – Yevhen
    Commented Apr 25, 2013 at 21:57
  • \$\begingroup\$ Mathematicians usually start at m11, CIS types at m00. If the determinant of the non-translational portion of the matrix is negative, that means the sprite is being reflected. It sounds like you are referring to that when you say m00 m11 m22, but of course that only applies if the off-diagonal elements (of the non-translational portion) of the matrix are all 0. \$\endgroup\$ Commented Apr 25, 2013 at 22:06
  • \$\begingroup\$ Let's go over your exact commands, what language and libraries do you use? What series of commands do you use to create the matrix? What command(s) do you use to extract the scale? If you could provide intermediate data dumps of example data between the individual commands that might also help. \$\endgroup\$ Commented Apr 26, 2013 at 21:29

1 Answer 1


If your matrix and quaternion classes are functioning properly, then a sequence of rotations should not ever give you a reflection (inverting or flipping a sprite). You should not just sweep the problem under the rug by writing code to flip something if it comes out with a reflection; you should try to figure out the actual problem.

That being said, based on the comments, it's not clear to me that you actually have a reflection showing up. Negative components in a matrix show up naturally as a result of rotations. For example a 2D rotation matrix for a 180-degree rotation is

[ -1  0 ]
[  0 -1 ]

The presence of negative values in the matrix - even along the main diagonal - doesn't mean anything by itself. You have to look at the determinant of the matrix to see whether it's orientation-preserving (positive) or orientation-reversing (negative), and in this case the determinant is +1, so this is a perfectly legit rotation matrix, with no reflection.

  • \$\begingroup\$ That matrix could be described as a scale of -1. Note that a similar scale -1 3D matrix has a determinant of -1, and thus will mirror the object. \$\endgroup\$ Commented Apr 25, 2013 at 23:38
  • \$\begingroup\$ @eBusiness Yep. Conversely, a 180-degree rotation about any axis in 3D could be described as a scale of -1 along the axes perpendicular to the rotation axis, but has a determinant of +1. \$\endgroup\$ Commented Apr 26, 2013 at 0:04
  • \$\begingroup\$ So what should I do? if rotation of 180degree gives me negative scale? should I modify scale given to renderer based on matrix determinant? something like if determinant > 0 scale < 0 then negate scale \$\endgroup\$
    – Yevhen
    Commented Apr 26, 2013 at 9:23
  • 1
    \$\begingroup\$ @bobenko No, a 180 rotation in 3D does not give negative scale. But what exactly are you trying to do? Your question is not very clear on that. \$\endgroup\$ Commented Apr 26, 2013 at 11:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .