Jump to content

Search In
  • More options...
Find results that contain...
Find results in...

Constrained rotation matrix scale bug?

Recommended Posts



I have an app that saves object transformation (matrix value is saved) and then reloads it. When using constrained rotation (holding the shift key down) I'm getting different results than with regular rotation. Example:


Given we have selected a TextField that starts with an identity matrix (a=1, b=0, c=0, d=1, tx=0, ty=0) and constrained rotated it 180 degrees the matrix should be (a=-1, b=0, c=0, d=-1, tx=0, ty=0) but instead ends up as something like (a=-1, b=4.996003610813204e-16, c=-4.996003610813204e-16, d=-1, tx=156.6, ty=74.95).


If you do the same rotation without holding shift and get as close as possible to 180 degrees you get an expected result with the correct scale e.g. (a=-0.9999896287918091, b=0.004538288805633783, c=-0.004538288805633783, d=-0.9999896287918091, tx=156.7, ty=74.65)


The object is not affected before the user saves (it rotates 180 degrees and is not scaled) but when the object is loaded from a saved matrix the scale values cause it to be too big, in this case 4.99 times too big.



Link to comment
Share on other sites

I think you might be interpreting the numbers incorrectly - 4.996003610813204e-16 is an EXTREMELY small number. Notice that "e-16" at the end? That's a wacky way that Flash expresses a very, very small decimal (like less than 0.0000001). Flash does have some rather odd ways that it reports rotation values, but the values you're indicating there don't seem way off to me. Or did I miss something?

Link to comment
Share on other sites

  • 4 months later...

Hey thanks for that. I was in a hurry so I disabled constrained rotation and moved on, but now revisiting it I can see what was happening. The values were being saved and normalized in a database and the e-16 was being truncated so -4.996003610813204e-16 became -4.996. Obviously quite different numbers :D . Now I round any numbers below .001 to 0 before saving them.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.