Results 1 to 6 of 6

Thread: correct cross-product method?

  1. #1
    Guest

    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.

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: correct cross-product method?

    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).

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: correct cross-product method?

    Anyways, a crossproduct is calculated in the same way as a 3x3 matrix determinant, with the following matrix.
    Code :
                    [ 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.
    Code :
    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:
    Code :
    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).]

  4. #4
    Senior Member Frequent Contributor
    Join Date
    Aug 2000
    Location
    Cardiff University
    Posts
    653

    Re: correct cross-product method?

    There is some code at....
    www.cs.cf.ac.uk/user/G.R.Powell
    -> C CODE

  5. #5
    Senior Member Regular Contributor
    Join Date
    Mar 2002
    Posts
    103

    Re: correct cross-product method?

    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.

  6. #6
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: correct cross-product method?

    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.

Similar Threads

  1. gluLookAt up Vector cross product
    By macsam in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 06-10-2017, 09:27 AM
  2. Replies: 0
    Last Post: 01-10-2017, 07:37 AM
  3. GLSL Cross Product documentation bug on website
    By cybernoid in forum OpenGL: GLSL
    Replies: 0
    Last Post: 07-10-2016, 08:47 AM
  4. Cross product question
    By blood.angel in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 01-23-2002, 03:39 AM
  5. Quick Cross Product/Dot Product
    By DLink in forum OpenGL: Basic Coding
    Replies: 12
    Last Post: 02-23-2001, 04:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean