SlideShare a Scribd company logo
1 of 24
Graphics Toolkits
• Graphics toolkits typically take care of the details
of producing images from geometry
• Input:
– Where the objects are located and what they look like
– Where the camera is and how it behaves
– Parameters for controlling the rendering
• Output: Pixel data in a framebuffer
– Data can be put on the screen
– Data can be read back for processing (part of toolkit)
OpenGL
• OpenGL is an open standard graphics toolkit
– Derived from SGI’s GL toolkit
• Provides a range of functions for modelling,
rendering and manipulating the framebuffer
• Why use it? Portable, hardware supported, simple
and easy to program (really!)
• Alternatives: Direct3D, Java3D - more complex
and less well supported respectively
In the Coming Weeks…
• We will look at the math and algorithms on which
OpenGL is built
• We will look at how to access those algorithms in
OpenGL
Coordinate Systems
• The use of coordinate systems is fundamental to
computer graphics
• Coordinate systems are used to describe the
locations of points in space
• Multiple coordinate systems make graphics
algorithms easier to understand and implement
Coordinate Systems (2)
• Different coordinate systems represent the
same point in different ways
• Some operations are easier in one coordinate
system than in another
x
y
(2,3)
u
v
x
y
(1,2)
u
v
Transformations
• Transformations convert points between
coordinate systems
x
y
(2,3)
v
x
y
(1,2)
u
v
u
u=x-1
v=y-1
x=u+1
y=v+1
Transformations
(Alternate Interpretation)
• Transformations modify an object’s shape and
location in one coordinate system
x
y
(2,3)
(1,2)
x
y
x’=x-1
y’=y-1
x=x’+1
y=y’+1
2D Affine Transformations
• An affine transformation is one that can be written
in the form:




































y
x
yy
yx
xy
xx
y
yy
yx
x
xy
xx
b
b
y
x
a
a
a
a
y
x
b
y
a
x
a
y
b
y
a
x
a
x
or
Why Affine Transformations?
• Affine transformations are linear
– Transforming all the individual points on a line gives
the same set of points as transforming the endpoints and
joining them
– Interpolation is the same in either space: Find the
halfway point in one space, and transform it. Will get
the same result if the endpoints are transformed and
then find the halfway point
Composition of Affine Transforms
• Any affine transformation can be composed as a
sequence of simple transformations:
– Translation
– Scaling
– Rotation
– Shear
– Reflection
2D Translation
• Moves an object




























y
x
b
b
y
x
y
x
1
0
0
1
x
y
x
y
bx
by
2D Scaling
• Resizes an object in each dimension
x
y




























0
0
0
0
y
x
s
s
y
x
y
x
x
y
x
y
sxx
syy
2D Rotation
• Rotate counter-clockwise about the origin by an
angle 


















 









0
0
cos
sin
sin
cos
y
x
y
x




x
y
x
y

X-Axis Shear
• Shear along x axis (What is the matrix for y axis
shear?)




























0
0
1
0
1
y
x
sh
y
x x
x
y
x
y
Reflect About X Axis
• What is the matrix for reflect about Y axis?





























0
0
1
0
0
1
y
x
y
x
x x
Rotating About An Arbitrary Point
• What happens when you apply a rotation
transformation to an object that is not at the origin?
• Solution:
– Translate the center of rotation to the origin
– Rotate the object
– Translate back to the original location
Rotating About An Arbitrary Point
x
y
x
y
x
y
x
y
Scaling an Object not at the Origin
• What also happens if you apply the scaling
transformation to an object not at the origin?
• Based on the rotating about a point composition,
what should you do to resize an object about its
own center?
[6]-20 RM
Preserved Attributes
General Properties
Line Angle Distance Area
Translation Yes Yes Yes Yes
Rotation Yes Yes Yes Yes
Scaling Yes No No No
Reflection Yes Yes Yes Yes
Shear Yes No No Yes
Back to Rotation About a Pt
• Say R is the rotation matrix to apply, and p is the
point about which to rotate
• Translation to Origin:
• Rotation:
• Translate back:
• The translation component of the composite
transformation involves the rotation matrix. What
a mess!
p
x
x 


Rp
Rx
p
x
R
x
R
x 






 )
(
p
Rp
Rx
p
x
x 









[6]-22 RM
A general invertible, linear, transformation.
Affine Transformation
Transformation Matrix:
   
   
 
x a x b y c
y a x b y c
a b a b
1 1 1
2 2 2
1 2 2 1 0
( )
Homogeneous Coordinates
• Use three numbers to represent a point
• (x,y)=(wx,wy,w) for any constant w0
• Typically, (x,y) becomes (x,y,1)
• Translation can now be done with matrix
multiplication!

































1
1
0
0
1
y
x
b
a
a
b
a
a
y
x
y
yy
yx
x
xy
xx
[6]-24 RM
• Product of affine transformations is affine.
•Affine transformations preserve linearity of segments.
•Affine transformations preserve parallelism between
lines.
•Affine transformations are invertible.
Affine Transformation: Properties

More Related Content

Similar to affine transformation for computer graphics

module 3 ppt2 (1).pptx
module 3 ppt2 (1).pptxmodule 3 ppt2 (1).pptx
module 3 ppt2 (1).pptxRADHIKAB20
 
Build Your Own VR Display Course - SIGGRAPH 2017: Part 2
Build Your Own VR Display Course - SIGGRAPH 2017: Part 2Build Your Own VR Display Course - SIGGRAPH 2017: Part 2
Build Your Own VR Display Course - SIGGRAPH 2017: Part 2StanfordComputationalImaging
 
06 image features
06 image features06 image features
06 image featuresankit_ppt
 
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
 
Mesh Shape Editing
Mesh Shape EditingMesh Shape Editing
Mesh Shape Editingssuser24ddad
 
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
 
Part 2- Transformation.pptx
Part 2- Transformation.pptxPart 2- Transformation.pptx
Part 2- Transformation.pptxKhalil Alhatab
 
A mid point ellipse drawing algorithm on a hexagonal grid
A mid  point ellipse drawing algorithm on a hexagonal gridA mid  point ellipse drawing algorithm on a hexagonal grid
A mid point ellipse drawing algorithm on a hexagonal gridS M K
 
Fisheye Omnidirectional View in Autonomous Driving
Fisheye Omnidirectional View in Autonomous DrivingFisheye Omnidirectional View in Autonomous Driving
Fisheye Omnidirectional View in Autonomous DrivingYu Huang
 
Part 2- Geometric Transformation.pptx
Part 2- Geometric Transformation.pptxPart 2- Geometric Transformation.pptx
Part 2- Geometric Transformation.pptxKhalil Alhatab
 
2hjsakhvchcvj hSKchvsABJChjSVCHjhvcvdxz.pptx
2hjsakhvchcvj hSKchvsABJChjSVCHjhvcvdxz.pptx2hjsakhvchcvj hSKchvsABJChjSVCHjhvcvdxz.pptx
2hjsakhvchcvj hSKchvsABJChjSVCHjhvcvdxz.pptxHarikumar Rajasekar
 
2 transformation computer graphics
2 transformation computer graphics2 transformation computer graphics
2 transformation computer graphicscairo university
 
Geometric transformations and projections
Geometric transformations and projectionsGeometric transformations and projections
Geometric transformations and projectionsJaya Teja
 
5_Geometric_Modeling.pdf
5_Geometric_Modeling.pdf5_Geometric_Modeling.pdf
5_Geometric_Modeling.pdfKeerthanaP37
 
04 image transformations_ii
04 image transformations_ii04 image transformations_ii
04 image transformations_iiankit_ppt
 
Programming in python
Programming in pythonProgramming in python
Programming in pythonIvan Rojas
 
"Fundamentals of Monocular SLAM," a Presentation from Cadence
"Fundamentals of Monocular SLAM," a Presentation from Cadence"Fundamentals of Monocular SLAM," a Presentation from Cadence
"Fundamentals of Monocular SLAM," a Presentation from CadenceEdge AI and Vision Alliance
 

Similar to affine transformation for computer graphics (20)

module 3 ppt2 (1).pptx
module 3 ppt2 (1).pptxmodule 3 ppt2 (1).pptx
module 3 ppt2 (1).pptx
 
Build Your Own VR Display Course - SIGGRAPH 2017: Part 2
Build Your Own VR Display Course - SIGGRAPH 2017: Part 2Build Your Own VR Display Course - SIGGRAPH 2017: Part 2
Build Your Own VR Display Course - SIGGRAPH 2017: Part 2
 
06 image features
06 image features06 image features
06 image features
 
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
 
Mesh Shape Editing
Mesh Shape EditingMesh Shape Editing
Mesh Shape Editing
 
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
 
Module 4.pptx
Module 4.pptxModule 4.pptx
Module 4.pptx
 
Part 2- Transformation.pptx
Part 2- Transformation.pptxPart 2- Transformation.pptx
Part 2- Transformation.pptx
 
A mid point ellipse drawing algorithm on a hexagonal grid
A mid  point ellipse drawing algorithm on a hexagonal gridA mid  point ellipse drawing algorithm on a hexagonal grid
A mid point ellipse drawing algorithm on a hexagonal grid
 
Fisheye Omnidirectional View in Autonomous Driving
Fisheye Omnidirectional View in Autonomous DrivingFisheye Omnidirectional View in Autonomous Driving
Fisheye Omnidirectional View in Autonomous Driving
 
Part 2- Geometric Transformation.pptx
Part 2- Geometric Transformation.pptxPart 2- Geometric Transformation.pptx
Part 2- Geometric Transformation.pptx
 
Robotics - introduction to Robotics
Robotics -  introduction to Robotics  Robotics -  introduction to Robotics
Robotics - introduction to Robotics
 
2hjsakhvchcvj hSKchvsABJChjSVCHjhvcvdxz.pptx
2hjsakhvchcvj hSKchvsABJChjSVCHjhvcvdxz.pptx2hjsakhvchcvj hSKchvsABJChjSVCHjhvcvdxz.pptx
2hjsakhvchcvj hSKchvsABJChjSVCHjhvcvdxz.pptx
 
2 transformation computer graphics
2 transformation computer graphics2 transformation computer graphics
2 transformation computer graphics
 
Geometric transformations and projections
Geometric transformations and projectionsGeometric transformations and projections
Geometric transformations and projections
 
5_Geometric_Modeling.pdf
5_Geometric_Modeling.pdf5_Geometric_Modeling.pdf
5_Geometric_Modeling.pdf
 
04 image transformations_ii
04 image transformations_ii04 image transformations_ii
04 image transformations_ii
 
Programming in python
Programming in pythonProgramming in python
Programming in python
 
"Fundamentals of Monocular SLAM," a Presentation from Cadence
"Fundamentals of Monocular SLAM," a Presentation from Cadence"Fundamentals of Monocular SLAM," a Presentation from Cadence
"Fundamentals of Monocular SLAM," a Presentation from Cadence
 

Recently uploaded

(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
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
 
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
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
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
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 
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
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
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
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
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
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
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
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 

Recently uploaded (20)

(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
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...
 
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
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
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
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
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)
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
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
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
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...
 
★ 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
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
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
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 

affine transformation for computer graphics

  • 1. Graphics Toolkits • Graphics toolkits typically take care of the details of producing images from geometry • Input: – Where the objects are located and what they look like – Where the camera is and how it behaves – Parameters for controlling the rendering • Output: Pixel data in a framebuffer – Data can be put on the screen – Data can be read back for processing (part of toolkit)
  • 2. OpenGL • OpenGL is an open standard graphics toolkit – Derived from SGI’s GL toolkit • Provides a range of functions for modelling, rendering and manipulating the framebuffer • Why use it? Portable, hardware supported, simple and easy to program (really!) • Alternatives: Direct3D, Java3D - more complex and less well supported respectively
  • 3. In the Coming Weeks… • We will look at the math and algorithms on which OpenGL is built • We will look at how to access those algorithms in OpenGL
  • 4. Coordinate Systems • The use of coordinate systems is fundamental to computer graphics • Coordinate systems are used to describe the locations of points in space • Multiple coordinate systems make graphics algorithms easier to understand and implement
  • 5. Coordinate Systems (2) • Different coordinate systems represent the same point in different ways • Some operations are easier in one coordinate system than in another x y (2,3) u v x y (1,2) u v
  • 6. Transformations • Transformations convert points between coordinate systems x y (2,3) v x y (1,2) u v u u=x-1 v=y-1 x=u+1 y=v+1
  • 7. Transformations (Alternate Interpretation) • Transformations modify an object’s shape and location in one coordinate system x y (2,3) (1,2) x y x’=x-1 y’=y-1 x=x’+1 y=y’+1
  • 8. 2D Affine Transformations • An affine transformation is one that can be written in the form:                                     y x yy yx xy xx y yy yx x xy xx b b y x a a a a y x b y a x a y b y a x a x or
  • 9. Why Affine Transformations? • Affine transformations are linear – Transforming all the individual points on a line gives the same set of points as transforming the endpoints and joining them – Interpolation is the same in either space: Find the halfway point in one space, and transform it. Will get the same result if the endpoints are transformed and then find the halfway point
  • 10. Composition of Affine Transforms • Any affine transformation can be composed as a sequence of simple transformations: – Translation – Scaling – Rotation – Shear – Reflection
  • 11. 2D Translation • Moves an object                             y x b b y x y x 1 0 0 1 x y x y bx by
  • 12. 2D Scaling • Resizes an object in each dimension x y                             0 0 0 0 y x s s y x y x x y x y sxx syy
  • 13. 2D Rotation • Rotate counter-clockwise about the origin by an angle                               0 0 cos sin sin cos y x y x     x y x y 
  • 14. X-Axis Shear • Shear along x axis (What is the matrix for y axis shear?)                             0 0 1 0 1 y x sh y x x x y x y
  • 15. Reflect About X Axis • What is the matrix for reflect about Y axis?                              0 0 1 0 0 1 y x y x x x
  • 16. Rotating About An Arbitrary Point • What happens when you apply a rotation transformation to an object that is not at the origin? • Solution: – Translate the center of rotation to the origin – Rotate the object – Translate back to the original location
  • 17. Rotating About An Arbitrary Point x y x y x y x y
  • 18. Scaling an Object not at the Origin • What also happens if you apply the scaling transformation to an object not at the origin? • Based on the rotating about a point composition, what should you do to resize an object about its own center?
  • 19.
  • 20. [6]-20 RM Preserved Attributes General Properties Line Angle Distance Area Translation Yes Yes Yes Yes Rotation Yes Yes Yes Yes Scaling Yes No No No Reflection Yes Yes Yes Yes Shear Yes No No Yes
  • 21. Back to Rotation About a Pt • Say R is the rotation matrix to apply, and p is the point about which to rotate • Translation to Origin: • Rotation: • Translate back: • The translation component of the composite transformation involves the rotation matrix. What a mess! p x x    Rp Rx p x R x R x         ) ( p Rp Rx p x x          
  • 22. [6]-22 RM A general invertible, linear, transformation. Affine Transformation Transformation Matrix:           x a x b y c y a x b y c a b a b 1 1 1 2 2 2 1 2 2 1 0 ( )
  • 23. Homogeneous Coordinates • Use three numbers to represent a point • (x,y)=(wx,wy,w) for any constant w0 • Typically, (x,y) becomes (x,y,1) • Translation can now be done with matrix multiplication!                                  1 1 0 0 1 y x b a a b a a y x y yy yx x xy xx
  • 24. [6]-24 RM • Product of affine transformations is affine. •Affine transformations preserve linearity of segments. •Affine transformations preserve parallelism between lines. •Affine transformations are invertible. Affine Transformation: Properties