Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: matrix and rotation

  1. #1
    Junior Member Regular Contributor
    Join Date
    Apr 2010
    Posts
    127

    matrix and rotation

    Hy.
    I have little mesh of 6 3dpoints(x,y,z) and i would rotate these 6 point by the 2 input axis direction.
    I try to create a 3x3 rotation matrix and multiply it by 3dpoints
    .
    I transform all 3dpoint to a vector and multiply it by a matrix create from the axis.
    but how i can create this matrix?
    I have y axes and z axes directions.
    is possible?
    Thanks.

  2. #2
    Intern Contributor
    Join Date
    Oct 2009
    Posts
    56

    Re: matrix and rotation

    First, obtain the X axis from the Y and Z:
    Code :
    X = crossProduct( Y, Z )

    Then simply:
    Code :
    matrix[0,i] = X.i
    matrix[1,i] = Y.i
    matrix[2,i] = Z.i

    Where i takes the values 0, 1 and 2

    Note that you must normalize Y and Z first of all (before calculating X), and of course Y and Z must be orthogonal.

    If Y and Z are not orthogonal, the solution is simple: once you have calculated X, recalculate Z with: Z = crossProduct( X, Y ). If you want to modify Y instead of Z, then do Y = crossProduct( Z, X ).

    If it doesn't work, try swapping the matrix indexes, i.e. instead of matrix[0,i] = X.i try matrix[i,0] = X.i, because it depends on the language you're programming on.

    ----
    Antares game blog: http://antaresgame.blogspot.com/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •