Chapter 5 Geometric Transformations

Slides:



Advertisements
Similar presentations
COMPUTER GRAPHICS 2D TRANSFORMATIONS.
Advertisements

Gursharan Singh Tatla TRANSFORMATIONS Gursharan Singh Tatla Gursharan Singh Tatla.
Three Dimensional Modeling Transformations
1 Computer Graphics Chapter 6 2D Transformations.
Two-Dimensional Geometric Transformations
2D TRANSFORMATIONS. 2D Transformations What is transformations? –The geometrical changes of an object from a current state to modified state. Why the.
25 May May May 2015Week 5-2D Transformations1 2D Transformations By: KanwarjeetSingh.
2D TRANSFORMATIONS.
CMPE 466 COMPUTER GRAPHICS
CMPE 466 COMPUTER GRAPHICS
1 CSCE 441 Computer Graphics: 2D Transformations Jinxiang Chai.
2.1 si SI31 Advanced Computer Graphics AGR Lecture 2 Basic Modelling.
Computer Graphics with OpenGL 3e
2D Transformations x y x y x y. 2D Transformation Given a 2D object, transformation is to change the object’s Position (translation) Size (scaling) Orientation.
2D Transformations Unit - 3. Why Transformations? In graphics, once we have an object described, transformations are used to move that object, scale it.
CAP4730: Computational Structures in Computer Graphics
CS 450: Computer Graphics 2D TRANSFORMATIONS
UNIT - 5 3D transformation and viewing. 3D Point  We will consider points as column vectors. Thus, a typical point with coordinates (x, y, z) is represented.
COS 397 Computer Graphics Svetla Boytcheva AUBG, Spring 2013.
5.2 Three-Dimensional Geometric and Modeling Transformations 2D3D Consideration for the z coordinate.
Geometric Transformation. So far…. We have been discussing the basic elements of geometric programming. We have discussed points, vectors and their operations.
Transformation of Graphics
TWO DIMENSIONAL GEOMETRIC TRANSFORMATIONS CA 302 Computer Graphics and Visual Programming Aydın Öztürk
Graphics Graphics Korea University cgvr.korea.ac.kr 2D Geometric Transformations 고려대학교 컴퓨터 그래픽스 연구실.
2D Transformation of Graphics
Dx = 2 dy = 3 Y X D Translation A translation is applied to an object by repositioning it along a straight-line path.
2D Geometric Transformations
Part7: Geometric Transformations
 2D Transformations 2D Transformations  Translation Translation  Rotation Rotation  Scaling Scaling.
Transformations Jehee Lee Seoul National University.
Geometric Transformations
CS 376 Introduction to Computer Graphics 02 / 16 / 2007 Instructor: Michael Eckmann.
Computer Graphics 2D Transformations. 2 of 74 Contents In today’s lecture we’ll cover the following: –Why transformations –Transformations Translation.
1 Computer Graphics Week9 -3D Geometric Transformation.
Computer Graphics 3D Transformations. Translation.
Two-Dimensional Geometric Transformations ch5. 참조 Subjects : Basic Transformations Homogeneous Coordinates Composite Transformations Other Transformations.
Two-Dimensional Geometric Transformations A two dimensional transformation is any operation on a point in space (x, y) that maps that point's coordinates.
Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.
Geometric Transformations
GEOMETRIC TRANFORMATIONS Presented By -Lakshmi Sahithi.
12/24/2015 A.Aruna/Assistant professor/IT/SNSCE 1.
2D Geometric Transformation Translation A translation is applied to an object by repositioning it along a straight-line path from one coordinate location.
3D Transformation A 3D point (x,y,z) – x,y, and z coordinates
Geometric Transformations UBI 516 Advanced Computer Graphics Aydın Öztürk
COLLEGE OF ENGINEERING UNIVERSITY OF PORTO COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS D Geometric Transformations Graphics Systems.
January 19, y X Z Translations Objects are usually defined relative to their own coordinate system. We can translate points in space to new positions.
3-D Geometric Transformations
3D Geometric Transformation
3D Geometric Transformation
CS552: Computer Graphics Lecture 4: 2D Graphics. Recap 2D Graphics Coordinate systems 2D Transformations o Translation o Scaling o Rotation Combining.
Learning Objectives Affine transformations Affine transformations Translation Translation Rotation Rotation Scaling Scaling Reflection Reflection Shear.
Homogeneous Coordinates and Matrix Representations Cartesian coordinate (x, y, z) Homogeneous coordinate (x h, y h, z h, h) Usually h = 1. But there are.
Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.
1 Teaching Innovation - Entrepreneurial - Global The Centre for Technology enabled Teaching & Learning, N Y S S, India DTEL DTEL (Department for Technology.
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
2D Transformations What is transformations? The geometrical changes of an object from a current state to modified state. Why the transformations is needed?
Computer Graphic 2 D Transformation.
CSCE 441 Computer Graphics: 2D Transformations
3D Geometry and Transformations
Transformations. Transformations Introduce standard transformations ◦ Rotation ◦ Translation ◦ Scaling ◦ Shear Derive homogeneous coordinate transformation.
Instructor: Dr. Shereen Aly Taie Basic Two-Dimensional Geometric Transformation 5.2 Matrix Representations and Homogeneous Coordinates 5.3 Inverse.
Forward Projection Pipeline and Transformations CENG 477 Introduction to Computer Graphics.
Lecture 10 Geometric Transformations In 3D(Three- Dimensional)
2D Transformations By: KanwarjeetSingh
Computer Graphics CC416 Week 15 3D Graphics.
2D Transformations y y x x y x.
2D/3D Transformations User Interfaces.
TWO DIMENSIONAL TRANSFORMATION
Lecture #6 2D Geometric Transformations
Translation in Homogeneous Coordinates
Presentation transcript:

Chapter 5 Geometric Transformations Computer Graphics Chapter 5 Geometric Transformations Andreas Savva

2D Translation Repositioning an object along a straight line path from one co-ordinate location to another (x,y) (x’,y’) To translate a 2D position, we add translation distances tx and ty to the original coordinates (x,y) to obtain the new coordinate position (x’,y’) x’= x + tx , y’= y + ty Matrix form T x y

2D Translation Moving a polygon from position (a) to position (b) with the translation vector (-5, 10), i.e. x y 5 10 15 20 x y 5 10 15 20 (a) (b)

Translating a Polygon class Point2D { public: GLfloat x, y; }; void translatePoly(Point2D P[], GLint n, GLfloat tx, GLfloat ty) { GLint i; for (i=0; i<n; i++) { P[i].x = P[i].x + tx; P[i].y = P[i].y + ty; } glBegin (GL_POLYGON); for (i=0; i<n; i++) glVertex2f(P[i].x, P[i].y); glEnd();

2D Rotation Repositioning an object along a circular path in the xy-plane x y (x,y) (x’,y’) φ θ r The original coordinates are:

2D Rotation Substituting x y (x,y) (x’,y’) φ θ r Matrix form

2D Rotation about a Pivot position Rotating about pivot position (xr, yr) x y (x,y) (x’,y’) φ θ r xr yr

Translating a Polygon class Point2D { public: GLfloat x, y; }; void rotatePoly(Point2D P[], GLint n, Point2D pivot, GLdouble theta) { Point2D *V; V = new Point2D[n]; GLint i; for (i=0; i<n; i++) { V[i].x = pivot.x + (P[i].x – pivot.x) * cos(theta) - (P[i].y – pivot.y) * sin(theta); V[i].y = pivot.y + (P[i].x – pivot.x) * sin(theta) - (P[i].y – pivot.y) * cos(theta); } glBegin (GL_POLYGON); for (i=0; i<n; i++ glVertex2f(V[i].x, V[i].y); glEnd(); delete[] V;

Reduced in size and moved 2D Scaling Altering the size of an object. Sx and Sy are the scaling factors. If Sx = Sy then uniform scaling. x y Sx = Sy = ½ Matrix form Sx = Sy = ½ x’ x Reduced in size and moved closer to the origin

2D Scaling relative to Fixed point Scaling relative to fixed point (xf, yf) x y Sx = ¼ , Sy = ½ P1 P2 P3 P1’ P2’ P3’ (xf , yf) OR where the additive terms xf(1-Sx) and yf(1-Sy) are constants for all points in the object.

Translating a Polygon class Point2D { public: GLfloat x, y; }; void scalePoly(Point2D P[], GLint n, Point2D fixedPt, GLfloat Sx, GLfloat Sy) { Point2D *V; V = new Point2D[n]; GLfloat addx = fixedPt.x * (1 – Sx); GLfloat addy = fixedPt.y * (1 – Sy); GLint i; for (i=0; i<n; i++) { V[i].x = P[i].x * Sx + addx; V[i].y = P[i].y * Sy + addy; } glBegin (GL_POLYGON); for (i=0; i<n; i++ glVertex2f(V[i].x, V[i].y); glEnd(); delete[] V;

Matrix Representation Use 3×3 matrices to combine transformations Translation Rotation Scaling

Inverse Transformations Translation Rotation Scaling

Example Consider the line with endpoints (10, 10) and (30, 25). Translate it by tx = -20, ty = -10 and then rotate it by θ = 90º. x y (10, 10) (30, 25) Right-to-left

Solution x y (10, 10) (30, 25)

Solution (continue) Point (10, 10) Point (30, 25) y x (30, 25) (0, -10) (-15, 10) Point (10, 10) Point (30, 25)

Result Step-by-step x y x y x y T(-20, -10) R(90º) (30, 25) (-15, 10) (10, 10) (30, 25) (0, -10) (-15, 10) Step-by-step x y (10, 15) (-10, 0) x y (0, -10) (-15, 10) T(-20, -10) R(90º)

Exercises Consider the following object: Apply a rotation by 145º then scale it by Sx=2 and Sy=1.5 and then translate it by tx=20 and ty=-30. Scale it by Sx=½ and Sy=2 and then rotate it by 30º. Apply a rotation by 90º and then another rotation by 45º. Apply a rotation by 135º. x y 10 25 45

Exercises Composite 2D Transformations Translation: Show that: Rotation: Show that: Scaling: Show that:

General 2D Pivot-Point Rotation x y (xr , yr) x y Original position and Pivot Point Translate Object so that Pivot Point is at origin x y (xr , yr) x y Rotation about origin Translate object so that Pivot Point is return to position (xr , yr)

General Pivot-point Rotation Using Matrices

Exercises Consider the following object: Apply a rotation by 60° on the Pivot Point (-10, 10) and display it. Apply a rotation by 30° on the Pivot Point (45, 10) and display it. Apply a rotation by 270° on the Pivot Point (10, 0) and then translate it by tx = -20 and ty = 5. Display the final result. x y 10 25 45

General 2D Fixed-Point Scaling y (xf , yf) x y Original position and Fixed Point Translate Object so that Fixed Point is at origin (xf , yf) x y x y Scale Object with respect to origin Translate Object so that Fixed Point is return to position (xf , yf)

General 2D Fixed-Point Scaling Using Matrices

Exercises Consider the following object: Scale it by sx = 2 and sy = ½ relative to the fixed point (140, 125) and display it. Apply a rotation by 90° on the Pivot Point (50, 60) and then scale it by sx = sy = 2 relative to the Fixed Point (0, 200). Display the result. Scale it sx = sy = ½ relative to the Fixed Point (50, 60) and then rotate it by 180° on the Pivot Point (50, 60). Display the final result. x y 60 50 125 220

Order of Transformations Object is first translated in the x direction and then rotated by 90º x y Object is first rotated by 90º and then translated in the x direction x y

Reflection About the x axis About the y axis y x y x Reflection of an object about the x axis x y About the y axis x y Reflection of an object about the y axis

Same as a rotation with 180º Reflection Relative to the coordinate origin Same as a rotation with 180º x y With respect to the line y = x x y y = x

2D Shear x-direction shear Matrix form y x Initial object y x shx = 2 1 Matrix form x y shx = 2 1 2 3

2D Shear x-direction relative to other reference line Matrix form y x 1 yref = -1 Matrix form y x shx = ½, yref = -1 1 2 3 yref = -1

2D Shear y-direction shear Matrix form y x Initial object y x shy = 2 1 Matrix form x y shy = 2 1 2 3

2D Shear y-direction relative to other reference line Matrix form y x 1 xref = -1 Matrix form y x 1 2 xref = -1 shy = ½, xref = -1

Transformations between 2D Coordinate Systems x y x0 x’ y’ y0  To translate object descriptions from xy coordinates to x’y’ coordinates, we set up a transformation that superimposes the x’y’ axes onto the xy axes. This is done in two steps: Translate so that the origin (x0, y0) of the x’y’ system is moved to the origin (0, 0) of the xy system. Rotate the x’ axis onto the x axis.

Transformations between 2D Coordinate Systems i.e. 1) 2) Concatenating:

Example Find the x’y’-coordinates of the xy points (10, 20) and (35, 20), as shown in the figure below: x y 30 x’ y’ 10 30º (10, 20) (35, 20)

y y’ y’ x’ x’ x (-12.38, 18.66) (35, 20) (10, 20) (9.31, 6.16) 30º 10

Exercise Find the x’y’-coordinates of the rectangle shown in the figure below: x y 10 x’ y’ 60º 20

x’= x + tx , y’= y + ty , z’= z + tz 3D Translation Repositioning an object along a straight line path from one co-ordinate location to another (x,y,z) (x’,y’,z’) To translate a 3D position, we add translation distances tx ty and tz to the original coordinates (x,y,z) to obtain the new coordinate position (x’,y’) x’= x + tx , y’= y + ty , z’= z + tz Matrix form (4 × 4) T(tx, ty, tz) x y z

3D Rotation x y z z-axis The 2D z-axis rotation equations are extended to 3D. Matrix form x y z

3D Rotation x-axis x y z Matrix form

3D Rotation y-axis x y z Matrix form

3D Scaling x y z Matrix form

Other 3D Transformations Reflection z-axis x y z Shears z-axis