Results 1 to 2 of 2

Thread: gluLookAt up Vector cross product

  1. #1
    Member Newbie
    Join Date
    Jan 2013
    Posts
    48

    gluLookAt up Vector cross product

    Hi,

    in the example for gluLookAt it has
    gluLookAt( 4.0,2.0, 1.0, 2.0, 4.0, -3.0, 2.0, 2.0, -1.0)

    The Up vector 2.0, 2.0, -1.0 is the cross product of 4.0,2.0, 1.0, and 2.0, 4.0, -3.0

    I get the cross product to be 10, 14, 12

    help!

    MacSam

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Oct 2004
    Posts
    4,654
    What are you trying to accomplish? What you're doing doesn't make sense.

    Check out the man page: gluLookAt

    Code cpp:
    void gluLookAt( GLdouble eyeX,  
                    GLdouble eyeY,
                    GLdouble eyeZ,
                    GLdouble centerX,
                    GLdouble centerY,
                    GLdouble centerZ,
                    GLdouble upX,
                    GLdouble upY,
                    GLdouble upZ );

    The first 3 parameters define a position (in WORLD space).
    The 2nd 3 parameters define a position (in WORLD space).
    The 3rd 3 parameters define a vector (in WORLD space).

    Take (center - eye), normalize it, and you've defined a unit vector pointing "forward" in EYE-SPACE (i.e. the direction your camera is looking). However, to define a coordinate space transform, this is unconstrained. You need to know what direction is "up" and what is "right". The "up" parameters give you the former, and the right-hand rule (the cross product you mention) implicitly gives you the latter.

    If you're determined to apply the cross product here, try:

    Code glsl:
    forward_vec = normalize( center - eye );     // This is the eye-space -Z axis (in WORLD space)
    up_vec      = normalize( up );               // This is the eye-space +Y axis (in WORLD space)
    right_vec   = cross( forward_vec, up_vec );  // This is the eye-space +X axis (in WORLD space)

Similar Threads

  1. GLSL Cross Product documentation bug on website
    By cybernoid in forum OpenGL: GLSL
    Replies: 0
    Last Post: 07-10-2016, 08:47 AM
  2. Dot product / Vector angle issue
    By mlfarrell in forum OpenGL: Advanced Coding
    Replies: 9
    Last Post: 01-14-2010, 01:55 PM
  3. correct cross-product method?
    By in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 04-19-2002, 05:28 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