Computer Graphics Geometric Transformations

Similar documents
CS 4204 Computer Graphics

Computer Graphics. Chapter 5 Geometric Transformations. Somsak Walairacht, Computer Engineering, KMITL

Computer Graphics. Chapter 7 2D Geometric Transformations

Transformations. CSCI 420 Computer Graphics Lecture 4

Rendering Pipeline and Coordinates Transforms

Lecture 6 Sections 4.3, 4.6, 4.7. Wed, Sep 9, 2009

EECE 478. Learning Objectives. Learning Objectives. Linear Algebra and 3D Geometry. Linear algebra in 3D. Coordinate systems

CSC 470 Computer Graphics

Transforms. COMP 575/770 Spring 2013

Computer Graphics Geometry and Transform

2D transformations: An introduction to the maths behind computer graphics

2D Image Transforms Computer Vision (Kris Kitani) Carnegie Mellon University

Lecture 4: Transformations and Matrices. CSE Computer Graphics (Fall 2010)

3D Mathematics. Co-ordinate systems, 3D primitives and affine transformations

2D and 3D Coordinate Systems and Transformations

Graphics and Interaction Transformation geometry and homogeneous coordinates

COMP30019 Graphics and Interaction Transformation geometry and homogeneous coordinates

GL_MODELVIEW transformation

2D and 3D Transformations AUI Course Denbigh Starkey

CS 428: Fall Introduction to. Transformations in OpenGL + hierarchical modeling. Andrew Nealen, Rutgers, /21/2009 1

UNIT 2 2D TRANSFORMATIONS

Reading. Hierarchical Modeling. Symbols and instances. Required: Angel, sections , 9.8. Optional:

Last week. Machiraju/Zhang/Möller/Fuhrmann

Computer Graphics with OpenGL ES (J. Han) Chapter IV Spaces and Transforms

1 Transformations. Chapter 1. Transformations. Department of Computer Science and Engineering 1-1

Transforms 1 Christian Miller CS Fall 2011

COMP30019 Graphics and Interaction Three-dimensional transformation geometry and perspective

Computer Graphics Seminar

Hierarchical Modeling. University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell

GEOMETRIC TRANSFORMATIONS AND VIEWING

Transformations. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

Affine Transformations in 3D

CS D Transformation. Junqiao Zhao 赵君峤

Modeling Transform. Chapter 4 Geometric Transformations. Overview. Instancing. Specify transformation for objects 李同益

CS380: Computer Graphics 2D Imaging and Transformation. Sung-Eui Yoon ( 윤성의 ) Course URL:

Fall CSCI 420: Computer Graphics. 2.2 Transformations. Hao Li.

2D TRANSFORMATIONS AND MATRICES

Computer Graphics (CS 4731) Lecture 11: Implementing Transformations. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Computer Graphics Geometry and Transform

Coordinate transformations. 5554: Packet 8 1

Review of Thursday. xa + yb xc + yd

CS Computer Graphics: Transformations & The Synthetic Camera

Computer Graphics (CS 4731) Lecture 11: Implementing Transformations. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Lecture 5b. Transformation

Transformations. CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science

Objectives. transformation. General Transformations. Affine Transformations. Notation. Pipeline Implementation. Introduce standard transformations

Spring 2013, CS 112 Programming Assignment 2 Submission Due: April 26, 2013

Transformations. Mike Bailey. Oregon State University. Oregon State University. Computer Graphics. transformations.

GRAFIKA KOMPUTER. ~ M. Ali Fauzi

CS4202: Test. 1. Write the letter corresponding to the library name next to the statement or statements that describe library.

Transformation Algebra

Transformations Computer Graphics I Lecture 4

Affine Transformation. Edith Law & Mike Terry

Section III: TRANSFORMATIONS

Modeling Objects by Polygonal Approximations. Linear and Affine Transformations (Maps)

Affine Transformations Computer Graphics Scott D. Anderson

Transformations. CSCI 420 Computer Graphics Lecture 5

Transformations. OpenGL Transformations. 4x4 Model-view Matrix (this lecture) OpenGL Transformation Matrices. 4x4 Projection Matrix (next lecture)

Overview. Affine Transformations (2D and 3D) Coordinate System Transformations Vectors Rays and Intersections

521493S Computer Graphics Exercise 2 Solution (Chapters 4-5)

The Viewing Pipeline adaptation of Paul Bunn & Kerryn Hugo s notes

Computer Graphics. P04 Transformations. Aleksandra Pizurica Ghent University

Transformations Computer Graphics I Lecture 4

Fachhochschule Regensburg, Germany, February 15, 2017

3D Transformation. In 3D, we have x, y, and z. We will continue use column vectors:. Homogenous systems:. x y z. x y z. glvertex3f(x, y,z);

蔡侑庭 (Yu-Ting Tsai) National Chiao Tung University, Taiwan. Prof. Wen-Chieh Lin s CG Slides OpenGL 2.1 Specification

Projection Lecture Series

Today s class. Viewing transformation Menus Mandelbrot set and pixel drawing. Informationsteknologi

Moving Objects. We need to move our objects in 3D space.

Overview. By end of the week:

7. 3D Viewing. Projection: why is projection necessary? CS Dept, Univ of Kentucky

Lecture 5 2D Transformation

1/29/13. Computer Graphics. Transformations. Simple Transformations

CT5510: Computer Graphics. Transformation BOCHANG MOON

Computer Graphics. Bing-Yu Chen National Taiwan University

Image warping , , Computational Photography Fall 2017, Lecture 10

(x, y) (ρ, θ) ρ θ. Polar Coordinates. Cartesian Coordinates

Today. Today. Introduction. Matrices. Matrices. Computergrafik. Transformations & matrices Introduction Matrices

2D/3D Geometric Transformations and Scene Graphs

Specifying Complex Scenes

CS452/552; EE465/505. Transformations

Transformations. Examples of transformations: shear. scaling

OpenGL Transformations

Computer Science 336 Fall 2017 Homework 2

Perspective projection and Transformations

Translation. 3D Transformations. Rotation about z axis. Scaling. CS 4620 Lecture 8. 3 Cornell CS4620 Fall 2009!Lecture 8

Hello, welcome to the video lecture series on Digital Image Processing. So in today's lecture

Math background. 2D Geometric Transformations. Implicit representations. Explicit representations. Read: CS 4620 Lecture 6

Chapter 3 - Basic Mathematics for 3D Computer Graphics

Computer Graphics 7: Viewing in 3-D

Computer Graphics Hands-on

INF3320 Computer Graphics and Discrete Geometry

Linear transformations Affine transformations Transformations in 3D. Graphics 2009/2010, period 1. Lecture 5: linear and affine transformations

Transformations Week 9, Lecture 18

COMP3421. Vector geometry, Clipping

1 Affine and Projective Coordinate Notation

Computer Graphics: Geometric Transformations

Object Representation Affine Transforms. Polygonal Representation. Polygonal Representation. Polygonal Representation of Objects

Transformations: 2D Transforms

Transformations IV. Week 3, Wed Jan 20

Transcription:

Computer Graphics 2016 6. Geometric Transformations Hongxin Zhang State Key Lab of CAD&CG, Zhejiang University 2016-10-31

Contents Transformations Homogeneous Co-ordinates Matrix Representations of Transformations

Transformations Procedures to compute new positions of objects Used to modify objects or to transform (map) from one co-ordinate system to another co-ordinate system As all objects are eventually represented using points, it is enough to know how to transform points.

Translation Is a Rigid Body Transformation x => x+ T x y => y + T y z => z + T z Translation vector (T x, T y, T z ) or shift vector

Scaling Changing the size of an object x => x * S x y => y * S y z => z * S z Scale factor (S x, S y, S z ) S y = 1 S x = 1 S x = S y

Shearing Produces shape distortions Shearing in x-direction x => x + a* y y => y z => z

Rotation y (x, y ) θ (x, y) α x

Rotate around (x r,y r ) y (x, y ) θ newx = x x r newy = y y r (x r, y r ) φ (x, y) newx = newx cosθ newy sinθ newy = newy cosθ + newx sinθ x x = newx + x r y = newy + y r x = x r + (x x r )cosθ (y y r )sinθ y = y r + (y y r )cosθ + (x x r )sinθ

General Linear Transformation x => a*x + b*y + c*z y => d*x + e*y + f*z or z => g*x + h*y + i*z Which of the following can be represented in this form? Translation Scaling Rotation

General Linear Transformation x = x cosθ y sinθ y = y cosθ + x sinθ x = x Sx y = y Sy x = x+t x y = y+t y???

Homogeneous Co-ordinates (x, y)! (x, y, a) (x, y)! (x, y, 1) x = x a,y = y a Any point (x, y, z) in Cartesian co-ordinates is written as (xw, yw, zw, w),w 6= 0 in Homogeneous Co-ordinates The point (x, y, z, w) represents in Cartesian co-ordinates (x/w, y/w, z/w),w 6= 0 What happens when w=0? the point represented is a point at infinity

xʹ = x cosθ y sinθ yʹ = y cosθ + x sinθ xʹ = x Sx yʹ = y Sy xʹ = x+t x yʹ = y+t y???

Matrix Notations for Transformations Point P (x,y,z) is written as the column vector P h A transformation is represented by a 4x4 matrix M The transformation is performed by matrix multiplication Q h = M * P h 19

Matrix Representations and Homogeneous Co-ordinates Each of the transformations defined above can be represented by a 4x4 matrix Composition of transformations is represented by product of matrices So composition of transformations is also represented by 4x4 matrix

Matrix Representations of Various Transformations Translation Scaling

Matrix Representations of Various Transformations (contd.) Shearing (in X direction)

Matrix Representations of Various Transformations (contd.) Rotation (around Z axis) y (x, y, z ) (x, y, z) θ x z

Matrix Representations of Various Transformations (contd.) y Rotation (around X axis) (x, y, z ) (x, y, z) θ x z

Matrix Representations of Various Transformations (contd.) Rotation (around Y axis) y (x, y, z ) θ (x, y, z) x question : why? z

Properties of Transformations Type Preserves Rigid Body: Rotation & translation Linear General 3x3 matrix Affine Linear + translation Projective 4x4 matrix with last row (0,0,0,1) Lengths Yes No No No Angles Yes No No No Parallelness Yes Yes Yes No Straight lines Yes Yes Yes Yes

Simple Rotation Suppose we wish to rotate the cat s head about its nose!

To rotate the cat s head about its nose 1. Translate the Nose to the Origin 3. Translate back 2. Rotate by the desired amount

Composition... This is an instance of a general rule: to apply transformation A to point p, and the transform result by transformation B, to obtain, say, q: q = (B A) p = B (A p)

Composite Transformation Resultant of a sequence of transformations Composite transformation matrix is equal to the product of the sequence of the given transformation matrices Q h = M n * * M 2 * M 1 * P h = M * P h

Rotation About Point P (Math) Point about which to rotate P = Translate to Origin M 1 = 1 0 T x 0 1 T y 0 0 1 M 2 = Rotate T x T y 1 cos( θ ) sin ( θ ) 0 sin ( θ ) cos( θ ) 0 0 0 1 Translate Back M 3 = 1 0 T x 0 1 T y 0 0 1 Composition Maps a Point A to new Point B. M 4 = 1 0 T x 0 1 T y 0 0 1 cos ( θ ) sin( θ ) 0 sin( θ ) cos ( θ ) 0 0 0 1 1 0 T x 0 1 T y 0 0 1 M 4 = cos ( θ ) sin ( θ ) cos ( θ ) T x + sin ( θ ) T y + T x sin ( θ ) cos( θ ) sin ( θ ) T x cos ( θ ) T y + T y 0 0 1

Scaling About Point P Scaling also operates relative to the Origin. To make an object bigger without moving it Translate P to origin. Apply scaling. Inverse translation. M 4 = 1 0 T x 0 1 T y 0 0 1 S x 0 0 0 S y 0 0 0 1 1 0 T x 0 1 T y 0 0 1 = S x 0 S + x T x 0 S y S y T y + 0 0 1 T x T y

Matrix Multiplication is Not Commutative First rotate, then translate => First translate, then rotate =>

Composite of basic transformations Order of multiplication of the matrices is important because matrix multiplication is not commutative Most of the transformations that we normally deal with can be obtained as composite of the 3 basic transformations, i.e., translation, scaling, and rotation

Rotation about arbitrary axis Given: Axis: (x 1,y 1,z 1 ) to (x 2,y 2,z 2 ) Angle of rotation: θ Procedure θ 1. Transform so that the given axis coincides with the Z axis 2. Rotate by θ 3. Apply inverse of step 1. transforms 34

Rotation example (contd.) Steps Makes given axis pass through origin Makes axis lie in ZX plane Makes axis coincide with the Z axis Applies given rotation Apply inverses of aligning transformations 35

Rotation About Arbitrary Axis Initial Position Translate P1 to Origin Rotate about X Rotate about Y Rotate about Z 36

Alternative solution Quaternion (10 min reading) what is? basic operations and how to perform rotation reference: http://www.cs.ucr.edu/~vbz/resources/ quatut.pdf

Transformations in OpenGL Model-view matrix Projection matrix Texture matrix

Programming Transformations In OpenGL, the transformation matrices are part of the state, they must be defined prior to any vertices to which they are to apply. In modeling, we often have objects specified in their own coordinate systems and must use transformations to bring the objects into the scene. OpenGL provides matrix stacks for each type of supported matrix (model-view, projection, texture) to store matrices.

Current Transformation Matrix Current Transformation Matrix (CTM) Is the matrix that is applied to any vertex that is defined subsequent to its setting. If we change the CTM, we change the state of the system. CTM is a 4 x 4 matrix that can be altered by a set of functions.

Changing CTM Specify CTM mode : glmatrixmode (mode); mode = (GL_MODELVIEW GL_PROJECTION GL_TEXTURE ) Load CTM : glloadidentity ( void ); glloadmatrix{fd} ( *m ); m = 1D array of 16 elements arranged by the columns Multiply CTM : glmultmatrix{fd} ( *m ); Modify CTM : (multiplies CTM with appropriate transformation matrix) gltranslate {fd} ( x, y, z); glscale {fd} ( x, y, z); glrotate {fd} ( angle, x, y, z); rotate counterclockwise around ray (0,0,0) to (x, y, z)

Rotation About an Arbitrary Point Task: Rotate an object by 45.0 degrees about the line from (4.0, 5.0, 6.0) to (5.0, 7.0, 9.0). (T -p1, R 45, T +p1 ) glmatrixmode (GL_MODEVIEW); glloadidentity (); gltranslatef (4.0, 5.0, 6.0); glrotatef (45.0, 1.0, 2.0, 3.0); gltranslatef (-4.0, -5.0, -6.0);

Order of Transformations The transformation matrices appear in reverse order to that in which the transformations are applied. In OpenGL, the transformation specified most recently is the one applied first.

Matrix Stacks OpenGL uses matrix stacks mechanism to manage modeling transformation hierarchy. glpushmatrix ( void ); glpopmatrix ( void ); OpenGL provides matrix stacks for each type of supported matrix to store matrices. Model-view matrix stack Projection matrix stack Texture matrix stack

Example of Modeling Transform hierarchy Table Table Top Base Frame 4 legs stiffener NSbars EWbars Leg-1 Leg-2 Leg-3 Leg-4 N S E W

Ex Desk with 4 legs By calling glutsolidcube()

Hierarchal transformations

Thank You