View Full Version : correct cross-product method?

I don't understand how this works... the equation for a cross product is:

A x B = A B sin()

so like (this is a mistake, right?)

A B C

x |3| |0| |0|

y |1| * |3| = |3|

z |4| |2| |8|

so now I've got vector C, but it won't be perpendicular to AB and multiplying C by the sine of the angle between A and B will just increase the magnitude of C.

This must look very obvious to most people here, how do you do it right? I haven't taken calculous yet. http://www.opengl.org/discussion_boards/ubb/frown.gif

Honestly, I have no idea what that chunk of characters in the middle of your post is supposed to look like. Please, either edit your message and put code tags around the chunk (and reformat it!), or post a new message with the chunk inside code tags.

A code tag is [ code ] <you text goes here> [ /code ] (without spaces in the square brackets).

Anyways, a crossproduct is calculated in the same way as a 3x3 matrix determinant, with the following matrix.

[ i j k ]

A cross B = det [ Ax Ay Az ]

[ Bx By Bz ]

A and B is the two vectors you want to cross, and (i j k) is the X, Y and Z axes.

You calculate it in the following way.

A cross B = i*Ay*Bz - i*Az*By + j*Az*Bx - j*Ax*Bz + k*Ax*By - k*Ay*Bx

A cross B = i * (Ay*Bz - Az*By) + j * (Az*Bx - Ax*Bz) + k * (Ax*By - Ay*Bx)

So, the resulting vector (X Y Z) is:

X = (Ay*Bz - Az*By)

Y = (Az*Bx - Ax*Bz)

Z = (Ax*By - Ay*Bx)

Now, if A and B are not unit vectors, you will have a resulting vector that is not unit length, and you must divide the resulting vector with the length of A and B.

And by the way, the formula you gave, A x B = A B sin(), is not correct, it should be more like |A x B| = A B sin().

[This message has been edited by Bob (edited 04-19-2002).]

Gavin

04-19-2002, 03:04 AM

There is some code at....

www.cs.cf.ac.uk/user/G.R.Powell (http://www.cs.cf.ac.uk/user/G.R.Powell)

-> C CODE

gumby

04-19-2002, 05:17 AM

You have confused the cross product and its magnitude.

What you wrote is the magnitude:

|AxB| = |A| |B| sin(theta)

What Bob wrote above is the vector AxB.

Gonna correct myself...

Now, if A and B are not unit vectors, you will have a resulting vector that is not unit length, and you must divide the resulting vector with the length of A and B.

I'm a little bit wrong here. If A and B are unit vectors, the resulting vector may not be of unit length. It's length is equal to sin(theta), where theta is the angle between the two vectors. Sorry for that one.

Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.