Results 1 to 3 of 3

Thread: Transformation matrix problem!

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2007
    Location
    Surabaya
    Posts
    11

    Transformation matrix problem!

    hi... i need help about transformation, i mean rotation object.
    i want to rotate object without glRotatef, so i multiple the points and matrix
    ex.
    rotate x
    1 0 0 | | x | | x
    0 cos -sin |X | y |=| cos * y + (-sin)*z
    0 sin cos | | z | | sin * y + cos * z

    my line program
    double RadTheta=theta*3.14159265358979323846/180.0;

    double CosRadTheta=cos(RadTheta);
    double SinRadTheta=sin(RadTheta);

    for (unsigned int i=1;i<=o->nPoints;i++){
    o->points[i].x=o->points[i].x;
    o->points[i].y=(o->points[i].y*CosRadTheta)+((-SinRadTheta)*o->points[i].z);
    o->points[i].z=(SinRadTheta*o->points[i].y)+(o->points[i].z*CosRadTheta);

    }

    the problem is, the result is not corect. my object not rotate corectly. please help me... what i must do?
    i have change degree to radian (angle*3,14.../180).

  2. #2
    Senior Member OpenGL Pro Zengar's Avatar
    Join Date
    Sep 2001
    Location
    Germany
    Posts
    1,931

    Re: Transformation matrix problem!

    You fall prey for a very basic algorithmic mistake mathematicians usually make: you change the y coordinate but then use it again to compute the z coordinate, where you should have used the old value. You should use a temporary variable that will store the old y value, like

    Code :
    old_y = y
    // compute new y
    // compute new z, with old_y

  3. #3
    Junior Member Newbie
    Join Date
    Oct 2007
    Location
    Surabaya
    Posts
    11

    Re: Transformation matrix problem!

    oh... i see...
    my point y is change!
    wow thank you!

Similar Threads

  1. Perspective transformation matrix problem
    By WormLice in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 04-29-2018, 02:27 PM
  2. Replies: 3
    Last Post: 04-03-2010, 03:10 PM
  3. Matrix transformation
    By in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 09-03-2005, 04:53 PM
  4. matrix transformation
    By hanuni in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 11-21-2002, 06:33 AM
  5. Can concatenate projection matrix with viewport transformation matrix?
    By MelvinEng in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 07-07-2002, 10:31 PM

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