8

I wont to rotate QuickTime Move 180 degrees.

Now my file's matrix(tkhd) is

1 0 0

0 1 0

0 0 1

I got this matrix form Dumpster.

What is the 3 × 3 matrix for a rotation of 180 degrees?

SUKIYAKI
  • 263
  • 2
  • 5
  • 12
  • Depends on what axis you want to rotate, 3x3 is for 3 dim rotations. http://en.wikipedia.org/wiki/Rotation_matrix – Ido Weinstein Aug 11 '10 at 04:36
  • 3
    @IdoWeinstein A 3x3 matrix could conceivably be for 2D transformations using "homogeneous coordinates". https://en.wikipedia.org/wiki/Homogeneous_coordinates – Kaz Jun 16 '17 at 05:20

4 Answers4

19

Assuming you want a 3x3 homogeneous matrix for a 2D rotation about the Z-axis, then the matrix you want is:

-1  0  0
 0 -1  0
 0  0  1

If you want to rotate about a different axis, then the matrix will be different.

Adam Rosenfield
  • 390,455
  • 97
  • 512
  • 589
  • In my experience you need to add a translation to this so that the transformed image is in the viewport. – George Apr 19 '12 at 22:32
2

Negate the two vectors that aren't the axis you want to rotate around.

So: You can take an ID matrix, negate the 1 for two axis you want affected, and leave the one you want to rotate around unaffected, then you can multiply the two.

Or if you have access to the axes individually (say you use an API that offers that), just use something ala myMtx.xAxis.NegateInPlace(); myMtx.zAxis.NegateInPlace() for a rotation around Y, and so on.

2

For a 3D rotation about an axis e, note that a rotation of 180 degrees about an axis e will keep the component of any vector x along e the same and impart a negative sign to the perpendicular component. Let x' be the rotated vector. Then:

enter image description here

zed111
  • 200
  • 5
  • 15
-5
-1  0  0
 0 -1  0
 0  0 -1

that should be the right matrix

jcoder
  • 29,554
  • 19
  • 87
  • 130
user416584
  • 37
  • 3
  • 1
    That's a full negation, which will change the handedness of the matrix. Only two axes need negating. –  Feb 12 '13 at 01:09