PDA

View Full Version : Transformation matrix problem!

matsurambo
07-30-2008, 05:18 AM
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

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

}

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

Zengar
07-30-2008, 05:24 AM
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

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

matsurambo
07-30-2008, 05:53 AM
oh... i see...
my point y is change!
wow thank you!