# cross product

This topic is 3932 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, I've been using the crossproduct to calculate the normal vector for two given vectors in 3d space, which I calculate by doing: v × w = (vywz − wyvz, vzwx − wzvx, vxwy − wxvy ) I tried to see why this calculation results in a vector perpendicular to the plane v & w form, but can't figure out why that is. In 2D for 1 vector it is simple enough, you just switch (x,y) with (-y,x)to get a perpendicular vector. But I can't see why the crossproduct does this in 3d for two vectors... Could anyone explain me why? [Edited by - bitshit on October 13, 2007 1:48:29 PM]

##### Share on other sites
This is quite easy to show if you know that the dot product of two non-zero vectors is 0 if and only if they are perpendicular.

v * (v x w) = vxvywz - vxwyvz + vyvzwx − vywzvx + vzvxwy − vzwxvy = 0

##### Share on other sites
What you can do is plug the unknown output vector (x,y,z) into the top row of a 3x3 matrix, where the other two rows are the input vectors (vx,vy,vz) and (wx,wy,wz):
[  x  y  z ][ vx vy vz ][ wx wy wz ]

We know that the determinant of a matrix should be the hyper-volume of the parallelepiped formed by the vectors of that matrix. Since we want (x,y,z) to be perpendicular to the input vectors, the parallelepiped is going to look like a parallelogram that also has a height, with no sheering. Volume is base area times height. It just so happens that the length of the cross product is both the base area and the height, meaning that |(v x w)|2 = volume = determinant (the squared length of the cross product equals the determinant). If we expand the above determinant we get:

x(vywz - wyvz) + y(vzwx - vxwz) + z(vxwy - vywx) = determinant

Clearly, if we let x, y, and z equal their constant factors from the above equation, we satisfy all our conditions.

##### Share on other sites
Perhaps the easiest way is as follows.

if p = (1, 0, 0) and q = (0, 1, 0)

There are two candidates for the perpendicular to these two vectors, p ^ q, and we chose p ^ q = (0, 0, 1) not (0, 0, -1) by convention.

Note that this is the vx.wy of

(vy.wz − wy.vz, vz.wx − wz.vx, vx.wy − wx.vy)

Then if r = (0, 0, 1) you can similarly write down p ^ r, r ^ p. Reversed they are negated as the cross product is anti-symmetric. You should find they correspond to the other terms in the formula for v ^ w. The rest follows by linearity, i.e. because

(a ^ b) + (a ^ c) = a ^ (b + c)

and m(a ^ b) = (ma) ^ b

You can combine them to produce the full cross product.

##### Share on other sites
Thanks guys! The penny dropped :)

1. 1
2. 2
Rutin
26
3. 3
4. 4
JoeJ
18
5. 5
gaxio
11

• 14
• 22
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631763
• Total Posts
3002197
×

## Important Information

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!