Uploaded by naira tarek

sheet 3

advertisement
Misr University for Science
and Technology
College of Information
Technology
Q1 :
a) Using OpenGL readymade transformation functions:
Rotate a triangle having Vertexes (-2, -1); (1, -1) and (0, 2)
around z axis by 45 degrees
Answer
glRotatef (45,0,0,1);
glBegin (GL_TRIANGLES);
glVertex3f (-2.0,-1.0,0.0);
glVertex3f (1.0,-1.0,0.0);
glVertex3f (0.0,2.0,0.0);
glEnd();
Q2 :
Translate a point at the origin to (0,0,50), then rotate it by -45 degrees around the X axis
Answer
Pnew = R*T*P
T=
1
0
0
0
0 1
0
0
0 0
1 50
0 0
0 1
1
0
0
0
0
0.7071
0.7071
0
0 -0.7071
0.7071
0
0
1
R=
0
0
R*T =
1
0
0
0
0.7071
0.7071
35.354
0 -0.7071
0.7071
35.354
0
P new =
0
0
35.354
35.354
1
0
0
1
Download