What and Why Transformations?

Similar documents
Two Dimensional Viewing

4. Two Dimensional Transformations

Computer Graphics. Geometric Transformations

Computer Graphics. Geometric Transformations

Modeling Transformations

UNIT 2 2D TRANSFORMATIONS

2D Transformations. 7 February 2017 Week 5-2D Transformations 1

Today s class. Geometric objects and transformations. Informationsteknologi. Wednesday, November 7, 2007 Computer Graphics - Class 5 1

CS F-07 Objects in 2D 1

1. We ll look at: Types of geometrical transformation. Vector and matrix representations

Modeling Transformations

GLOBAL EDITION. Interactive Computer Graphics. A Top-Down Approach with WebGL SEVENTH EDITION. Edward Angel Dave Shreiner

CS559: Computer Graphics

Motivation. What we ve seen so far. Demo (Projection Tutorial) Outline. Projections. Foundations of Computer Graphics

CSE328 Fundamentals of Computer Graphics: Theory, Algorithms, and Applications

Modeling Transformations Revisited

To Do. Demo (Projection Tutorial) Motivation. What we ve seen so far. Outline. Foundations of Computer Graphics (Fall 2012) CS 184, Lecture 5: Viewing

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

CS770/870 Spring 2017 Transformations

Transformations using matrices

To Do. Motivation. Demo (Projection Tutorial) What we ve seen so far. Computer Graphics. Summary: The Whole Viewing Pipeline

Editing and Transformation

STRAND I: Geometry and Trigonometry. UNIT 37 Further Transformations: Student Text Contents. Section Reflections. 37.

Determining the 2d transformation that brings one image into alignment (registers it) with another. And

Image Warping : Computational Photography Alexei Efros, CMU, Fall Some slides from Steve Seitz

Computer Graphics. P04 Transformations. Aleksandra Pizurica Ghent University

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

Unit 3 Transformations and Clipping

3D Geometry and Camera Calibration

3-Dimensional Viewing

Image Warping. Some slides from Steve Seitz

2D and 3D Transformations AUI Course Denbigh Starkey

MEM380 Applied Autonomous Robots Winter Robot Kinematics

CS 450: COMPUTER GRAPHICS 2D TRANSFORMATIONS SPRING 2016 DR. MICHAEL J. REALE

Transformations II. Week 2, Wed Jan 17

CS Computer Graphics: Transformations & The Synthetic Camera

CSE528 Computer Graphics: Theory, Algorithms, and Applications

CS 2770: Intro to Computer Vision. Multiple Views. Prof. Adriana Kovashka University of Pittsburgh March 14, 2017

Homogeneous Coordinates

Image warping. image filtering: change range of image. image warping: change domain of image g(x) = f(h(x)) h(y)=0.5y+0.5. h([x,y])=[x,y/2] f h

Image Warping (Szeliski Sec 2.1.2)

20 Calculus and Structures

Chap 7, 2009 Spring Yeong Gil Shin

Lecture 4: Transforms. Computer Graphics CMU /15-662, Fall 2016

Scene Graphs & Modeling Transformations COS 426

Translations, Reflections, and Rotations

Think About. Unit 5 Lesson 3. Investigation. This Situation. Name: a Where do you think the origin of a coordinate system was placed in creating this

[ ] [ ] Orthogonal Transformation of Cartesian Coordinates in 2D & 3D. φ = cos 1 1/ φ = tan 1 [ 2 /1]

Glossary alternate interior angles absolute value function Example alternate exterior angles Example angle of rotation Example

Image Warping. Some slides from Steve Seitz

2D Geometric Transformations and Matrices

CMSC 425: Lecture 10 Basics of Skeletal Animation and Kinematics

Isometry: When the preimage and image are congruent. It is a motion that preserves the size and shape of the image as it is transformed.

Image Metamorphosis By Affine Transformations

Introduction to Homogeneous Transformations & Robot Kinematics

Graphics Output Primitives

Geometric Model of Camera

Uses of Transformations. 2D transformations Homogeneous coordinates. Transformations. Transformations. Transformations. Transformations and matrices

Reteaching Golden Ratio

Plot and connect the points in a coordinate plane to make a polygon. Name the polygon.

The 3-D Graphics Rendering Pipeline

Unit 5 Lesson 2 Investigation 1

IMGD The Game Development Process: 3D Modeling and Transformations

Therefore, after becoming familiar with the Matrix Method, you will be able to solve a system of two linear equations in four different ways.

STRAND J: TRANSFORMATIONS, VECTORS and MATRICES

Computer Graphics Hands-on

Modeling Transformations

Part 3: 2D Transformation

Module 2, Section 2 Graphs of Trigonometric Functions

Geometric Transformations

Half Turns and Quarter Turns Rotations of Figures on the Coordinate Plane

Transformations II. Arbitrary 3D Rotation. What is its inverse? What is its transpose? Can we constructively elucidate this relationship?

MODULE - 7. Subject: Computer Science. Module: Other 2D Transformations. Module No: CS/CGV/7

9. f(x) = x f(x) = x g(x) = 2x g(x) = 5 2x. 13. h(x) = 1 3x. 14. h(x) = 2x f(x) = x x. 16.

Computer Graphics. Si Lu. Fall er_graphics.htm 10/11/2017

Perspective Projection Transformation

GRAPHICS OUTPUT PRIMITIVES


Name Date. using the vector 1, 4. Graph ABC. and its image. + to find the image

Lecture 4: Viewing. Topics:

Introduction to Homogeneous Transformations & Robot Kinematics

CS770/870 Spring 2017 Transformations

Modeling Transformations

1.1 Horizontal & Vertical Translations

3.1 Sequences of Transformations

Answers to practice questions for Midterm 1

Transformations. Examples of transformations: shear. scaling

Lines and Their Slopes

Chapter 9 Transformations

Matrix Transformations. Affine Transformations

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI

High Dimensional Rendering in OpenGL

What does OpenGL do?

Image Warping CSE399b, Spring 07 Computer Vision

To Do. Computer Graphics (Fall 2004) Course Outline. Course Outline. Motivation. Motivation

Computer Graphics: Geometric Transformations

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

To Do. Course Outline. Course Outline. Goals. Motivation. Foundations of Computer Graphics (Fall 2012) CS 184, Lecture 3: Transformations 1

Modeling Transformations

Double Integrals in Polar Coordinates

Transcription:

2D transformations

What and Wh Transformations? What? : The geometrical changes of an object from a current state to modified state. Changing an object s position (translation), orientation (rotation) or size (scaling) Others transformations: reflection and shearing operations Wh? To manipulate the initiall created object and to displa the modified object without having to redraw it.

Matrices Matri is a two Dimensional arra of numbers. Elements of the matri are identified b its row and column pair. 5 5 6 Matri multiplication: Matri multiplication is associative. Means if we have multiple matrices to multipl then, it does not matter which matri we multipl first. A(BC) = (AB)C 2/27/24 3

In CG images are made up of series of line segments. Each line segment is then represented b its end coordinates. We can make changes in the image b performing some mathematical operations on these co-or. The changes made in a image are called transformations. 2/27/24 4

Basic Transformations :. Scaling 2

Scaling X 2, Y.5

Scaling Scaling changes the size of an object and involves two scale factors, S and S for the - and - coordinates respectivel. Scales are about the origin. We can write the components: p' = s p p' = s p or in matri form: P' = S P Scale matri as: s S s P P

If the scale factors are in between and the points will be moved closer to the origin the object will be smaller. P Eample : P(2, 5), S =.5, S =.5 Find P? If the scale factors are larger than the points will be moved awa from the origin the object will be larger. P P(2, 5) Eample : P(2, 5), S = 2, S = 2 Find P?

P If the scale factors are the same, S = S uniform scaling Onl change in size (as previous eample) If S S differential scaling. Change in size and shape Eample : square rectangle P(, 3), S = 2, S = 5, P? P(, 2)

Matri It is possible to represent this scaling in terms of the matri. S= S S Therefore P = P. S

Thus: Scaling is used to alter the size of an object Simple 2D scaling is performed b multipling object positions (, ) b scaling factors s and s = s = s or P = S P = S S

Points @ 2D Scaling An positive value can be used as scaling factor Values less than reduce the size of the object Values greater than enlarge the object If scaling factor is then the object stas unchanged If s = s, we call it uniform scaling If scaling factor <, then the object moves closer to the origin and If scaling factor >, then the object moves farther from the origin

Translation A translation moves all points in an object along the same straight-line path to new positions. The path is represented b a vector, called the translation or shift vector. We can write the components:? t =4 p' = p + t p' = p + t or in matri form: P' = P + T = + t t (2, 2) t = 6

2. Translation Translation changes the position of an object. P = point before translation P = point after translation Let point P(,) P (, ) = + t, = + t T P P Translation moves the object without deformation How can we write this in matri form?

Some points @ translation 2D Translation To move a line segment, appl the transformation equation to each of the two line endpoints and redraw the line between new endpoints To move a polgon, appl the transformation equation to coordinates of each verte and regenerate the polgon using the new set of verte coordinates

Rotation A rotation repositions all points in an object along a circular path in the plane centered at the pivot point. P First, we ll assume the pivot is at the origin. P

Rotation Review Trigonometr => cos = /r, sin = /r = r. cos, = r.sin P (, ) => cos (+ ) = /r = r. cos (+ ) = r.coscos -r.sinsin =.cos.sin r P(,) =>sin (+ ) = /r = r. sin (+ ) = r.cossin + r.sincos r =.sin +.cos Identit of Trigonometr

Rotation We can write the components: p' = p cos p sin p' = p sin + p cos P (, ) or in matri form: P' = R P can be clockwise (-ve) or counterclockwise (+ve as our eample). Rotation matri r P(,) R cos sin sin cos

Eample Find the transformed point, P, caused b rotating P= (5, ) about the origin through an angle of 9. Rotation cos sin sin cos cos sin sin cos cos9 sin 9 5 sin 9 cos9 5 5 5 5

Matri Representations and Homogeneous Coordinates Man graphics applications involve sequences of geometric transformations Animations Design and picture construction applications We will now consider matri representations of these operations Sequences of transformations can be efficientl processed using matrices

Matri Representations and Homogeneous Coordinates P = M P + M 2 P and P are row matrices M is a 2 b 2 arra containing scaling factors M 2 is a 2 element row matri containing translational terms

Matri Representations and Homogeneous Coordinates To produce a sequence of operations, such as scaling followed b rotation then translation, we could calculate the transformed coordinates one step at a time A more efficient approach is to combine transformations, without calculating intermediate coordinate values

Matri Representations and Homogeneous Coordinates Multiplicative and translational terms for a 2D geometric transformation can be combined into a single matri if we epand the representations to 3 b 3 matrices. We can use the third column for translation terms, and all transformation equations can be epressed as matri multiplications

Homogenous Coordinates w Let s move our problem into 3D. Let point (, ) in 2D be represented b point (,, ) in the new space. Scaling our new point b an value a puts us somewhere along a particular line: (a, a, a). A point in 2D can be represented in man was in the new space. (2, 4) ---------- (8, 6, 4) or (6, 2, 3) or (2, 4, ) or etc.

Homogenous Coordinates We can alwas map back to the original 2D point b dividing b the last coordinate (5, 6, 3) --- (5, 2). (6, 4, ) -?. Wh do we use for the last coordinate? The fact that all the points along each line can be mapped back to the same point in 2D gives this coordinate sstem its name homogeneous coordinates.

Matri Representations and Homogeneous Coordinates Thus 2D Translation Matri is as follows: = t t

Thus 2D Rotation Matri becomes as : = cos sin sin cos Note : Positive values of the rotation angle define the counterclockwise rotation about the rotation point and negative values rotate objects in the clockwise sense.

Thus 2D Scaling Matri becomes as : = s s

Inverse Transformations When we appl an transformation to point(,) we get a new point (, ). Some times we need to get original coordinate from the transformed point. This can be achieved b inverse transformation. 2D Inverse Translation Matri T t t

Inverse Transformations 2D Inverse Rotation Matri Rotation in clockwise direction making Փ negative i.e cos(-θ)=cos θ sin(-θ)=-sin θ Matri becomes: 2D Inverse Scaling Matri cos sin sin cos R s s S

2D Composite Transformations We can setup a sequence of transformations as a composite transformation matri b calculating the product of the individual transformations P =M 2 M P P =M P

ROTATION ABOUT AN ARBITRARY POINT

2D Composite Transformations General 2D Pivot-Point Rotation Translate Rotate Retranslate cos sin sin cos r r r r

Eample Perform a clockwise rotation of 45 a triangle A(,) B(,) and C(5,2) (Dec-25,29, Marks) about a point (-,-) About origin Answer : about origin A = (,) B =( 2,) C =((7/ 2),(-3/ 2)) E2: consider a square p(,) Q(,) R(,) S(,). Rotate the Sq about fied point R(,) b an angle 45 o (anticlockwise) followed b scaling b 2 units in X direction and 2 units in Y direction. (Dec 26, 8 marks)

Prove that two scaling transformations commute that is S S2=S2 S Show that transformation matri for a reflection about a line Y=X is equivalent to reflection to X-ais followed b counterclockwise rotation of 9 (Dec 28 8 marks) Perform X-shear and Y-shear on a triangle having A(2,) B(4,3) C(2,3). Consider the constant value b=c=2 (Dec 28, 8 marks) Answer : A = 4,5 B =, C = 8,7

Scaling with respect to an arbitrar point. Translation 2. Scaling 3. Retranslation Pictoriall shown on net slide.

f f f f s s

Other Two Dimensional Transformations Reflection Transformation that produces a mirror image of an object

Reflection: -ais -ais

Reflection: origin line =

Shear Transformations Shear Transformation that distorts the shape of an object such that the transformed shape appears as the object was composed of internal laers that had been caused to slide over each other (,) (,) (2,) (3,) (,) (,) (,) (,) sh =2

X-Shear An -direction shear relative to the ais An -direction shear relative to the ais sh sh sh ' '

Transformations in 3D

Some graphics applications are 2D such as charts,graphs, maps etc. But to create realistic picture, we need to represent picture in 3D. In 3D, geometr we need additional, third ais z-ais to specif the depth value of the object. Let us see the coordinate sstems used in 3D graphics

Lets plot a point in 3D with coordinates (3,4,2) Y-ais h e i g h t Depth. first plot the point at(3,,2) it is on the plane X-Z 2. then lift the point up b 4 units. X-ais Z-ais width

Translation in 3D! Remembering 2D transformations -> 33 matrices, take a wild guess what happens to 3D transformations. 3D means z-ais comes into picture. Giving Depth information for an object.,,, z z z t t t t t t z t t t T t t t t t t T T=(t, t, t z )

Scale, 3D Stle S=(s, s, s z ) z s z s s z * * * ' * * ),, ( p p s s s P P s s s S z z

3D Rotation In 3D we have to specif the ais of rotation along with the rotation angle. Positive rotation angles produce counterclockwise rotations about a coordinate ais, assuming that we are looking in the negative direction along that coordinate ais

3D Rotation z-ais rotation = cos θ - sin θ = sin θ + cos θ z =z z = z cos sin sin cos or, P = R z (θ) P

When we sa that we want to rotate a point in anticlockwise direction about z-ais, it is ver similar to performing a 2D rotation in anticlockwise direction as follows: Fig:2D Rotation Fig: 3D Rotation

3D Rotation z-ais rotation = cos θ - sin θ = sin θ + cos θ z =z Transformation equations for rotation abt the other aes can be obtained with a cclic permutation of coordinate parameters,, and z. That is we use the replacements: z -ais rotation = cos θ - z sin θ z = sin θ + z cos θ = -ais rotation z =z cos θ - sin θ =z sin θ + cos θ

Matrices for anticlockwise 3D rotation cos sin sin cos R cos sin sin cos R cos sin sin cos Rz

3D Rotation about an arbitrar ais General Three-Dimensional Rotations Special case where an object is to be rotated about an ais that is parallel to one of the coordinate aes. Translate the object so that the rotation ais coincides with parallel coordinate ais 2. Perform the specified rotation about the ais 3. Translate the object so that the rotation ais is moved back to its original position

3D Rotation of an object about an arbitrar ais When an object is to rotated about an ais that is not parallel to one of the coordinate aes. Translate the object so that the rotation ais passes through the coordinate origin 2. Rotate the object so that the ais of rotation coincides with one of the coordinate aes 3. Perform the specified rotation about the selected coordinate ais 4. Appl inverse rotations to bring the rotation ais back to its original position 5. Appl the inverse translation to bring the rotation ais back to its original spatial position

We can determine the transformation matrices for each step. Assume that rotation ais ie arbitrar ais is defined with two points p(,,z) and p2(2,2,z2). Let us sa a point on the ais is (P,Q,R) Initial position of the ais and point is as bellow: p2 (P,Q,R) p

Step : (Translation)transformation of rotation ais so that it passes through the origin. This can be done b moving point P to the origin This repositions the rotation ais and the object as shown z T p p2 (P,Q,R)

Step2: transform the rotation ais so that it coincides the z-ais. This can be performed in two sub-steps:. a) Rotate about -ais to transform ais into z plane b) Swing rotation ais around to the z-ais using -ais rotation. a) Take projection of line segment (,,) to (P,Q,R) onto z plane as shown in fig ie (,Q,R). (,Q,R) (P,Q,R) Light source z

Step2-a Now if we rotate the rotation (arbitrar) ais @ -ais so that it lies in X-Z. In this situation its shadow will coincides the z-ais. So we are interested in angle α, so that shadow will coincides with z-ais. (,Q,R) α L (P,Q,R) length of shadow L = Q 2 +R 2 sin α = Q/L cos α = R/L Therefore the matri for rotation about -ais R (α) = R / L Q / L Q / L R / L

After performing -ais rotation the rotation ais will lie in -z plane as shown: When we perform -ais rotation -value remains unchanged as ais of rotation is in z plane so - coordinate is zero. We need to get z-value L = P 2 +Q 2 +R 2 z-coordinate will be v = (L 2 -P 2 ) P L (P,Q,R)

Step2-b Now we have to rotate the ais around -ais so that it coincides the z-ais. Let that angle be β From figure cosβ = V/L sin β = p/l P β L Therefore the transformation matri for rotation about -ais in clockwise rotation is R (β) = v / L p / L p / L v / L

step3 Rotation about z-ais b given angle ie θ ie. Rz (θ) Rz cos sin sin cos Step 4 and 5 does inverse transformations ie R -, R -,T - Therefore the final transformation matri will be the product of all matrices in sequence. RA= T. R. R.Rz. R -, R -,T -

Reflection w.r.to plane Consider a point P(,,z). The reflection of this point w.r.to plane is given b pointp (,,-z) Corresponding matri is given as: M = -