#### Archived

This topic is now archived and is closed to further replies.

# Rotation Matrix

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

## Recommended Posts

Hi, how do i create a axis-angle rotation matrix in detail????

##### Share on other sites
glRotatef(angle, 1.0, 0, 0)
the above rotation will multiply the proper rotation matrix automatically by the current matrix. The order in which you perform transformations will drastically vary in the final effect. Think about it. Say your program is only drawing a spere at the grand fixed origin, where the camera rests by default(0,0,0). In your display function, if you wanted to rotate a sphere and then translate it. you''d do this:
void display(void){	glClear(GL_COLOR_BUFFER_BIT);	glColor3f(1.0, 1.0, 1.0);			glPushMatrix();	glTranslatef(-3.0, 0, 0);	glRotatef((GLfloat) ???angle, 0, 1.0, 0);	glutWireSphere(0.05f, 6, 4);	glPopMatrix();        .        .        .[/CODE]^^^^^^^^^The above will first rotate an abstract local origin about the origin, thin will move it "-3" along the x. Done backwards, this would result in the sphere orbiting around the grand origin rather than rotating about it. The normal vectorfor rotation (0,1,0) just says to rotate around the y axis.if it had been(0,0,0), around what would it rotate?!?!?!*notice how rotate comes after translate, it''s because the Matrix multiplication order is backwards, somewhat.i.e. T(R*Sphere)for t = trans, r = rotation***very important to grasp!

##### Share on other sites
well, a rotation matrix that rotate around the Z axis

cos( ang ) -sin( ang ) 0
sin( ang ) cos( ang ) 0
0 0 1

around Y axis

cos( ang ) 0 -sin( ang )
0 1 0
sin( ang ) 0 cos( ang )

and around X axis

1 0 0
0 cos( ang ) -sin( ang )
0 sin( ang ) cos( ang )

i hope this was that you are looking for.

##### Share on other sites
http://www.flipcode.com/documents/matrfaq.html

##### Share on other sites
given angle
and a direction (x, y, z) (where ||(x, y, z)|| = 1)

then the matrix is
<pre>
xx * (1 - c) + c xy * (1- c) - zs xz * (1 - c) + ys 0
yx * (1 - c) + zs yy * (1 - c) + c yz * (1 - c) - xs 0
zx * (1 - c) - ys zy * (1 - c) + xs zz * (1 - c) + c 0
0 0 0 1
</pre>

where c = cos(angle)
where s = sin(angle)

1. 1
Rutin
40
2. 2
3. 3
4. 4
5. 5

• 12
• 18
• 12
• 14
• 9
• ### Forum Statistics

• Total Topics
633359
• Total Posts
3011513
• ### Who's Online (See full list)

There are no registered users currently online

×