I have worked this out on paper and I'm hoping someone can point out my mistake.

A "look at" matrix is supposed to rotate you so your old $(x,y,z)$ coordinate axes become aligned with a new set of coordinate axes $(newx, newy, newz)$. Basically a change of basis.

Working in an LH coordinate system, using row major matrices, according to this document, this rotation matrix should be constructed as:

$$ \left[ \matrix { newx.x&newy.x&newz.x \\ newx.y&newy.y&newz.y \\ newx.z&newy.z&newz.z } \right] $$

(Note I have left off the final translation row from the article - assuming we are working with 3x3 matrices here.)

Assume I pass in

  • $eye=(0,0,0)$ (so there is no translation, only rotation of the coordinate axes),
  • $at=(0,0,1)$ (so we are "looking down the +z axis"),
  • $up=(\frac{-1}{2}, \frac{\sqrt{3}}{2}, 0)$ (so we basically are doing a 30 degree rotation about the z-axis).


  • $newz=(0,0,1)$,
  • $newx=( \frac{\sqrt{3}}{2}, \frac{1}{2}, 0 )$,
  • $newy=(\frac{-1}{2}, \frac{\sqrt{3}}{2}, 0)$

So far we are on track: the $newz$ vector points in the same direction it did before, $newx$ is 30 degrees rotated about the z-axis, and $newy$ is 30 degrees rotated about the z-axis.

Form the rotation matrix:

$$ \left[ \matrix { \frac{\sqrt{3}}{2} & \frac{-1}{2} & 0 \\ \frac{1}{2} & \frac{\sqrt{3}}{2} & 0 \\ 0 & 0 & 1 } \right] $$

(I tested this on a computer and this is exactly the matrix that the library will form, with these inputs),

Yet premultiply with a sample vector like $ \left[ \matrix{1&0&0} \right] $, and get $ \left[ \matrix{ \frac{\sqrt{3}}{2} & \frac{-1}{2}& 0 } \right] $ as the result, meaning $ \left[ \matrix{1&0&0} \right] $ lands rotated negative 30 degrees, not as expected.

If you transpose this rotation matrix though, you will get the expected answer of $ \left[ \matrix{ \frac{\sqrt{3}}{2} & \frac{1}{2}& 0 } \right] $.

Where have I gone wrong?

  • $\begingroup$ If you have a rotation matrix $J(\theta)$ that rotates by an angle of $\theta$, its transpose rotates by an angle of $-\theta$, due to the matrices being orthogonal. Another way to put it: if $J$ rotates stuff anticlockwise, its transpose rotates things clockwise. $\endgroup$ Jul 23, 2011 at 19:26
  • 1
    $\begingroup$ I always found change of basis extremely confusing myself, and even now I'm not convinced I know what the accepted convention is. The problem is this: is the universe changing, or are you only changing your perspective on the universe? $\endgroup$ Jul 23, 2011 at 19:41
  • 2
    $\begingroup$ @Qiaochu: covariant versus contravariant. $\endgroup$ Jul 23, 2011 at 19:45
  • 3
    $\begingroup$ @Willie: yes, it's easy to say that, but sometimes it isn't clear to me what is a covariant variable and what is a contravariant variable. I thought I could tell, and then I took a course on special relativity, which proved to me that I actually couldn't... $\endgroup$ Jul 24, 2011 at 4:34
  • 3
    $\begingroup$ @Qiaochu: the way I like to explain it to linear algebra students is via measurement (basically linear functionals, but not in so scary words). First you chose some fundamental rulers. Things you directly measure with the rulers are contravariant (you can demonstrate this in a classroom directly). Things you measure by comparing against a contravariant object is covariant. $\endgroup$ Jul 24, 2011 at 13:27

1 Answer 1


Ok, I get it. This is an unrotation matrix. The "look at" matrix unrotates things to align with the coordinate axes (ie its an inverse of the rotation matrix that would produce that rotation).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.