Transformations Week 9, Lecture 18

Similar documents
3D Transformations World Window to Viewport Transformation Week 2, Lecture 4

XPM 2D Transformations Week 2, Lecture 3

XPM 2D Transformations Week 2, Lecture 3

Transformations. CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science

Objectives. transformation. General Transformations. Affine Transformations. Notation. Pipeline Implementation. Introduce standard transformations

3D Transformations. CS 4620 Lecture 10. Cornell CS4620 Fall 2014 Lecture Steve Marschner (with previous instructors James/Bala)

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

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

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

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

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

Geometric Transformations

Animating orientation. CS 448D: Character Animation Prof. Vladlen Koltun Stanford University

Quaternions and Rotations

Math background. 2D Geometric Transformations. Implicit representations. Explicit representations. Read: CS 4620 Lecture 6

Quaternions and Rotations

Vector Algebra Transformations. Lecture 4

Advanced Computer Graphics Transformations. Matthias Teschner

Quaternions and Rotations

12.1 Quaternions and Rotations

Transforms. COMP 575/770 Spring 2013

CS4620/5620. Professor: Kavita Bala. Cornell CS4620/5620 Fall 2012 Lecture Kavita Bala 1 (with previous instructors James/Marschner)

Computer Animation II

Part II: OUTLINE. Visualizing Quaternions. Part II: Visualizing Quaternion Geometry. The Spherical Projection Trick: Visualizing unit vectors.

2D/3D Geometric Transformations and Scene Graphs

Animation. CS 4620 Lecture 32. Cornell CS4620 Fall Kavita Bala

CS 536 Computer Graphics Intro to Curves Week 1, Lecture 2

2D and 3D Transformations AUI Course Denbigh Starkey

Transformations: 2D Transforms

Coordinate transformations. 5554: Packet 8 1

UNIT 2 2D TRANSFORMATIONS

Visual Recognition: Image Formation

Translation. 3D Transformations. Rotation about z axis. Scaling. CS 4620 Lecture 8. 3 Cornell CS4620 Fall 2009!Lecture 8

Computer Graphics: Geometric Transformations

Quaternions and Rotations

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

Linear and Affine Transformations Coordinate Systems

Intro to Curves Week 4, Lecture 7

Computer Graphics. Chapter 5 Geometric Transformations. Somsak Walairacht, Computer Engineering, KMITL

Overview. Affine Transformations (2D and 3D) Coordinate System Transformations Vectors Rays and Intersections

Image warping , , Computational Photography Fall 2017, Lecture 10

Today. Today. Introduction. Matrices. Matrices. Computergrafik. Transformations & matrices Introduction Matrices

Homogeneous Coordinates

3D Modeling: Surfaces

Transformations. Questions on Assignment 1? Announcements

2D TRANSFORMATIONS AND MATRICES

Animation and Quaternions

B-Splines and NURBS Week 5, Lecture 9

3D Computer Graphics. Jared Kirschner. November 8, 2010

Modeling Transformations

Jane Li. Assistant Professor Mechanical Engineering Department, Robotic Engineering Program Worcester Polytechnic Institute

Computer Animation Fundamentals. Animation Methods Keyframing Interpolation Kinematics Inverse Kinematics

Jorg s Graphics Lecture Notes Coordinate Spaces 1

IMAGE-BASED RENDERING AND ANIMATION

Object Representation Affine Transforms. Polygonal Representation. Polygonal Representation. Polygonal Representation of Objects

2D Object Definition (1/3)

Fundamentals of Computer Animation

Analysis of Euler Angles in a Simple Two-Axis Gimbals Set

Graphics and Interaction Transformation geometry and homogeneous coordinates

GEOMETRIC TRANSFORMATIONS AND VIEWING

COMP30019 Graphics and Interaction Transformation geometry and homogeneous coordinates

Lecture 9: Transformations. CITS3003 Graphics & Animation

Lecture 4: Transforms. Computer Graphics CMU /15-662, Fall 2016

2D transformations: An introduction to the maths behind computer graphics

Interactive Computer Graphics. Hearn & Baker, chapter D transforms Hearn & Baker, chapter 5. Aliasing and Anti-Aliasing

Affine Transformations in 3D

Game Engineering CS S-05 Linear Transforms

2D and 3D Coordinate Systems and Transformations

Section III: TRANSFORMATIONS

CS354 Computer Graphics Rotations and Quaternions

COMP30019 Graphics and Interaction Three-dimensional transformation geometry and perspective

521493S Computer Graphics Exercise 2 Solution (Chapters 4-5)

Geometric transformations assign a point to a point, so it is a point valued function of points. Geometric transformation may destroy the equation

CS612 - Algorithms in Bioinformatics

Animating Transformations

Computer Graphics. P04 Transformations. Aleksandra Pizurica Ghent University

Computer Graphics Geometric Transformations

Today. Parity. General Polygons? Non-Zero Winding Rule. Winding Numbers. CS559 Lecture 11 Polygons, Transformations

CSE528 Computer Graphics: Theory, Algorithms, and Applications

Rotations (and other transformations) Rotation as rotation matrix. Storage. Apply to vector matrix vector multiply (15 flops)

Outline. The de Casteljau Algorithm. Properties of Piecewise Linear Interpolations. Recall: Linear Interpolation

Computer Graphics 7: Viewing in 3-D

Hierarchical Modeling. CS 432 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science

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

CS230 : Computer Graphics Lecture 12: Introduction to Animation. Tamar Shinar Computer Science & Engineering UC Riverside

Homogeneous Coordinates and Transformations of the Plane

Quaternion properties: addition. Introduction to quaternions. Quaternion properties: multiplication. Derivation of multiplication

3D Mathematics. Co-ordinate systems, 3D primitives and affine transformations

3D Kinematics. Consists of two parts

Outline. Properties of Piecewise Linear Interpolations. The de Casteljau Algorithm. Recall: Linear Interpolation

CS 428: Fall Introduction to. Transformations in OpenGL + hierarchical modeling. Andrew Nealen, Rutgers, /21/2009 1

3D Modeling: Solid Models

CSE328 Fundamentals of Computer Graphics

CALCULATING TRANSFORMATIONS OF KINEMATIC CHAINS USING HOMOGENEOUS COORDINATES

CS452/552; EE465/505. Transformations

COMP3421. Vector geometry, Clipping

Motion Control (wheeled robots)

Animations. Hakan Bilen University of Edinburgh. Computer Graphics Fall Some slides are courtesy of Steve Marschner and Kavita Bala

Intro to Curves Week 1, Lecture 2

Computer Science 336 Fall 2017 Homework 2

Transcription:

CS 536 Computer Graphics Transformations Week 9, Lecture 18 2D Transformations David Breen, William Regli and Maxim Peysakhov Department of Computer Science Drexel University 1 3 2D Affine Transformations 2D Affine Transformations All represented as matrix operations on vectors! Parallel lines preserved, angles/lengths not Scale Rotate Translate Reflect Shear 4 Pics/Math courtesy of Dave Mount @ UMD-CP Example 1: rotation and non uniform scale on unit cube Example 2: shear first in x, then in y Note: Preserves parallels Does not preserve lengths and angles 5 2D Transforms: Translation 2D Transforms: Scale Rigid motion of points to new locations Stretching of points along axes: Defined with column vectors: In matrix form: as 6 or just: 7 1

2D Transforms: Rotation 2D Transforms: Rotation Rotation of points about the origin Substitute the 1 st two equations into the 2 nd two to get the general equation Positive Angle: CCW Negative Angle: CW rcos(θ + φ) rcos(φ) Matrix form: x= x cos(θ) y sin(θ) or just: 8 y= x sin(θ) + y cos(θ) 9 Homogeneous Coordinates Observe: translation is treated differently from scaling and rotation Homogeneous coordinates: allows all transformations to be treated as matrix multiplications Example: A 2D point (x,y) is the line (x,y,w), where w is any real #, in 3D homogenous coordinates. To get the point, homogenize by dividing by w (i.e. w=1) 10 Recall our Affine Transformations 11 Pics/Math courtesy of Dave Mount @ UMD-CP Matrix Representation of 2D Affine Transformations Translation: Scale: Rotation: Composition of 2D Transforms Rotate about a point P1 Translate P1 to origin Rotate Translate back to P1 P = T P T Shear: Reflection: F y = 12 13 2

Composition of 2D Transforms Composition of 2D Transforms Scale object around point P1 P1 to origin Scale Translate back to P1 Compose into T Scale + rotate object around point P1 and move to P2 P1 to origin Scale Rotate Translate to P2 P = T P P = T P 14 15 Composition of 2D Transforms Be sure to multiple transformations in proper order! P = (T (R (S (T P)))) P = ((T (R (S T))) P) P = T P The Window-to-Viewport Transformation Problem: Screen windows cannot display the whole world (window management) How to transform and clip: Objects to Windows to Screen 16 18 Pics/Math courtesy of Dave Mount @ UMD-CP Window-to-Viewport Transformation Given a window and a viewport, what is the transformation from WCS to VPCS? Three steps: Translate Scale Translate Transforming World Coordinates to Viewports 3 steps 1. Translate 2. Scale 3. Translate Overall Transformation: 19 P= M wv P 20 3

3D Transformations Representation of 3D Transformations Z axis represents depth Right Handed System When looking down at the origin, positive rotation is CCW 24 Left Handed System When looking down, positive rotation is in CW More natural interpretation for (into screen) displays, big z means far 25 3D Homogenous Coordinates Homogenous coordinates for 2D space requires 3D vectors & matrices Homogenous coordinates for 3D space requires 4D vectors & matrices [x,y,z,w] 26 3D Transformations: Scale Scale Parameters for each axis direction 27 3D Transformations: Translate Translation 3D Transformations: Rotation One rotation for each world coordinate axis 28 29 4

c = cos(θ) s = sin(θ) t = (1 - c) Rotation Around an Arbitrary Axis Rotate a point P around axis n (x,y,z) by angle θ # tx 2 + c txy + sz txz sy 0& % ( txy sz ty 2 + c tyz + sx 0 R = % ( % txz + sy tyz sx tz 2 + c 0( % ( $ 0 0 0 1 Graphics Gems I, p. 466 & 498 30 Rotation Around an Arbitrary Axis Also can be expressed as the Rodrigues Formula P rot = P cos(ϑ ) + (n P)sin(ϑ ) + n(n P)(1 cos(ϑ )) 31 Improved Rotations Euler Angles have problems How to interpolate keyframes? Angles aren t independent Interpolation can create Gimble Lock, i.e. loss of a degree of freedom when axes align Solution: Quaternions! 32 33 p = (0, x ) 34 35 5

36 37 What about interpolating multiple keyframes? A & B are quaternions slerp Spherical linear interpolation Need to take equals steps on the sphere 38 Shoemake suggests using Bezier curves on the sphere Offers a variation of the De Casteljau algorithm using slerp and quaternion control points See K. Shoemake, Animating rotation with quaternion curves, Proc. SIGGRAPH 85 39 Reflection: 3D Transformations: Reflect Reflection corresponds to negative scale factors about x-y plane s x = -1 s y = 1 original " $ about y-z plane F x = $ $ $ # 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 % & 40 s x = -1 s y = -1 s x = 1 s y = -1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E Addison-Wesley 2012 6

3D Transformations: Shear Shear: (function of y)! 1 sh x 0 0 $ # & H x = # 0 1 0 0 & # 0 0 1 0 & # & " 0 0 0 1 % x = x +sh x y 43 3D Transformations: Shear " X % " y z 1 Sh x Sh x 0% " X% $ $ x z $ $ Y Sh = $ y 1 Sh y 0 $ Y x y $ Z $ Sh z Sh z 1 0 $ Z $ $ $ # 1 & # 0 0 0 1& # 1 & X = X + Sh x y Y + Sh x z Z Y = Sh y x X +Y + Sh y z Z Z = Sh z x X + Sh z y Y + Z 45 Example: Composition of 3D Transformations Goal: Transform P 1 P 2 and P 1 P 3 Example (Cont.) Process 1. Translate P 1 to (0,0,0) 2. Rotate about y 3. Rotate about x 4. Rotate about z (4) (1) (2-3) 46 47 What we ve really done is transform the local coordinate system R x, R y, R z to align with the origin x,y,z Final Result Example 2: Composition of 3D Transformations Airplane defined in x,y,z Problem: want to point it in Dir of Flight (DOF) centered at point P Note: DOF is a vector Process: Rotate plane Move to P 48 49 7

Example 2 (cont.) Z p axis to be DOF X p axis to be a horizontal vector perpendicular to DOF y x DOF Y p, vector perpendicular to both Z p and X p (i.e.z p x X p ) Transformations to Change Coordinate Systems Issue: the world has many different relative frames of reference How do we transform among them? Example: CAD Assemblies & Animation Models 50 51 Transformations to Change Coordinate Systems 4 coordinate systems 1 point P Coordinate System Example (1) Translate the House to the origin M M M 1 2 2 3 3 4 = T (4,2) = T (2,3) S(0.5,0.5) = T (6.7,1.8) R(45 ) M 1 2 = T(x 1,y 1 ) M 2 1 = ( M 1 2 ) 1 = T( x 1, y 1 ) P 1 52 The matrix M ij that maps points from coordinate system j to i is the inverse of the matrix M ji that maps points from coordinate system j to coordinate system i. 53 Coordinate System Example (2) Transformation Composition: M 5 1 = M 5 4 M 4 3 M 3 2 M 2 1 54 World Coordinates and Local Coordinates To move the tricycle, we need to know how all of its parts relate to the WCS Example: front wheel rotates on the ground wrt the front wheel s z axis: P (wo) = T(αr,0,0) R z (α) P (wh ) Coordinates of P in wheel coordinate system: P (wh) = R z (α) P (wh ) 55 8

Properties of Transformation Matrices Note that matrix multiplication is not commutative i.e. in general M 1 M 2 M 2 M 1 T reflection around y axis T rotation in the plane 9