Computer Graphics. P04 Transformations. Aleksandra Pizurica Ghent University

Similar documents
Computer Graphics. 2D transformations. Transforma3ons in computer graphics. Overview. Basic classes of geometric transforma3ons

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

Image Warping. Some slides from Steve Seitz

Homogeneous Coordinates

Modeling Transformations

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

Modeling Transformations

Image Warping. Some slides from Steve Seitz

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

Scene Graphs & Modeling Transformations COS 426

Modeling Transformations Revisited

Image Warping. Many slides from Alyosha Efros + Steve Seitz. Photo by Sean Carroll

Modeling Transformations

Modeling Transformations

How is project #1 going?

Image Warping (Szeliski Sec 2.1.2)

Image Warping CSE399b, Spring 07 Computer Vision

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

Modeling Transformations

Transformations II. Week 2, Wed Jan 17

Chapter 3 : Computer Animation

What and Why Transformations?

Transformations. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

Two Dimensional Viewing

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

2D Image Transforms Computer Vision (Kris Kitani) Carnegie Mellon University

Computer Graphics Geometric Transformations

4. Two Dimensional Transformations

Computer Graphics. Geometric Transformations

Computer Graphics. Geometric Transformations

Editing and Transformation

Last Lecture. Edge Detection. Filtering Pyramid

High Dimensional Rendering in OpenGL

CS F-07 Objects in 2D 1

Interactive Computer Graphics. Warping and morphing. Warping and Morphing. Warping and Morphing. Lecture 14+15: Warping and Morphing. What is.

Rotation and Orientation: Fundamentals. Perelyaev Sergei VARNA, 2011

GEOMETRIC TRANSFORMATIONS AND VIEWING

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

3-Dimensional Viewing

Transformations. Examples of transformations: shear. scaling

Transformations III. Week 2, Fri Jan 19

Transformations Week 9, Lecture 18

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

3D Kinematics. Consists of two parts

CS770/870 Spring 2017 Transformations

Geometric Transformations

CS612 - Algorithms in Bioinformatics

CMSC 425: Lecture 6 Affine Transformations and Rotations

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

Warping, Morphing and Mosaics

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

2D and 3D Coordinate Systems and Transformations

CS Computer Graphics: Transformations & The Synthetic Camera

MEM380 Applied Autonomous Robots Winter Robot Kinematics

Graphics and Interaction Transformation geometry and homogeneous coordinates

COMP30019 Graphics and Interaction Transformation geometry and homogeneous coordinates

2D transformations and homogeneous coordinates

Geometric Model of Camera

Image Warping. Computational Photography Derek Hoiem, University of Illinois 09/28/17. Photo by Sean Carroll

CS559: Computer Graphics

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

3D Geometry and Camera Calibration

Transforms. COMP 575/770 Spring 2013

Reading. Topics in Articulated Animation. Character Representation. Animation. q i. t 1 t 2. Articulated models: Character Models are rich, complex

Name: [20 points] Consider the following OpenGL commands:

CS 445 / 645 Introduction to Computer Graphics. Lecture 21 Representing Rotations

1/29/13. Computer Graphics. Transformations. Simple Transformations

CSE528 Computer Graphics: Theory, Algorithms, and Applications

COMP30019 Graphics and Interaction Three-dimensional transformation geometry and perspective

More on Transformations. COS 426, Spring 2019 Princeton University

CS4670: Computer Vision

Image Metamorphosis By Affine Transformations

Modeling Transformations

4.7 INVERSE TRIGONOMETRIC FUNCTIONS

Coordinate transformations. 5554: Packet 8 1

Last week. Machiraju/Zhang/Möller/Fuhrmann

CALCULATING TRANSFORMATIONS OF KINEMATIC CHAINS USING HOMOGENEOUS COORDINATES

Topic 7: Transformations. General Transformations. Affine Transformations. Introduce standard transformations

Introduction to Homogeneous Transformations & Robot Kinematics

CS354 Computer Graphics Rotations and Quaternions

Introduction to Homogeneous Transformations & Robot Kinematics

Transformations using matrices

Lecture 9: Transformations. CITS3003 Graphics & Animation

Computer Graphics. Geometric. Transformations. by Brian Wyvill University of Calgary. Lecture 2 Geometric. Transformations. Lecture 2 Geometric

2D Object Definition (1/3)

Transformations: 2D Transforms

Orientation & Quaternions

Geometric transformations in 3D and coordinate frames. Computer Graphics CSE 167 Lecture 3

Image Warping, mesh, and triangulation CSE399b, Spring 07 Computer Vision

Geometric Transformations

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

CS770/870 Spring 2017 Quaternions

IMAGE-BASED RENDERING AND ANIMATION

CS5620 Intro to Computer Graphics

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

3D Transformations. CS 4620 Lecture Kavita Bala w/ prior instructor Steve Marschner. Cornell CS4620 Fall 2015 Lecture 11

CSCI-4530/6530 Advanced Computer Graphics

Hello, welcome to the video lecture series on Digital Image Processing. So in today's lecture

Animation. Keyframe animation. CS4620/5620: Lecture 30. Rigid motion: the simplest deformation. Controlling shape for animation

UNIT 2 2D TRANSFORMATIONS

Transcription:

Computer Graphics P4 Transformations Aleksandra Pizurica Ghent Universit Telecommunications and Information Processing Image Processing and Interpretation Group

Transformations in computer graphics Goal: introduce methodolog to Change coordinate sstem Move and deform objects Principle: transformations are applied to object vertices In 2D, point P(X,Y) is transformed to P (X,Y ); in 3D, P(X,Y,Z) P (X,Y,Z ) P4_2

Overview 2D transformations 3D transformations Quaternions Transformations in OpenGL P4_3

2D transformations

2D affine transformations Translate Shear Rotate Scale P4_5

Basic classes of geometric transformations General linear (preserve lines) Affine (preserve paralelism) Arbitrar shearing General scaling Conformal (preserve angles) Uniform scaling Rigid (preserve lengths) Translation Rotation P4_6

Elementar 2D transformations Translation T(T,T ) X X + T X Y Y + T Scaling S(S,S ) X X * S X Y Y * S Y Rotation R(θ) X X * cosθ Y*sinθ Y X * sinθ + Y*cosθ P4_7

Matri representation P4_8 Suppose we represent a 2D transformation b a matri d c b a d c b a + + transformed point transformation matri original point l k j i h g f e d c b a Wh is this useful? -A sequence of transformations matri multiplication Can we do it for an affine transform?

22 Matrices Which transformations can be represented b 22 matrices? -Lets look at some eamples: P4_9 S S 2D scale around (,) S S 2D identit 2D mirror over (,) - - 2D mirror over Y ais -

22 Matrices Which transformations can be represented b 22 matrices? -Lets look at some eamples: 2D rotation around (,) * cosθ *sinθ * sinθ+ *cosθ cosθ sinθ sinθ cosθ 2D Shear + H X * + H Y * H H P4_

22 Matrices Which transformations can be represented b 22 matrices? -Can we represent translation b a 22 matri? 2D Translation + T + T NO 22 matri! Onl linear2d transformations can be represented b a 22 matri Linear transformations satisf: T(s P +s 2 P 2 )s T (P )+s 2 T(P 2 ) are combinations of scale, rotation, share and mirror P4_

Matri representation for affine 2D transforms We want a representation where 2D translation is also represented b a matri (so that we can easil combine different transformations b multiplication) 2D matri representation of translation does not eist! What do we do? Solution: use a 33 matri 2D Translation + T + T T T Homogeneous coordinates P4_2

Homogeneous coordinates An equivalent formulation: adding a 3 rd coordinate to 2D point such that (, ) (W, W, W) (/W, /W) are Cartesian coordinates of the homogeneous point (,, W) (,, ) represents a point at infinit (,, ) not allowed 3 (2,3,) or (4,6,2) or (6,9,3) or W 2 (3,,) or (6,2,2) or 2 3 4 5 Homogeneous point is a line in 3D space P4_3

Homogeneous coordinates Even points infinitel far have a representation in homogeneous coordinates Points at infinit have their last coordinate equal to zero Eamples: P (,,); P 2 (,,); P 3 (,,), P 4 (2,,) 4 3 2 P P 2 P 4 P 3 2 3 4 5 P4_4

Matri form of elementar 2D transformations P4_5 T T Translation T(T,T ) S S Scaling S(S,S ) cos sin sin cos θ θ θ θ Rotation R(θ)

2D Shear transformation P4_6 H H General shear operation SH (H,H) Shear in the X-direction: H a SH b SH Shear in the Y-direction: H Shear can be represented as a combination of rotations and nonuniform scaling operations.

Compositions of 2D transformations Translate Rotate Eample: A comple transformation as a sequence of elementar transformations P4_7

Compositions of 2D transformations Inverse elementar transforms T - (T X, T Y ) T (-T X, -T Y ) S - (S X, S Y ) S (/S X, /S Y ) R - (θ) R (-θ) Comple transformations can be described as a combination (composition) of elementar transformations (X, Y,) T S (-) R (-) T (-) R (-) S (-) (X, Y, ) T Each rotation brings an etra parameter, scaling and translations two etra parameters Can this be simplified? P4_8

Compositions of 2D transformations We tr to simplif such epressions b Combining transformations, if possible Changing the order of transformations in order to make the combinations possible Sequential elementar transforms of the same tpe absorb each other T (T X, T Y ) T (T X2, T Y2 ) T (T X +T X2, T Y +T Y2 ) S (S X, S Y ) S (S X2, S Y2 ) S (S X.S X2, S Y.S Y2 ) R (θ ) R (θ 2 ) R (θ +θ 2 ) Changing transformation order is not alwas possible! Transformations that commute are onl Two elementar transformations of the same tpe Scaling with S S and Rotation P4_9

Compositions of 2D transformations Translation and rotation pseudo-commute T (T X,T Y ) R (θ) R (θ) T (T X2,T Y2 ) T (T X2,T Y2 ) R (θ) R (θ) T (T X,T Y ) P4_2

Compositions of 2D transformations Translation and scaling pseudo-commute S (S X, S Y ) T (T X,T Y ) T (T X2,T Y2 ) S (S X, S Y ) T(T X,T Y ) S(.5,3.) S (.5,3.) T (T X2,T Y2 ) No similar propert for rotation and scaling P4_2

Compositions of 2D transformations Hpothesis: Most general affine transform can alwas be represented as R(θ ) S (S X, S Y ) R(θ 2 ) T(T X,T Y ) This means: a unit square in the centre is reshaped to an arbitrar parallelogram, brought to an arbitrar position and rotated b an arbitrar angle Prove the hpothesis formall X ax + by + c Y dx + ey + f Set ct, ft Determine the parameters θ, θ 2, S X, S Y as a function of a, b, d, e P4_22

Efficienc: matri calculations The most general affine transformation P4_23 f e d c b a Multiplication of a 33 matri with column vector requires 9 multiplies and 6 additions Actuall we need onl 4 multiplies and 4 additions X ax + by + c Y dx + ey + f Even though matri representation is useful, practical application should make use of the special structure of the matri, for efficienc

Efficienc: creating successive views To produce an impression of a dnamicall rotating object, man successive views are needed *cosθ *sinθ *sinθ+ *cosθ The angle difference between the successive views is ver small (a few degrees). Can we simplif the calculation? Solution : Use approimation cosθ : *sinθ *sinθ+ What is wrong with this solution? A better solution *sinθ *sinθ+ Check the determinant of the matri in both cases! P4_24

3D transformations

3-D Transformations Generalization of 2D transformations Same principle: appl to vertices (which are now 3D points) P(X,Y,Z) is transformed to P (X,Y,Z ) We consider general 3D affine transformation X ax + by + cz + d Y ex + fy + gz + h Z ix + jy + kz + l Properties analogous to 2D case Lines map to lines (plane segments map to plane segments) Parallelism preserved A unit cube centered in the origin is transformed into an arbitrar parallelepiped, arbitraril positioned in space P4_26

3D transformations Convention that we will adopt: Right-hand side sstem z z z P4_27

3D rotation 3D rotation of a rigid object is described b three parameters, such as three angles of Euler In Euler angle formulation an arbitrar rotation is represented as a composition of three elemental rotations, each around a single coordinate ais http://en.wikipedia.org/wiki/euler_angles P4_28

3D rotation The rotations around, and z ais are also known as Roll, Pitch and Yaw ( heading ); terms coming from flight dnamics Pitch Yaw Longitudinal Roll Vertica Lateral P4_29

3D transformations Three elementar transforms Elementar translation Three elementar rotations Around the X-ais, Y-ais and Z-ais Elementar scaling In X-, Y-, en Z-direction Matri representation 4 4 matrices for 3-D, analogous to 3 3 matrices for 2-D using homogeneous coordinates W W ; Wz z W usual notation W : z z Each point in 3D space a line throught the origin in 4D space P4_3

3D Translation and Scaling Translation P4_3 T (T X, T Y, T Z ) z T T T z z X X + T X Y Y + T Y Z Z + T Z Elementar scaling S (S X, S Y, S Z ) z S S S z Y Y X X S X X Y S Y Y Z S Z Z

3D Rotation Rotation around -ais P4_32 cos sin sin cos θ θ θ θ R X (θ) R Y (ϕ) R Z (ψ) cos sin sin cos ϕ ϕ ϕ ϕ cos sin sin cos ψ ψ ψ ψ X X Y Y cos(θ) -Z sin(θ) Z Y sin(θ) + Z cos(θ Similarl for rotations around other two aes:

3D Shear Shear around the Z-ais X X + H X Z Y Y + H Y Z Z Z Can be represented in matri form as P4_33 z H H z Shear around the X-ais and Y-ais have a similar form

3D Transformations: properties Inverse transforms are defined as T - (T X, T Y, T Z ) T (-T X, -T Y, -T Z ) S - (S X, S Y, S Z ) S (/S X, /S Y, /S Z ) R X - (θ) R X (-θ); R Y - (φ) R Y (-φ); R Z - (ψ) R X (-ψ) The same absorption and pseudo-commutation are valid like in the 2D case Translation pseudo-commutes with scaling and with three rotations Scaling and rotations do not pseudo-commute Additional properties, specific for 3D (without proof) Two (different) rotations do not pseudo-commute (not even with an additional translation) Three (different) rotations and a translation do pseudo commute P4_34

3D Transformations: properties z. A general positioning transformation involves 6 parameters T (T X, T Y, T Z ) R X (θ) R Y (φ) R Z (ψ) Object deformation: 6 other parameters (scaling + rotation) A general affine transformation involves thus 2 parameters R X (θ) R Y (φ) R Z (ψ) S (S X,S Y,S Z ) R X (θ ) R Y (φ ) R Z (ψ ) T (T X,T Y,T Z ) There are man equivalent forms P4_35

Arbitrar displacement in 3D C B See eercises A C z Initial position z B A Desired position z C A () B B z C A (2) A z B C (3) C z B A (4) P4_36

Compositions of 3D transformations Rotation about arbitrar point: in this eample about z-ais From the book of Edward Angel: Interactive Computer Graphics A Top-Down Approach Using OpenGL P4_37

Quaternions and 3D rotation

Comple numbers and rotation Remember polar representation of a comple number c a + ib re iθ 2 r a + b 2, θ arctan( b / a) Denotebc the resultof rotatingc aboutthe originb φ: c re iθ iφ i( θ + φ) e re Quaternions (Sir William Rowan Hamilton, 843) are etensions of comple numbers in 3D, ielding elegant rotations in 3D a ( q, q); q qi + q2j + q3k i 2 2 2 j k ijk P4_39

Comple numbers and rotation A point in space p (, p) Rotationof the point p b θaboutthe vector v: where: θ θ r cos, sin v, 2 2 p rpr θ cos, sin 2 θ v 2 Whare quaternionsinterestingfor3drotationsin computer graphics? Euler angle representation suffers from Gimbal lock Simpler representation Lower computational compleit, but not necessaril after conversion to matri form r P4_4

Gimbal lock When the aes of two of the three gimbals align, "locking" into rotation in a degenerate 2D space. Eample: when the pitch (green) and aw (magenta) gimbals become aligned, changes to roll (blue) and aw appl the same rotation to the airplane. P4_4

Transformations in OpenGL

OpenGL function format function name dimensions glverte3f(,,z) belongs to GL librar,,z are floats glverte3fv(p) pis a pointer to an arra Angel: Interactive Computer Graphics 4E Addison-Wesle 25 P4_43

Transformations in OpenGL We canloadmatri withthe function glloadmatri(pointer_to_matri) Orset a matri to identitmatri withthe function glloadidentit() Rotation, translation and scaling are provided through glrotatef(angle,v,v,vz) gltranslatef(d,d,dz) glscalef(s,s,sz) P4_44

Summar 2D transformations arbitrar 2D affine transformation 6 parameters comple transformations as compositions of the elementar ones 3D transformations arbitrar 3D affine transformation 2 parameters comple transformations as compositions of the elementar ones Euler angles Quaternions advantage over Euler angle representation (Gimbal lock avoided) Transformations in OpenGL P4_45