CS 4731: Computer Graphics Lecture 8: 3D Affine transforms Emmanuel Agu.

Slides:



Advertisements
Similar presentations
Computer Graphics: 2D Transformations
Advertisements

Computer Graphics 2D & 3D Transformation.
University of North Carolina at Greensboro
Geometric Transformations
Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 51 Today’s class Geometric objects and transformations.
HCI 530 : Seminar (HCI) Damian Schofield. HCI 530: Seminar (HCI) Transforms –Two Dimensional –Three Dimensional The Graphics Pipeline.
CS 4731: Computer Graphics Lecture 7: Introduction to Transforms, 2D transforms Emmanuel Agu.
Elementary 3D Transformations - a "Graphics Engine" Transformation procedures Transformations of coordinate systems Translation Scaling Rotation.
1 CSCE 441 Computer Graphics: 2D Transformations Jinxiang Chai.
2D/3D Geometric Transformations CS485/685 Computer Vision Dr. George Bebis.
3D Coordinate Systems and Transformations Revision 1
2.1 si SI31 Advanced Computer Graphics AGR Lecture 2 Basic Modelling.
Computer Graphics using OpenGL, 3 rd Edition F. S. Hill, Jr. and S. Kelley Chapter Vector Tools for Graphics.
Transformations CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
Computer Graphics with OpenGL 3e
2D Transformations x y x y x y. 2D Transformation Given a 2D object, transformation is to change the object’s Position (translation) Size (scaling) Orientation.
2D Transformations Unit - 3. Why Transformations? In graphics, once we have an object described, transformations are used to move that object, scale it.
Mathematical Fundamentals
COS 397 Computer Graphics Svetla Boytcheva AUBG, Spring 2013.
Transformations of Objects CVG lab. Introduction  Affine transformations : Affine transformations are a fundamental cornerstone of computer graphics.
CS 480/680 Computer Graphics Representation Dr. Frederick C Harris, Jr. Fall 2012.
Geometric Transformation. So far…. We have been discussing the basic elements of geometric programming. We have discussed points, vectors and their operations.
Transformations Dr. Amy Zhang.
CS 480/680 Computer Graphics Transformations Dr. Frederick C Harris, Jr.
Lecture Notes: Computer Graphics.
Computer Graphics Raster Devices Transformations Areg Sarkissian.
2003CS Hons RW778 Graphics1 Chapter 5: Transforming Objects 5.2 Introduction to Transformations 5.2 Introduction to Transformations –Affine transformations.
Dx = 2 dy = 3 Y X D Translation A translation is applied to an object by repositioning it along a straight-line path.
Part7: Geometric Transformations
Chi-Cheng Lin, Winona State University CS430 Computer Graphics Transformations of Objects – 2D Part I.
CSE 681 Review: Transformations. CSE 681 Transformations Modeling transformations build complex models by positioning (transforming) simple components.
CS 376 Introduction to Computer Graphics 02 / 16 / 2007 Instructor: Michael Eckmann.
Transformations of Objects – 3D
Computer Graphics 2D Transformations. 2 of 74 Contents In today’s lecture we’ll cover the following: –Why transformations –Transformations Translation.
1 Computer Graphics Week9 -3D Geometric Transformation.
16/5/ :47 UML Computer Graphics Conceptual Model Application Model Application Program Graphics System Output Devices Input Devices API Function.
Transformational Geometry CS418 Computer Graphics John C. Hart.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
Computer Graphics 3D Transformations. Translation.
Affine Transformation. Affine Transformations In this lecture, we will continue with the discussion of the remaining affine transformations and composite.
3D Transformation A 3D point (x,y,z) – x,y, and z coordinates
January 19, y X Z Translations Objects are usually defined relative to their own coordinate system. We can translate points in space to new positions.
Graphics Lecture 2: Slide 1 Lecture 2 Transformations for animation.
II-1 Transformations Transformations are needed to: –Position objects defined relative to the origin –Build scenes based on hierarchies –Project objects.
Learning Objectives Affine transformations Affine transformations Translation Translation Rotation Rotation Scaling Scaling Reflection Reflection Shear.
1 By Dr. HANY ELSALAMONY.  We have seen how to create models in the 3D world. We discussed transforms in lecture 3, and we have used some transformations.
Homogeneous Coordinates and Matrix Representations Cartesian coordinate (x, y, z) Homogeneous coordinate (x h, y h, z h, h) Usually h = 1. But there are.
Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.
Computer Graphics I, Fall 2010 Transformations.
1 Teaching Innovation - Entrepreneurial - Global The Centre for Technology enabled Teaching & Learning, N Y S S, India DTEL DTEL (Department for Technology.
CS 325 Introduction to Computer Graphics 02 / 19 / 2010 Instructor: Michael Eckmann.
Transformations in 3D Lecture 17 Mon, Oct 6, 2003.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
Computer Graphic 2 D Transformation.
CSCE 441 Computer Graphics: 2D Transformations
Transformations. Transformations Introduce standard transformations ◦ Rotation ◦ Translation ◦ Scaling ◦ Shear Derive homogeneous coordinate transformation.
Math Fundamentals Maths revisit.
Transforms.
Geometric Transformations Hearn & Baker Chapter 5
Computer Graphics Transformations.
2D Transformations with Matrices
Review: Transformations
Computer Graphics Transformations.
2D Transformations y y x x y x.
Three-Dimensional Graphics
Chapter IV Spaces and Transforms
Three-Dimensional Graphics
Geometric Transformations
Geometric Objects and Transformations (II)
Presentation transcript:

CS 4731: Computer Graphics Lecture 8: 3D Affine transforms Emmanuel Agu

Introduction to Transformations Introduce 3D affine transformation: Position (translation) Size (scaling) Orientation (rotation) Shapes (shear) Previously developed 2D (x,y) Now, extend to 3D or (x,y,z) case Extend transform matrices to 3D Enable transformation of points by multiplication

Point Representation Previously, point in 2D as column matrix Now, extending to 3D, add z-component: or

3D Coordinate Systems x Y +z x y Right hand coordinate system Left hand coordinate system Not used in this class and Not in OpenGL +z All perpendicular: X x Y = Z ; Y x Z = X; Z x X = Y; Tip: sweep fingers x-y: thumb is z

Transforms in 3D 2D: 3x3 matrix multiplication 3D: 4x4 matrix multiplication: homogenous coordinates Recall: transform object = transform each vertice General form: Xform of P

3x3 2D Translation Matrix  Previously, 2D :

3x3 2D Translation Matrix  Now, 3D :  Where: x’= x.1 + y.0 + z.0 + tx.1 = x + tx, … etc OpenGL: gltranslated(tx,ty,tz)

2D Scaling  Scale: Alter object size by scaling factor (s x, s y ). i.e x’ = x. Sx y’ = y. Sy (1,1) (2,2) Sx = 2, Sy = 2 (2,2) (4,4)

3x3 2D Scaling Matrix

4x4 3D Scaling Matrix Example: If Sx = Sy = Sz = 0.5 Can scale: big cube (sides = 1) to small cube ( sides = 0.5) 2D: square, 3D cube OpenGL: glScaled(Sx,Sy,Sz)

Rotation (x,y) (x’,y’)  (x,y) -> Rotate about the origin by  (x’, y’) How to compute (x’, y’) ?  x = r cos () y = r sin () r x’ = r cos ( +) y = r sin ( +)

Rotation (x,y) (x’,y’)   r x’ = x cos(  ) – y sin(  ) y’ = y cos(  ) + x sin(  ) Matrix form? 3 x 3? Using trig identity

3x3 2D Rotation Matrix (x,y) (x’,y’)   r

Rotating in 3D Cannot do mindless conversion like before Why? Rotate about what axis? 3D rotation: about a defined axis Different Xform matrix for: Rotation about x-axis Rotation about y-axis Rotation about z-axis New terminology X-roll: rotation about x-axis Y-roll: rotation about y-axis Z-roll: rotation about z-axis

Rotating in 3D New terminology X-roll: rotation about x-axis Y-roll: rotation about y-axis Z-roll: rotation about z-axis Which way is +ve rotation Look in –ve direction (into +ve arrow) CCW is +ve rotation x y z +

Rotating in 3D

For a rotation angle,  about an axis Define: A x-roll: OpenGL: glrotated(, 1,0,0)

Rotating in 3D A y-roll: A z-roll: Rules: Rotate row, column int. is 1 Rest of row/col is 0 c,s in rect pattern OpenGL: glrotated(, 0,1,0) OpenGL: glrotated(, 0,0,1)

Rotating in 3D Q: Using y-roll equation, rotate P = (3,1,4) by 30 degrees: A: c = cos(30) = 0.866, s = sin(30) = 0.5, and E.g. first line: 3.c s = 4.6

Rotating in 3D Q: Write C code to Multiply point P = (Px, Py, Pz, 1) by a 4x4 matrix shown below to give new point Q = (Qx,Qy,Qz, 1). i.e. where

Rotating in 3D Outline of solution: Declare P,Q as array: Double P[4], Q[4]; Declare transform matrix as 2-dimensional array Double M[4][4]; Remember: C indexes from 0, not 1 Long way: Write out equations line by line expression for Q[i] E.g. Q[0] = P[0]*M[0][0] + P[1]*M[0][1] + P[2]*M[0][2] + P[3]*M[0][3] Cute way: Use indexing, say i for outer loop, j for inner loop

Rotating in 3D Using loops looks like: for(i=0;i<4;i++) { temp = 0; for(j=0;j<4;j++) { temp += P[j]*M[i][j]; } Q[i] = temp; } Test matrice code rigorously Use known results (or by hand) and plug into your code

3D Rotation About Arbitrary Axis Arbitrary rotation axis (rx, ry, rz) openGL: rotate(, rx, ry, rz) Without openGL: a little hairy!! Important: read Hill pp x z y (rx, ry, rz)

3D Rotation About Arbitrary Axis Can compose arbitrary rotation as combination of: X-roll Y-roll Z-roll

3D Rotation About Arbitrary Axis Classic: use Euler’s theorem Euler’s theorem: any sequence of rotations = one rotation about some axis Our approach: Want to rotate  about the axis u through origin and arbitrary point Use two rotations to align u and x-axis Do x-roll through angle  Negate two previous rotations to de-align u and x-axis

3D Rotation About Arbitrary Axis

Composing Transformation Composing transformation – applying several transforms in succession to form one overall transformation Example: M1 X M2 X M3 X P where M1, M2, M3 are transform matrices applied to P Be careful with the order Matrix multiplication is not commutative

References Hill, chapter 5.3