• Embed Doc
  • Readcast
  • Collections
  • CommentGo Back
Download
 
1
page 1CPSC453
CPSC 453CPSC 453
Transformations & OpenGLTransformations & OpenGL3D3D
Lecture VIILecture VII
page 2CPSC453
2D rotation revisited2D rotation revisited
As matrix multiplication:
It can be used for points or vectors
Transforming endpoints is enough
Other transformations can be expressed using matrixmultiplication
 
2
page 3CPSC453
Transformations & MatricesTransformations & Matrices
CG transformations as matrix multiplications
P’= rotate( P,
θ
) can be written as
P’= R(
θ
) P
Multiple transformations
single matrix
P
1
= R(
θ
) P
0
P
2
= T(v
x
,v
y
,v
z
) P
1
P
3
= S(s
x
,s
y
,s
z
) P
2
Or
P
3
= S(s
x
,s
y
,s
z
)T(v
x
,v
y
,v
z
)R(
θ
) P
0
Transformation matrixCombined transformation matrix
page 4CPSC453
Transformations & OpenGLTransformations & OpenGL
Current Transformation Matrix (CTM)
Initially CTM = I
glScalef()
CTM
CTM * S
glTranslatef()
CTM
CTM * T
CTM is Post-multiplied
Transformation specified in ‘reverse order’
Allows for hierarchical models
 
3
page 5CPSC453
Transformations & OpenGLTransformations & OpenGL
Current Transformation Matrix (CTM)
Initially is set to the 4x4 identity matrix
CurrentTransformationverticesvertices
page 6CPSC453
ExampleExample –  – hierarchical modelhierarchical model
void mydisplay() {glClear( GL_COLOR_BUFFER_BIT );for( float angle = 0 ; angle < 360 ; angle += 30 ) {glLoadIdentity();glRotatef( angle, 0, 0, -1 );glTranslatef( 0, 0.75, 0 );glScalef( 0.2, 0.2, 0 );draw_square();}glFlush();}
of 00

Leave a Comment

You must be to leave a comment.
Submit
Characters: ...
You must be to leave a comment.
Submit
Characters: ...