Monday, July 20, 2009

Constructing a vector basis

This is a blog posting targeted at my self. Every time I need to construct a vector basis in 3D space,I can't remember the argument order to the cross products, and each time I have a hard time finding a reference, making me write test code to find out. So here it is, recorded for my future references. If you mess up order, you are likely to end up with a left handed coordinate system. As a mnemonic, you can use the rule that the arguments are in alphabetical order, except for the Y axis. This will give you the following argument orders for the cross products:

X = Cross( Y, Z )
Y = Cross( Z, X ) // NOT Cross( X, Z )
Z = Cross( X, Y )


Bram said...

And for the geeks reading this, also check out this story about a bid from suppliers to Opera.

Anonymous said...

Nice reference, but I think you got the last one wrong. It should be 'Z = Cross( X, Y )'.

That last one is way I remember how to make a right-hand coordinate system. Point the fingers of your right hand in the X axis direction and curl your fingers toward the Y axis, then your thumb will be pointing along the positive Z axis.

Also, see the history of XYZZY at:

Bram said...

Argh Argh Argh!
How could I mess this up?
Thanks for the correction.