2D/3D Geometric Transformations and Scene Graphs

Similar documents
Geometric Transformations

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

Transformation Hierarchies. CS 4620 Lecture 5

Scene Graphs. COMP 575/770 Fall 2010

Vector Algebra Transformations. Lecture 4

Graphics Pipeline 2D Geometric Transformations

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

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

Scene Graphs. CS4620/5620: Lecture 7. Announcements. HW 1 out. PA 1 will be out on Wed

Transforms. COMP 575/770 Spring 2013

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

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

Linear and Affine Transformations Coordinate Systems

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

Graphics and Interaction Transformation geometry and homogeneous coordinates

COMP30019 Graphics and Interaction Transformation geometry and homogeneous coordinates

CS354 Computer Graphics Rotations and Quaternions

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

For each question, indicate whether the statement is true or false by circling T or F, respectively.

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

Lecture 5 2D Transformation

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

CSE528 Computer Graphics: Theory, Algorithms, and Applications

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

To Do. Outline. Translation. Homogeneous Coordinates. Foundations of Computer Graphics. Representation of Points (4-Vectors) Start doing HW 1

CSE328 Fundamentals of Computer Graphics

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

CT5510: Computer Graphics. Transformation BOCHANG MOON

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

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

Transforms 1 Christian Miller CS Fall 2011

Transformations Week 9, Lecture 18

CALCULATING TRANSFORMATIONS OF KINEMATIC CHAINS USING HOMOGENEOUS COORDINATES

3D Viewing. CS 4620 Lecture 8

2D Object Definition (1/3)

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

COMP 175 COMPUTER GRAPHICS. Ray Casting. COMP 175: Computer Graphics April 26, Erik Anderson 09 Ray Casting

3D Geometry and Camera Calibration

3D Viewing. CS 4620 Lecture Steve Marschner. Cornell CS4620 Spring 2018 Lecture 9

Matrices. Chapter Matrix A Mathematical Definition Matrix Dimensions and Notation

CS 465 Program 4: Modeller

Orientation & Quaternions

Humanoid Robotics. Projective Geometry, Homogeneous Coordinates. (brief introduction) Maren Bennewitz

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

Game Engineering: 2D

Overview. By end of the week:

UNIT 2 2D TRANSFORMATIONS

To graph the point (r, θ), simply go out r units along the initial ray, then rotate through the angle θ. The point (1, 5π 6. ) is graphed below:

GEOMETRIC TRANSFORMATIONS AND VIEWING

Affine Transformations. Transforming shape models Combining affine transformations Scene graphs, interactor trees Hit tests on transformed shapes

2D Spline Curves. CS 4620 Lecture 18

2D and 3D Transformations AUI Course Denbigh Starkey

2D Spline Curves. CS 4620 Lecture 13

Affine Transformations in 3D

An idea which can be used once is a trick. If it can be used more than once it becomes a method

Interactive Math Glossary Terms and Definitions

CHAPTER 1 Graphics Systems and Models 3

Monday, 12 November 12. Matrices

Specifying Complex Scenes

Visualizing Quaternions

Today s Topics. 3. Transformations in 2D. 4. Coordinate-free geometry. 5. 3D Objects (curves & surfaces) 6. Transformations in 3D

CS559: Computer Graphics

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

Introduction to Homogeneous coordinates

Transformations. Examples of transformations: shear. scaling

Computer Vision cmput 428/615

Articulated Characters

CS 130 Final. Fall 2015

CS6670: Computer Vision

Computer Vision Projective Geometry and Calibration. Pinhole cameras

Mathematics 308 Geometry. Chapter 9. Drawing three dimensional objects

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

To graph the point (r, θ), simply go out r units along the initial ray, then rotate through the angle θ. The point (1, 5π 6

GEOMETRIC TOOLS FOR COMPUTER GRAPHICS

Lecture 5: Transforms II. Computer Graphics and Imaging UC Berkeley CS184/284A

Drawing in 3D (viewing, projection, and the rest of the pipeline)

Answers. Chapter 2. 1) Give the coordinates of the following points:

CMSC427 Final Practice v2 Fall 2017

2-9 Operations with Complex Numbers

Graphics pipeline and transformations. Composition of transformations

JUST THE MATHS SLIDES NUMBER 5.2. GEOMETRY 2 (The straight line) A.J.Hobson

Computer Graphics Hands-on

METR 4202: Advanced Control & Robotics

STATISTICS MEAN Know the TOTAL # of points MEDIAN MIDDLE ($) Arrange the scores in order MODE most frequent. RANGE DIFFERENCE in high and low scores

CSE 167: Introduction to Computer Graphics Lecture #2: Coordinate Transformations

Modeling Objects. Modeling. Symbol-Instance Table. Instance Transformation. Each appearance of the object in the model is an instance

Pipeline Operations. CS 4620 Lecture 14

CS452/552; EE465/505. Geometry Transformations

Unit 1, Lesson 1: Moving in the Plane

Advanced Computer Graphics Transformations. Matthias Teschner

Ohio Tutorials are designed specifically for the Ohio Learning Standards to prepare students for the Ohio State Tests and end-ofcourse

UNIT 4 GEOMETRIC OBJECTS AND TRANSFORMATIONS-1

Linear algebra deals with matrixes: two-dimensional arrays of values. Here s a matrix: [ x + 5y + 7z 9x + 3y + 11z

Visual Recognition: Image Formation

First of all, we need to know what it means for a parameterize curve to be differentiable. FACT:

Chapter 3: Kinematics Locomotion. Ross Hatton and Howie Choset

TD2 : Stereoscopy and Tracking: solutions

Agenda. Rotations. Camera models. Camera calibration. Homographies

Hierarchical Modeling. University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell

Computer Graphics Geometric Transformations

Transcription:

2D/3D Geometric Transformations and Scene Graphs Week 4 Acknowledgement: The course slides are adapted from the slides prepared by Steve Marschner of Cornell University 1

A little quick math background Notation for sets, functions, mappings Linear transformations Matrices Matrix-vector multiplication Matrix-matrix multiplication Geometry of curves in 2D Implicit representation Explicit representation 2

Implicit representations Equation to tell whether we are on the curve Example: line (orthogonal to u, distance k from 0) Example: circle (center p, radius r) Always define boundary of region (if f is continuous) 3

Explicit representations Also called parametric Equation to map domain into plane Example: line (containing p, parallel to u) Example: circle (center b, radius r) Like tracing out the path of a particle over time Variable t is the parameter 4

Transforming geometry Move a subset of the plane using a mapping from the plane to itself Parametric representation: Implicit representation: 5

Translation Simplest transformation: Inverse: Example of transforming circle 6

Linear transformations One way to define a transformation is by matrix multiplication: Such transformations are linear, which is to say: (and in fact all linear transformations can be written this way) 7

Geometry of 2D linear trans. 2x2 matrices have simple geometric interpretations uniform scale non-uniform scale rotation shear reflection Reading off the matrix 8

Linear transformation gallery Uniform scale 9

Linear transformation gallery Nonuniform scale 10

Linear transformation gallery Rotation 11

Linear transformation gallery Reflection can consider it a special case of nonuniform scale 12

Linear transformation gallery Shear 13

Composing transformations Want to move an object, then move it some more We need to represent S o T ( S compose T ) and would like to use the same representation as for S and T Translation easy Translation by u T then by u S is translation by u T + u S commutative! 14

Composing transformations Linear transformations also straightforward Transforming first by M T then by M S is the same as transforming by M S M T only sometimes commutative e.g. rotations & uniform scales e.g. non-uniform scales w/o rotation Note M S M T, or S o T, is T first, then S 15

Combining linear with translation Need to use both in single framework Can represent arbitrary seq. as e. g. Transforming by M T and u T, then by M S and u S, is the same as transforming by M S M T and u S + M S u T This will work but is a little awkward 16

Homogeneous coordinates A trick for representing the foregoing more elegantly Extra component w for vectors, extra row/column for matrices for affine, can always keep w = 1 Represent linear transformations with dummy extra row and column 17

Homogeneous coordinates Represent translation using the extra column 18

Homogeneous coordinates Composition just works, by 3x3 matrix multiplication This is exactly the same as carrying around M and u but cleaner and generalizes in useful ways as we ll see later 19

Affine transformations The set of transformations we have been looking at is known as the affine transformations straight lines preserved; parallel lines preserved ratios of lengths along lines preserved (midpoints preserved) 20

Affine transformation gallery Translation 21

Affine transformation gallery Uniform scale 22

Affine transformation gallery Nonuniform scale 23

Affine transformation gallery Rotation 24

Affine transformation gallery Reflection can consider it a special case of nonuniform scale 25

Affine transformation gallery Shear 26

General affine transformations The previous slides showed canonical examples of the types of affine transformations Generally, transformations contain elements of multiple types often define them as products of canonical transforms sometimes work with their properties more directly 27

Composite affine transformations In general not commutative: order matters! rotate, then translate translate, then rotate 28

Composite affine transformations In general not commutative: order matters! rotate, then translate translate, then rotate 28

Composite affine transformations In general not commutative: order matters! rotate, then translate translate, then rotate 28

Composite affine transformations In general not commutative: order matters! rotate, then translate translate, then rotate 28

Composite affine transformations Another example scale, then rotate rotate, then scale 29

Composite affine transformations Another example scale, then rotate rotate, then scale 29

Composite affine transformations Another example scale, then rotate rotate, then scale 29

Composite affine transformations Another example scale, then rotate rotate, then scale 29

Rigid motions A transform made up of only translation and rotation is a rigid motion or a rigid body transformation The linear part is an orthonormal matrix Inverse of orthonormal matrix is transpose so inverse of rigid motion is easy: 30

Composing to change axes Want to rotate about a particular point could work out formulas directly Know how to rotate about the origin so translate that point to the origin 31

Composing to change axes Want to rotate about a particular point could work out formulas directly Know how to rotate about the origin so translate that point to the origin 31

Composing to change axes Want to rotate about a particular point could work out formulas directly Know how to rotate about the origin so translate that point to the origin 31

Composing to change axes Want to rotate about a particular point could work out formulas directly Know how to rotate about the origin so translate that point to the origin 31

Composing to change axes Want to scale along a particular axis and point Know how to scale along the y axis at the origin so translate to the origin and rotate to align axes 32

Composing to change axes Want to scale along a particular axis and point Know how to scale along the y axis at the origin so translate to the origin and rotate to align axes 32

Composing to change axes Want to scale along a particular axis and point Know how to scale along the y axis at the origin so translate to the origin and rotate to align axes 32

Composing to change axes Want to scale along a particular axis and point Know how to scale along the y axis at the origin so translate to the origin and rotate to align axes 32

Composing to change axes Want to scale along a particular axis and point Know how to scale along the y axis at the origin so translate to the origin and rotate to align axes 32

Composing to change axes Want to scale along a particular axis and point Know how to scale along the y axis at the origin so translate to the origin and rotate to align axes 32

Transforming points and vectors Recall distinction points vs. vectors vectors are just offsets (differences between points) points have a location represented by vector offset from a fixed origin Points and vectors transform differently points respond to translation; vectors do not 33

Transforming points and vectors Homogeneous coords. let us exclude translation just put 0 rather than 1 in the last place and note that subtracting two points cancels the extra coordinate, resulting in a vector! Preview: projective transformations what s really going on with this last coordinate? think of R 2 embedded in R 3 : all affine xfs. preserve z=1 plane could have other transforms; project back to z=1 34

More math background Coordinate systems Expressing vectors with respect to bases Linear transformations as changes of basis 35

Affine change of coordinates Six degrees of freedom or 36

Affine change of coordinates Coordinate frame: point plus basis Interpretation: transformation changes representation of point from one basis to another Frame to canonical matrix has frame in columns takes points represented in frame represents them in canonical basis e.g. [0 0], [1 0], [0 1] Seems backward but bears thinking about 37

Affine change of coordinates A new way to read off the matrix e.g. shear from earlier can look at picture, see effect on basis vectors, write down matrix Also an easy way to construct transforms e. g. scale by 2 across direction (1,2) 38

Affine change of coordinates When we move an object to the origin to apply a transformation, we are really changing coordinates the transformation is easy to express in object s frame so define it there and transform it T e is the transformation expressed wrt. {e 1, e 2 } T F is the transformation expressed in natural frame F is the frame-to-canonical matrix [u v p] This is a similarity transformation 39

Coordinate frame summary Frame = point plus basis Frame matrix (frame-to-canonical) is Move points to and from frame by multiplying with F Move transformations using similarity transforms 40

Data structures with transforms Representing a drawing ( scene ) List of objects Transform for each object can use minimal primitives: ellipse is transformed circle transform applies to points of object 41

Example Can represent drawing with flat list but editing operations require updating many transforms 42

Example Can represent drawing with flat list but editing operations require updating many transforms 42

Groups of objects Treat a set of objects as one Introduce new object type: group contains list of references to member objects This makes the model into a tree interior nodes = groups leaf nodes = objects edges = membership of object in group 43

Example Add group as a new object type lets the data structure reflect the drawing structure enables high-level editing by changing just one node 44

Example Add group as a new object type lets the data structure reflect the drawing structure enables high-level editing by changing just one node 44

The Scene Graph (tree) A name given to various kinds of graph structures (nodes connected together) used to represent scenes Simplest form: tree just saw this every node has one parent leaf nodes are identified with objects in the scene 45

Concatenation and hierarchy Transforms associated with nodes or edges Each transform applies to all geometry below it want group transform to transform each member members already transformed concatenate Frame transform for object is product of all matrices along path from root each object s transform describes relationship between its local coordinates and its group s coordinates frame-to-canonical transform is the result of repeatedly changing coordinates from group to containing group 46

Instances Simple idea: allow an object to be a member of more than one group at once transform different in each case leads to linked copies single editing operation changes all instances 47

Example Allow multiple references to nodes reflects more of drawing structure allows editing of repeated parts in one operation 48

Example Allow multiple references to nodes reflects more of drawing structure allows editing of repeated parts in one operation 48

Example Allow multiple references to nodes reflects more of drawing structure allows editing of repeated parts in one operation 48

The Scene Graph (with instances) With instances, there is no more tree an object that is instanced multiple times has more than one parent Transform tree becomes DAG directed acyclic graph group is not allowed to contain itself, even indirectly Transforms still accumulate along path from root now paths from root to leaves are identified with scene objects 49

Implementing a hierarchy Object-oriented language is convenient define shapes and groups as derived from single class abstract class Shape { void draw(); } class Square extends Shape { void draw() { // draw unit square } } class Circle extends Shape { void draw() { // draw unit circle } } 50

Implementing traversal Pass a transform down the hierarchy before drawing, concatenate abstract class Shape { void draw(transform t_c); } class Square extends Shape { void draw(transform t_c) { // draw t_c * unit square } } class Circle extends Shape { void draw(transform t_c) { // draw t_c * unit circle } } 51

Implementing traversal Pass a transform down the hierarchy before drawing, concatenate abstract class Shape { void draw(transform t_c); } class Square extends Shape { void draw(transform t_c) { // draw t_c * unit square } } class Circle extends Shape { void draw(transform t_c) { // draw t_c * unit circle } } class Group extends Shape { Transform t; ShapeList members; void draw(transform t_c) { for (m in members) { m.draw(t_c * t); } } } 51

Basic Scene Graph operations Editing a transformation good to present usable UI Getting transform of object in canonical (world) frame traverse path from root to leaf Grouping and ungrouping can do these operations without moving anything group: insert identity node ungroup: remove node, push transform to children Reparenting move node from one parent to another can do without altering position 52

Adding more than geometry Objects have properties besides shape color, shading parameters approximation parameters (e.g. precision of subdividing curved surfaces into triangles) behavior in response to user input Setting properties for entire groups is useful paint entire window green Many systems include some kind of property nodes in traversal they are read as, e.g., set current color 53

Scene Graph variations Where transforms go in every node on edges in group nodes only in special Transform nodes Tree vs. DAG Nodes for cameras and lights? 54

Translation 55

Translation 55

Translation 55

Translation 55

Scaling 56

Scaling 56

Scaling 56

Scaling 56

Rotation about z axis 57

Rotation about z axis 57

Rotation about x axis 58

Rotation about x axis 58

Rotation about y axis 59

Rotation about y axis 59

General rotations A rotation in 2D is around a point A rotation in 3D is around an axis so 3D rotation is w.r.t a line, not just a point there are many more 3D rotations than 2D a 3D space around a given point, not just 1D 2D 3D 60

Specifying rotations In 2D, a rotation just has an angle if it s about a particular center, it s a point and angle In 3D, specifying a rotation is more complex basic rotation about origin: unit vector (axis) and angle convention: positive rotation is CCW when vector is pointing at you about different center: point (center), unit vector, and angle this is redundant: think of a second point on the same axis... Alternative: Euler angles stack up three coord axis rotations 61

Coming up with the matrix Showed matrices for coordinate axis rotations but what if we want rotation about some random axis? Compute by composing elementary transforms transform rotation axis to align with x axis apply rotation inverse transform back into position Just as in 2D this can be interpreted as a similarity transform 62

Building general rotations Using elementary transforms you need three translate axis to pass through origin rotate about y to get into x-y plane rotate about z to align with x axis Alternative: construct frame and change coordinates choose p, u, v, w to be orthonormal frame with p and u matching the rotation axis apply similarity transform T = F R x (θ ) F 1 63

Orthonormal frames in 3D Useful tools for constructing transformations Recall rigid motions affine transforms with pure rotation columns (and rows) form right handed ONB that is, an orthonormal basis 64

Building 3D frames Given a vector a and a secondary vector b The u axis should be parallel to a; the u v plane should contain b u = u / u w = u x b; w = w / w v = w x u Given just a vector a The u axis should be parallel to a; don t care about orientation about that axis Same process but choose arbitrary b first Good choice is not near a: e.g. set smallest entry to 1 65

Building general rotations Alternative: construct frame and change coordinates choose p, u, v, w to be orthonormal frame with p and u matching the rotation axis apply similarity transform T = F R x (θ ) F 1 interpretation: move to x axis, rotate, move back interpretation: rewrite u-axis rotation in new coordinates (each is equally valid) 66

Building transforms from points Recall2D affine transformation has 6 degrees of freedom (DOFs) this is the number of knobs we have to set to define one Therefore 6 constraints suffice to define the transformation handy kind of constraint: point p maps to point q (2 constraints at once) three point constraints add up to constrain all 6 DOFs (i.e. can map any triangle to any other triangle) 3D affine transformation has 12 degrees of freedom count them by looking at the matrix entries we re allowed to change Therefore 12 constraints suffice to define the transformation in 3D, this is 4 point constraints (i.e. can map any tetrahedron to any other tetrahedron) 67

Transforming normal vectors Transforming surface normals differences of points (and therefore tangents) transform OK normals do not 68

Transforming normal vectors Transforming surface normals differences of points (and therefore tangents) transform OK normals do not 68