2D transformations like translation, scaling, rotation.

© All Rights Reserved

11 views

2D transformations like translation, scaling, rotation.

© All Rights Reserved

- Opengl Project
- ComputerGraphics_3D_Part1
- Computer Graphics
- Computer Graphics Question BankNew
- historyofmatricesproject
- Assignment Bca 193
- SAFEv12 Features
- SketchUp 7 Help
- Chapter 3 Dynamics
- 18309_3d..trans...
- GMAT Quant Topic 1 (General Arithmetic) Solutions
- Cutviewer Turn User Guide V3
- Cg Lab Manual
- chem win
- GiD Reference Manual
- 2018 Design Trends Guide by Milo on Behance
- Guide Pathfinder
- Clanak Piloti Cimbola Soldo
- ru,6
- Pure Pass) Syllabus

You are on page 1of 32

2D Transformations

CMPT 361

Introduction to Computer Graphics

Torsten Mller

Machiraju/Zhang/Mller

2

Graphics Pipeline

Hardware

Modelling Transform Visibility

Illumination +

Shading

Color

Perception,

Interaction

Texture/

Realism

Machiraju/Zhang/Mller

3

Reading

Chapter 3 of Angel

Chapter 5 of Foley, van Dam,

Machiraju/Zhang/Mller

4

Schedule

Geometry basics

Afne transformations

Use of homogeneous coordinates

Concatenation of transformations

3D transformations

Transformation of coordinate systems

Transform the transforms

Transformations in OpenGL

Machiraju/Zhang/Mller

5

Basic transformations

The most basic ones

Translation

Scaling

Rotation

Shear

And others, e.g., perspective transform, projection, etc.

Basic types of transformations

Rigid-body: preserves length and angle

Afne: preserves parallel lines, not angles or lengths

Free-form: anything goes

Machiraju/Zhang/Mller

6

Translation in 2D

P

= P +T

x

= x +d

x

y

= y +d

y

x

y

d

x

d

y

Machiraju/Zhang/Mller

7

Scaling in 2D

s

x

0

0 s

y

x

y

= S P

x

= s

x

x

y

= s

y

y

Uniform s

x

= s

y

Non-uniform s

x

= s

y

Machiraju/Zhang/Mller

Positive angles:

counterclockwise

For negative angles

8

Rotation about origin

P

= R P

x

= xcos() y sin()

y

= xsin() + y cos()

cos() = cos()

sin() = sin()

cos() sin()

sin() cos()

x

y

Machiraju/Zhang/Mller

Make use of polar coordinates:

9

Derivation of rotation matrix

x = r cos()

y = r sin()

x = r cos( +)

y = r sin( +)

x

= r cos( +)

= r cos() cos() r sin() sin()

= xcos() y sin()

y

= r sin( +)

= r sin() cos() + r cos() sin()

= y cos() + xsin()

(r, ) (x, y)

(r, ) (x, y)

Machiraju/Zhang/Mller

10

Shearing in 2D

P

= SH

y

P

P

= SH

x

P

1 a

0 1

x

y

1 0

b 1

x

y

= x +ay

y

= y

Machiraju/Zhang/Mller

11

Schedule

Geometry basics

Afne transformations

Use of homogeneous coordinates

Concatenation of transformations

3D transformations

Transformation of coordinate systems

Transform the transforms

Transformations in OpenGL

Machiraju/Zhang/Mller

12

Homogeneous coordinates

Only translation cannot be expressed as

matrix-vector multiplications

But we can add a third coordinate

Homogeneous coordinates for 2D points

(x, y) turns into (x, y, W)

if (x, y, W) and (x', y', W ) are multiples of one

another, they represent the same point

typically, W ! 0.

points with W = 0 are points at innity

Machiraju/Zhang/Mller

13

2D Homogeneous Coordinates

Cartesian coordinates of the homogenous point

(x, y, W): x/W, y/W (divide through by W)

Our typical homogenized points: (x, y, 1)

Connection to 3D?

(x, y, 1) represents a 3D

point on the plane W = 1

A homogeneous point is a

line in 3D, through the origin

Machiraju/Zhang/Mller

14

Transformation in

homogeneous coordinates

General form of afne (linear) transformation

E.g., 2D translation in

homogeneous coordinates

Machiraju/Zhang/Mller

2D line equation

Duality of 3D points to a line

3D plane equation:

Duality of 4D points to a plane

Homog. Coords in 1D?

15

Homogeneous Coords (3)

ax + by + cx + d = 0

a b c d

x

y

z

1

= 0

ax + by + c = 0

a b c

x

y

1

= 0

Machiraju/Zhang/Mller

16

Basic 2D transformations

Machiraju/Zhang/Mller

17

Inverse of transformations

Inverse of T(d

x

, d

y

) = T("d

x

, "d

y

)

R(#)

!1

= R("#)

S(s

x

, s

y

)

!1

= S(1/s

x

, 1/s

y

)

Sh(a

x

)

!1

= Sh("a

x

)

T("d

x

, "d

y

) = T(d

x

, d

y

)

!1

Machiraju/Zhang/Mller

18

Schedule

Geometry basics

Afne transformations

Use of homogeneous coordinates

Concatenation of transformations

3D transformations

Transformation of coordinate systems

Transform the transforms

Transformations in OpenGL

Machiraju/Zhang/Mller

19

Compound transformations

Often we need many transforms to build

objects (or to direct them)

e.g., rotation about an arbitrary point/line?

Concatenate basic transforms sequentially

This corresponds to multiplication of the

transform matrices, thanks to homogeneous

coordinates

Machiraju/Zhang/Mller

20

Compound translation

What happens when a point goes through

T(d

x1

, d

y1

) and then T(d

x2

, d

y2

)?

x1

+d

x2

, d

y1

+d

y2

)

Concatenation of transformations: matrix multiplication

1 0 d

x

2

0 1 d

y

2

0 0 1

1 0 d

x

1

0 1 d

y

1

0 0 1

1 0 d

x

1

+ d

x

2

0 1 d

y

1

+ d

y

2

0 0 1

Machiraju/Zhang/Mller

21

Compound rotation

What happens when a point goes through

R(#) and then R($)?

Combined rotation: R(# + $)

Scaling or shearing (in one direction) is similar

These concatenations are commutative

Machiraju/Zhang/Mller

22

Commutativity

Transformations that do commute:

Translate translate

Rotate rotate (around the same axis)

Scale scale

Uniform scale rotate

Shear in x (y) shear in x (y), etc.

In general, the order in which transformations

are composed is important

After all, matrix multiplications are not

commutative

Machiraju/Zhang/Mller

23

Commutativity

the order in which we compose matrices is

important: matrix multiplication does not

commute

x

y

z

x

y

z

x

y

z

x

y

z

x

y

z

X then Z

Z then X

Machiraju/Zhang/Mller

24

Rotation about an

arbitrary point

Break it down into easier problems:

Translate to the origin: T("x

1

, "y

1

)

Rotate: R(q)

And translate back: T(x

1

, y

1

)

Machiraju/Zhang/Mller

25

Rotation about an

arbitrary point

Compound transformation (non-commutative):

T(x

1

, y

1

) R(q) T(" x

1

, " y

1

)

P = T(x

1

, y

1

)R(q)T(" x

1

, " y

1

)P = AP

Why combine these matrices into a single A?

Machiraju/Zhang/Mller

26

Another example

Compound transformation:

T(x

2

, y

2

) R(90

o

) S(s

x

, s

y

) T("x

1

, "y

1

)

Machiraju/Zhang/Mller

27

Rigid-body transformation

A transformation matrix

where the upper 2 % 2 submatrix is

orthonormal, preserves angles and lengths

called rigid-body transformation

any sequence of translation and rotation give a

rigid-body transformation

Machiraju/Zhang/Mller

28

Afne transformation

Preserves parallelism, not lengths or angles

Product of a sequence of translation, scaling,

rotation, and shear is afne

Unit cube Rot("45

o

) Scale in x

Machiraju/Zhang/Mller

29

Types of Transforms

Continuous/Discrete, one to one ; invertible

Classication

Euclidean (preserves angles)

translation, rotation, uniform scale

Afne (preserves parallel lines)

Euclidean plus non-uniform scale, shearing

Projective (preserves lines)

Isometry (preserves distance)

Reection, rigid body motion

Nonlinear (lines become curves)

Twists, Bends, warps, morphs

Machiraju/Zhang/Mller

30

Window-To-Viewport

Transformation

Important example of compound transform

World coords: space users work in

need to map world to the screen

window in world-coordinate space and

viewport in screen coordinate space

Machiraju/Zhang/Mller

one can specify non-uniform scaling

results in distorted images

What property of window and viewport

indicates whether the mapping will distort the

images?

31

Window-To-Viewport

Transformation (2)

Machiraju/Zhang/Mller

32

Window-To-Viewport

Transformation (3)

Specify transform in matrix form

M

wv

= T

u

min

v

min

u

max

u

min

x

max

x

min

v

max

v

min

y

max

y

min

x

min

y

min

- Opengl ProjectUploaded bypavan146_s8089
- ComputerGraphics_3D_Part1Uploaded byapi-3799599
- Computer GraphicsUploaded byUnaise Ek
- Computer Graphics Question BankNewUploaded byvishaljain2639
- historyofmatricesprojectUploaded byapi-239316362
- Assignment Bca 193Uploaded bydolon10
- SAFEv12 FeaturesUploaded byJaime Suárez
- SketchUp 7 HelpUploaded byBao Hoang Nguyen
- Chapter 3 DynamicsUploaded byDaniyal Hassan
- GMAT Quant Topic 1 (General Arithmetic) SolutionsUploaded bymeashish25
- Cutviewer Turn User Guide V3Uploaded byLawrence Adu-Gyamfi
- Cg Lab ManualUploaded byPurush Thaman
- 18309_3d..trans...Uploaded byMAyankBIsht
- chem winUploaded byAda Topan
- GiD Reference ManualUploaded byAlrack sinner
- 2018 Design Trends Guide by Milo on BehanceUploaded byElga Septia Savista
- Guide PathfinderUploaded byRicardo Mendaro
- Clanak Piloti Cimbola SoldoUploaded byAmanda Mathis
- ru,6Uploaded byNearLin
- Pure Pass) SyllabusUploaded byarinmath
- PMD Topic 2 Fundamentals of ErrorsUploaded byLuis Angel Martinez Soto
- 15 462 Fall03 WrAssign1 AnswerUploaded byBayu Yudha Pratama
- Introduction to AcousticsUploaded byncharala
- Phy416G-HWSol6.pdfUploaded byDavidSuarez
- ProsUploaded byNauman Siddiqui
- 11 Maths Impq 12 Introduction to Three Dimensional Coordinate GeometryUploaded byAnkit Tiwari
- real grade 6 arfirst week of lesson plansUploaded byapi-273179753
- Dynamics FemUploaded byAlicia Hambure
- Dynamic Parameter Identification of a 6 DOF Industrial Robot Using Power ModelUploaded bycegceg85
- fplrp87Uploaded byPavao Gos

- fuzzy and nural approaches in engineering matlab supplimentUploaded byKirtesh Tiwari
- System CallsUploaded byIAGPLS
- Opengl PrgUploaded byIAGPLS
- CreatUploaded byIAGPLS
- VotUploaded byIAGPLS
- Mod 14_LNUploaded bymanixjain
- Introduction to UNIXUploaded byIAGPLS
- Ch02Uploaded byIAGPLS
- Introduction to SilambamUploaded byIAGPLS
- OPen Gl SetupUploaded byIAGPLS
- The Cellular ConceptUploaded byazlan30
- Bresenhams AlgorithmUploaded byIAGPLS
- ECE632 Mobile CommunicationUploaded byUsama Latif
- C 05 Wireless Standards EnUploaded byIAGPLS
- Chapter 1 Wireless 09Uploaded byIAGPLS
- Svdsum2(Project Paper)Uploaded byIAGPLS
- Phase1 Project ReportUploaded byIAGPLS
- GSM Industrial ReportUploaded byIAGPLS
- Broadband DLCUploaded byIAGPLS

- Cpuz ReadmeUploaded byalusius
- 25 Calorie Savings Tips by kevin zahriUploaded byMohanesh
- The Linguistic Legacy of Spanish and PortugueseUploaded bytacarvalho
- MR-1Uploaded byabeid khamis
- ECM370Uploaded byadrian monter lugo
- The Self in the MirrorUploaded byadusumalliramani
- Gioda Sakurai 1987Uploaded byBhaskar Reddy
- Pse Ud Epigraph AUploaded byAbda Yasharahla
- TEST Science 1st With TOSUploaded byJaja Carlina
- Reservoir Rock and Fluid PropertiesUploaded byRahul Marathe
- Arcanum Manual (Complete)Uploaded byTravis
- Lab_Num.pdfUploaded byNavjot Wadhwa
- 101 Plant Care Tips for Your Interior Plants CapeUploaded byguywire62
- Eng.romanusUploaded byEmmanuel
- crestron st-1550cUploaded byJay Langdon
- BIOL 112 Lab ReportUploaded byessexchick13
- 1914_buckinghamUploaded byFelipe Venegas Guzman
- TIL 1719Uploaded byfrangarcia1979
- Tri Calcium Phosphate FsUploaded bydrg. Rifqie Al Haris
- Maxxis 2011 Bike CatalogUploaded byMatej Charvat
- Failure+Modes+Effect+AnalysisUploaded byAkhmas Meraj
- Interest rate futuresUploaded byShivanshuBelongsToYou
- Vol. Xxv No. 9 03 March 2010Uploaded byCohen
- Process Control and HazopUploaded byCosmin Florea
- DLA-TAUploaded byphoenix8612005
- marine hydrodynamicsUploaded byAnu Parameswaran
- EvaporationUploaded bykmrosario
- Ibm Sap BarcelonaUploaded bypipocaazul
- IntroductionUploaded byhidayathsmf
- Beginners ESL: Star Wars readingUploaded bymelissa_cassidy