1 / 13

CS770/870

CS770/870. Class 4. Translation. Scale. Multiplying Matrices. The R C rule What happens when we do two translates? What happens when we do two scales? What happens when we translate and scale, or scale then translate (Commutative?) Exercise. Matrices in GL virtual machine.

oren-henry
Download Presentation

CS770/870

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS770/870 Class 4

  2. Translation

  3. Scale

  4. Multiplying Matrices. The R C rule What happens when we do two translates? What happens when we do two scales? What happens when we translate and scale, or scale then translate (Commutative?) Exercise

  5. Matrices in GL virtual machine OpenGL maintains a matrix stack glPushMatrix() creates pushes a new 4x4 matrix on the top of the stack containing a copy of the existing top of stack matrix. glTranslate, glScale and glRotate cause a new matrix to be contructed and post multiplied by the top of the stack.

  6. The matrix stack glLoadIdentity(); M1 I glRotatef(); M1 IR1 glTranslatef(); M1  IR1T1 glScalef(); M1  IR1T1S1 glPushMatrix(); M2  M1 glTranslatef(); M2  M1T2 glPushMatrix(); M3  M2 M1 M1 M2 M1

  7. The view window to viewport transformation In open GL As a set of matrixes

  8. Rotation about z axis

  9. Derive rotation about z Take notes Rotations about x and y.

  10. Exercise: do it by drawing Given a square glRectf(-1,-1,1,1) glRotatef(-30.0,0,0,1); glScalef(2.0,1.0,1.0); gLTranslatef(2.0,0.0,0.0); glRectf (-1,-1,1,1); glTranslatef(0.0,2.0,0.0); glScalef(1.0,2.0,1.0); glRotatef(45,0.0,0.0, 1.0); glRectf (-1,-1,1,1);

  11. The Scene window to viewport mapping Scene window box (Lsw, Rsw, Bsw, Tsw) Viewport box (Lvp, Rvp, Bvp, Tvp); Exercise specify open gl commands to accomplish this) If time construct the matrix(Just the top row)

  12. Some basic linear algebra (CH 4) Dot and Cross Product. A dot product of unit vectors gives the cosine of the angle between two unit vectors a.b = (a1*b1 + a2*b2 + a3*b3) = |a||b|cos(q); |a| = Sqrt(a1*a1+ a2*a2+ a3*a3); a/|a| = a1/|a| + a2/|a| + a3/|a| // unit vector

  13. Cross Product of two vectors a xb = (a1, a2, a3)T x (b1, b2, b3) The result is a vector = (a2 * b3) – (a3 * b2), (a3 * b1) – (a1 * b3), (a1 * b2) – (a2 * b1) If both vectors are unit vectors the result is at right angles to the plane running through the other two.

More Related