SlideShare a Scribd company logo
1 of 25
Download to read offline
2D transformations and
homogeneous coordinates
Contents
• Transformations in 2D:
– vector/matrix notation
– example: translation, scaling, rotation
• Homogeneous coordinates:
– consistent notation
– several other good points (later)
• Composition of transformations
• Transformations for the window system
Transformations in 2D
• In the application model:
– a 2D description of an object (vertices)
– a transformation to apply
• Each vertex is modified:
• x’ = f(x,y)
• y’ = g(x,y)
• Express the modification
Translations
• Each vertex is modified:
• x’ = x+tx
• y’ = y+ty
Before After
A (3,6)
A’(5,3)
Translations: vector notation
• Use vector for the notation:
– makes thingssimpler
• A point is avector:
• A translation is merely a vector sum:
A’ = A + T (2,-3)
x
y
Scaling in 2D
• Coordinates multiplied by the scaling
factor:
• x’ = sx x
• y’ = sy y
Before After
Scaling in 2D, matrix notation
• Scaling is a matrix multiplication:
P’ = SP
x
y
sx 0
0 sy
x
y
Rotating in 2D
• New coordinates depend on bothx and y
• x’ = cos x - sin y
• y’ = sin x + cos y
Before After
Rotating in 2D, matrix notation
• A rotation is a matrix multiplication:
P’=RP
x
y
cos
sin
sin x
cos y
2D transformations, summary
• Vector-matrix notation simplifies writing:
– translation is a vector sum
– rotation and scaling are matrix-vector
multiplication
• A consistent notation:
– that expresses all three identically
– that expresses combination of these also
identically
• How to do this?
Homogeneous coordinates
• Introduced in mathematics:
– for projections and drawings
– used in artillery, architecture
– used to be classified material (in the 1850s)
• Add a third coordinate, w
• A 2D point is a 3coordinates vector:
x
y
w
Homogeneous coordinates (cont’d)
• Two points are equal if and only if:
x’/w’ = x/w and y’/w’= y/w
• w=0: points at infinity
– useful for projections and curve drawing
• Homogenize = divide by w.
• Homogenized points: x
y
1
Translations with homogeneous
x
y
w
y
1 0 tx x
0 1 t y
0 0 1 w
x. x wtx
y. y wty
w w
x
w
y
w
x
w
y
w
tx
ty
Scaling with homogeneous
x
y
w
y
sx 0 0 x
0 s 0 y
0 0 1 w
x. sxx
y. syy
w w
x
w
y
w
x
x w
s
s y
y w
Rotation with homogeneous
x
y
w
cos
sin
0
sin 0 x
cos 0 y
0 1 w
x cos x sin y y sin
x cos y w w
x
w
y
w
cos
sin
x
w
x
w
sin
cos
y
w
y
w
Composition of transformations
• To compose transformations, multiply
the matrices:
– composition of a rotation and a translation:
M = RT
• all transformations can be expressed as
matrices
– even transformations that are not
translations, rotations and scaling
Rotation around a point Q
• Rotation about a point Q:
– translate Q to origin (TQ),
– rotate about origin (R )
– translate back to Q (- TQ).
(-TQ)R TQ P
Important !
• Matrix multiplication is not commutative
• The order of the transformations is vital
– Rotation followed by translation is very different
from translation followed by rotation
– careful with the order of the matrices!
• Small commutativity:
– rotation commute with rotation, translation with
translation…
From World to Window
• Inside the application:
– application model
– coordinates related to the model
– possibly floating point
• On the screen:
– pixel coordinates
– integer
– restricted viewport: umin/umax, vmin/vmax
From Model to Viewport
xmin xmax
ymin
ymax
From Model to Viewport
• Model is (xmin,ymin)-(xmax,ymax)
• Viewport is (umin,vmin)-(umax,vmax)
• Translate by (-xmin,-ymin)
• Translate by (umin,vmin)
M =T’ST
xmax-xmin ymax-ymin
Scale by (umax-umin , vmax-vmin
)
From Model to Viewport
u x
v M y
w w
Model Coordinates
Pixel Coordinates
Mouse position: inverse problem
• Mouse click: coordinates in pixels
• We want the equivalent in World Coord
– because the user has selected an object
– to draw something
– for interaction
• How can we convert from window
coordinates to model coordinates?
• Simply inverse the matrix:
Mouse click: inverse problem
M 1
(T ST) 1
1
x u
y M v
w w
Pixels coordinates
Model Coordinates
2D transformations: conclusion
• Simple, consistent matrix notation
– using homogeneous coordinates
– all transformations expressed as matrices
• Used by the window system:
– for conversion from model to window
– for conversion from window to model
• Used by the application:
– for modeling transformations

More Related Content

Similar to 2d Transformation.pdf

GeometricTransformations.ppt
GeometricTransformations.pptGeometricTransformations.ppt
GeometricTransformations.pptDebjit Doira
 
Part 3- Manipulation and Representation of Curves.pptx
Part 3- Manipulation and Representation of Curves.pptxPart 3- Manipulation and Representation of Curves.pptx
Part 3- Manipulation and Representation of Curves.pptxKhalil Alhatab
 
Transformations in Computer Graphics
Transformations in Computer GraphicsTransformations in Computer Graphics
Transformations in Computer GraphicsJatenderKhatri
 
Part 2- Transformation.pptx
Part 2- Transformation.pptxPart 2- Transformation.pptx
Part 2- Transformation.pptxKhalil Alhatab
 
Unit-3 overview of transformations
Unit-3 overview of transformationsUnit-3 overview of transformations
Unit-3 overview of transformationsAmol Gaikwad
 
lec07_transformations.pptx
lec07_transformations.pptxlec07_transformations.pptx
lec07_transformations.pptxAneesAbbasi14
 
Computer Vision transformations
Computer Vision  transformationsComputer Vision  transformations
Computer Vision transformationsWael Badawy
 
Part 2- Geometric Transformation.pptx
Part 2- Geometric Transformation.pptxPart 2- Geometric Transformation.pptx
Part 2- Geometric Transformation.pptxKhalil Alhatab
 
Introduction to Real Time Rendering
Introduction to Real Time RenderingIntroduction to Real Time Rendering
Introduction to Real Time RenderingKoray Hagen
 
affine transformation for computer graphics
affine transformation for computer graphicsaffine transformation for computer graphics
affine transformation for computer graphicsDrSUGANYADEVIK
 
3D Transformation in Computer Graphics
3D Transformation in Computer Graphics3D Transformation in Computer Graphics
3D Transformation in Computer Graphicssabbirantor
 
2 transformation computer graphics
2 transformation computer graphics2 transformation computer graphics
2 transformation computer graphicscairo university
 
5_6221983039971394498.pptx
5_6221983039971394498.pptx5_6221983039971394498.pptx
5_6221983039971394498.pptxNachiketKadlag1
 
Geometric objects and transformations
Geometric objects and transformationsGeometric objects and transformations
Geometric objects and transformationssaad siddiqui
 
Computer graphic
Computer graphicComputer graphic
Computer graphicnusratema1
 
Kulum alin-11 jan2014
Kulum alin-11 jan2014Kulum alin-11 jan2014
Kulum alin-11 jan2014rolly purnomo
 
scan conversion of point , line and circle
scan conversion of point , line and circlescan conversion of point , line and circle
scan conversion of point , line and circleDivy Kumar Gupta
 
Computer Vision - Single View
Computer Vision - Single ViewComputer Vision - Single View
Computer Vision - Single ViewWael Badawy
 

Similar to 2d Transformation.pdf (20)

GeometricTransformations.ppt
GeometricTransformations.pptGeometricTransformations.ppt
GeometricTransformations.ppt
 
CO3303-1 Lecture 2.ppt
CO3303-1 Lecture 2.pptCO3303-1 Lecture 2.ppt
CO3303-1 Lecture 2.ppt
 
Part 3- Manipulation and Representation of Curves.pptx
Part 3- Manipulation and Representation of Curves.pptxPart 3- Manipulation and Representation of Curves.pptx
Part 3- Manipulation and Representation of Curves.pptx
 
Transformations in Computer Graphics
Transformations in Computer GraphicsTransformations in Computer Graphics
Transformations in Computer Graphics
 
Part 2- Transformation.pptx
Part 2- Transformation.pptxPart 2- Transformation.pptx
Part 2- Transformation.pptx
 
Unit-3 overview of transformations
Unit-3 overview of transformationsUnit-3 overview of transformations
Unit-3 overview of transformations
 
lec07_transformations.pptx
lec07_transformations.pptxlec07_transformations.pptx
lec07_transformations.pptx
 
Computer Vision transformations
Computer Vision  transformationsComputer Vision  transformations
Computer Vision transformations
 
Part 2- Geometric Transformation.pptx
Part 2- Geometric Transformation.pptxPart 2- Geometric Transformation.pptx
Part 2- Geometric Transformation.pptx
 
Introduction to Real Time Rendering
Introduction to Real Time RenderingIntroduction to Real Time Rendering
Introduction to Real Time Rendering
 
affine transformation for computer graphics
affine transformation for computer graphicsaffine transformation for computer graphics
affine transformation for computer graphics
 
september4.ppt
september4.pptseptember4.ppt
september4.ppt
 
3D Transformation in Computer Graphics
3D Transformation in Computer Graphics3D Transformation in Computer Graphics
3D Transformation in Computer Graphics
 
2 transformation computer graphics
2 transformation computer graphics2 transformation computer graphics
2 transformation computer graphics
 
5_6221983039971394498.pptx
5_6221983039971394498.pptx5_6221983039971394498.pptx
5_6221983039971394498.pptx
 
Geometric objects and transformations
Geometric objects and transformationsGeometric objects and transformations
Geometric objects and transformations
 
Computer graphic
Computer graphicComputer graphic
Computer graphic
 
Kulum alin-11 jan2014
Kulum alin-11 jan2014Kulum alin-11 jan2014
Kulum alin-11 jan2014
 
scan conversion of point , line and circle
scan conversion of point , line and circlescan conversion of point , line and circle
scan conversion of point , line and circle
 
Computer Vision - Single View
Computer Vision - Single ViewComputer Vision - Single View
Computer Vision - Single View
 

More from Mattupallipardhu (13)

Module 1.pptx
Module 1.pptxModule 1.pptx
Module 1.pptx
 
Image processing.pptx
Image processing.pptxImage processing.pptx
Image processing.pptx
 
Pyhton-1a-Basics.pdf
Pyhton-1a-Basics.pdfPyhton-1a-Basics.pdf
Pyhton-1a-Basics.pdf
 
Lec_2.pdf
Lec_2.pdfLec_2.pdf
Lec_2.pdf
 
Lec_10.pdf
Lec_10.pdfLec_10.pdf
Lec_10.pdf
 
Lec_4.pdf
Lec_4.pdfLec_4.pdf
Lec_4.pdf
 
2-D Transformations.pdf
2-D Transformations.pdf2-D Transformations.pdf
2-D Transformations.pdf
 
Ray Tracing.pdf
Ray Tracing.pdfRay Tracing.pdf
Ray Tracing.pdf
 
Fundamentals of Computer Graphics.pdf
Fundamentals of Computer Graphics.pdfFundamentals of Computer Graphics.pdf
Fundamentals of Computer Graphics.pdf
 
raster algorithm.pdf
raster algorithm.pdfraster algorithm.pdf
raster algorithm.pdf
 
Hidden_surfaces.pdf
Hidden_surfaces.pdfHidden_surfaces.pdf
Hidden_surfaces.pdf
 
cathoderaytube.pdf
cathoderaytube.pdfcathoderaytube.pdf
cathoderaytube.pdf
 
3. Syntax Analyzer.pptx
3. Syntax Analyzer.pptx3. Syntax Analyzer.pptx
3. Syntax Analyzer.pptx
 

Recently uploaded

Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduitsrknatarajan
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 

Recently uploaded (20)

Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 

2d Transformation.pdf

  • 2. Contents • Transformations in 2D: – vector/matrix notation – example: translation, scaling, rotation • Homogeneous coordinates: – consistent notation – several other good points (later) • Composition of transformations • Transformations for the window system
  • 3. Transformations in 2D • In the application model: – a 2D description of an object (vertices) – a transformation to apply • Each vertex is modified: • x’ = f(x,y) • y’ = g(x,y) • Express the modification
  • 4. Translations • Each vertex is modified: • x’ = x+tx • y’ = y+ty Before After A (3,6) A’(5,3)
  • 5. Translations: vector notation • Use vector for the notation: – makes thingssimpler • A point is avector: • A translation is merely a vector sum: A’ = A + T (2,-3) x y
  • 6. Scaling in 2D • Coordinates multiplied by the scaling factor: • x’ = sx x • y’ = sy y Before After
  • 7. Scaling in 2D, matrix notation • Scaling is a matrix multiplication: P’ = SP x y sx 0 0 sy x y
  • 8. Rotating in 2D • New coordinates depend on bothx and y • x’ = cos x - sin y • y’ = sin x + cos y Before After
  • 9. Rotating in 2D, matrix notation • A rotation is a matrix multiplication: P’=RP x y cos sin sin x cos y
  • 10. 2D transformations, summary • Vector-matrix notation simplifies writing: – translation is a vector sum – rotation and scaling are matrix-vector multiplication • A consistent notation: – that expresses all three identically – that expresses combination of these also identically • How to do this?
  • 11. Homogeneous coordinates • Introduced in mathematics: – for projections and drawings – used in artillery, architecture – used to be classified material (in the 1850s) • Add a third coordinate, w • A 2D point is a 3coordinates vector: x y w
  • 12. Homogeneous coordinates (cont’d) • Two points are equal if and only if: x’/w’ = x/w and y’/w’= y/w • w=0: points at infinity – useful for projections and curve drawing • Homogenize = divide by w. • Homogenized points: x y 1
  • 13. Translations with homogeneous x y w y 1 0 tx x 0 1 t y 0 0 1 w x. x wtx y. y wty w w x w y w x w y w tx ty
  • 14. Scaling with homogeneous x y w y sx 0 0 x 0 s 0 y 0 0 1 w x. sxx y. syy w w x w y w x x w s s y y w
  • 15. Rotation with homogeneous x y w cos sin 0 sin 0 x cos 0 y 0 1 w x cos x sin y y sin x cos y w w x w y w cos sin x w x w sin cos y w y w
  • 16. Composition of transformations • To compose transformations, multiply the matrices: – composition of a rotation and a translation: M = RT • all transformations can be expressed as matrices – even transformations that are not translations, rotations and scaling
  • 17. Rotation around a point Q • Rotation about a point Q: – translate Q to origin (TQ), – rotate about origin (R ) – translate back to Q (- TQ). (-TQ)R TQ P
  • 18. Important ! • Matrix multiplication is not commutative • The order of the transformations is vital – Rotation followed by translation is very different from translation followed by rotation – careful with the order of the matrices! • Small commutativity: – rotation commute with rotation, translation with translation…
  • 19. From World to Window • Inside the application: – application model – coordinates related to the model – possibly floating point • On the screen: – pixel coordinates – integer – restricted viewport: umin/umax, vmin/vmax
  • 20. From Model to Viewport xmin xmax ymin ymax
  • 21. From Model to Viewport • Model is (xmin,ymin)-(xmax,ymax) • Viewport is (umin,vmin)-(umax,vmax) • Translate by (-xmin,-ymin) • Translate by (umin,vmin) M =T’ST xmax-xmin ymax-ymin Scale by (umax-umin , vmax-vmin )
  • 22. From Model to Viewport u x v M y w w Model Coordinates Pixel Coordinates
  • 23. Mouse position: inverse problem • Mouse click: coordinates in pixels • We want the equivalent in World Coord – because the user has selected an object – to draw something – for interaction • How can we convert from window coordinates to model coordinates?
  • 24. • Simply inverse the matrix: Mouse click: inverse problem M 1 (T ST) 1 1 x u y M v w w Pixels coordinates Model Coordinates
  • 25. 2D transformations: conclusion • Simple, consistent matrix notation – using homogeneous coordinates – all transformations expressed as matrices • Used by the window system: – for conversion from model to window – for conversion from window to model • Used by the application: – for modeling transformations