Public Group

# GL rotation

This topic is 5150 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

hi all, I couldn't understand the difference of the following set of commands :: 1 ---- glRotatef (30.0, 0.0, 1.0, 0.0); glRotatef (30.0, 0.0, 0.0, 1.0); 2 --- glRotatef (30.0, 0.0,1.0,1.0); Shouldn't the above 2 be same ? ~ boyd

##### Share on other sites
No, the first one is saying to rotate 30 degrees around the Y axis, and then rotate 30 degrees around the Z axis.

The second one is saying to rotate 30 degrees around a line in the Y-Z plane that runs 45 degrees to to both the Y and Z axes.

##### Share on other sites
glRotatef takes four paremeters:
- angle, given in degs
- x, y, z that is vector

so glRotatef rotates model around specified vector...

<ang> < vector >
glRotatef(30.0f, 1.0f, 0.0f, 0.0f); - around X axis
glRotatef(30.0f, 0.0f, 1.0f, 0.0f); - around Y axis
glRotatef(30.0f, 0.0f, 0.0f, 1.0f); - around Z axis

so this function is very flexible

##### Share on other sites
It takes a second to fully get this into one's head but the order that rotations occur changes the final resting place.

To verify this take a book and place it at the corner of a table. Flip it along one edge and the flip it on one of the edges of the book. Note the final resting place, which side is up and the rotation of the cover.

Now do the same rotations in another order. Different place eh?

This is because rotations are essentially matrix transformation, by that I meant the each rotation can be expressed by a matrix and several rotation can be expressed by multiplying them together.

Unlike plain old variable multiplication, matrix multiplication order alters the result. There is a math word for this. Communative I think....

##### Share on other sites
if i not wrong...

glRotationf(angle,vector x,vector y,vector z)

same to:

cVector3d rotate(float angle,float vx,float vy,float vz,cVector3d point)
{
cVector3d temp;

temp.x=(cos(angle)*point.x + sin(angle)*point.z)*vy +
point.x*vx +
(cos(angle)*point.x - sin(angle)*point.y)*vz;

temp.y=point.y*vy +
(point.y * cos(angle) - point.z * sin(angle))*vx +
(point.x * sin(angle) + point.y * cos(angle))*vz;

temp.z=(point.x * -sin(angle) + point.z * cos(angle))*vy +
(point.y * sin(angle) + point.z * cos(angle))*vx +
point.z*vz;

return temp;
}

1 degree = 3.141592653589793 / 180 rad

am i right ?

-ghckr82--

##### Share on other sites
Quote:
 Original post by gohacker82am i right ?

Not really - it modifies the view matrix, it doesn't return a vector. Look here.

##### Share on other sites
sorry not the same but similar..

1. 1
2. 2
3. 3
Rutin
19
4. 4
5. 5
JoeJ
12

• 12
• 21
• 9
• 31
• 16
• ### Forum Statistics

• Total Topics
632618
• Total Posts
3007466
• ### Who's Online (See full list)

There are no registered users currently online

×