I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Stuff Andries van Dam September 12, 2006 Transformations 1/33 Transformations.

Slides:



Advertisements
Similar presentations
Today Composing transformations 3D Transformations
Advertisements

COMP 175 | COMPUTER GRAPHICS Remco Chang1/6103b – Shapes Lecture 03b: Shapes COMP 175: Computer Graphics February 3, 2015.
Computer Graphics Lecture 4 Geometry & Transformations.
Three Dimensional Viewing
Shared Graphics Skills Cameras and Clipping Planes
Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 51 Today’s class Geometric objects and transformations.
CPCS 391 Computer Graphics 1 Lecture 5: Polygon Filling
HCI 530 : Seminar (HCI) Damian Schofield. HCI 530: Seminar (HCI) Transforms –Two Dimensional –Three Dimensional The Graphics Pipeline.
2D Geometric Transformations
Chapter 4.1 Mathematical Concepts
2/7/2001Hofstra University – CSC290B1 Review: Math (Ch 4)
Chapter 4.1 Mathematical Concepts. 2 Applied Trigonometry Trigonometric functions Defined using right triangle  x y h.
CS5500 Computer Graphics March 22, Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 Coordinate-Free Geometry When we learned simple.
2.1 si SI31 Advanced Computer Graphics AGR Lecture 2 Basic Modelling.
Transformations Objectives Understand how transformations work in 2D and 3D Understand the concept of homogenous coordinate system Understand scene graphs.
CSCE 590E Spring 2007 Basic Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
3-D Geometry.
Transformations. 2 Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 Coordinate-Free Geometry When we learned simple geometry, most of us.
Transformations CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
Geometric Transformations
Linear Algebra Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.
CS 450: Computer Graphics 2D TRANSFORMATIONS
Geometric Objects and Transformations Geometric Entities Representation vs. Reference System Geometric ADT (Abstract Data Types)
Hierarchical Transformations Hierarchical Models Scene Graphs
2IV60 Computer graphics set 4:3D transformations and hierarchical modeling Jack van Wijk TU/e.
Foundations of Computer Graphics (Fall 2012) CS 184, Lecture 3: Transformations 1
COS 397 Computer Graphics Svetla Boytcheva AUBG, Spring 2013.
C O M P U T E R G R A P H I C S Stuff Jian Chen January 15, 2010 Transformations 1/28 Geometric Transformations By Andries van Dam.
COMP 175: Computer Graphics March 10, 2015
Transformations Aaron Bloomfield CS 445: Introduction to Graphics
I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 14, 2004 Transformation 1/32 Transformations.
C O M P U T E R G R A P H I C S Stuff CMSC 435 / 634 Transformations 1/29 Geometric Transformations Readings: Chapters 5-6.
Chapter 4.1 Mathematical Concepts
COMP 175: Computer Graphics March 24, 2015
CS 480/680 Computer Graphics Representation Dr. Frederick C Harris, Jr. Fall 2012.
C O M P U T E R G R A P H I C S Stuff Jian Chen January 15, 2010 Transformations 1/10 Describing Shape By Andries van Dam.
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
Transformations Dr. Amy Zhang.
CS 480/680 Computer Graphics Transformations Dr. Frederick C Harris, Jr.
Mathematical Foundations Sections A-1 to A-5 Some of the material in these slides may have been adapted from university of Virginia, MIT and Åbo Akademi.
Geometric Transformations Jehee Lee Seoul National University.
Dx = 2 dy = 3 Y X D Translation A translation is applied to an object by repositioning it along a straight-line path.
CSE 681 Review: Transformations. CSE 681 Transformations Modeling transformations build complex models by positioning (transforming) simple components.
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.
Geometric Objects and Transformation
C O M P U T E R G R A P H I C S Guoying Zhao 1 / 52 C O M P U T E R G R A P H I C S Guoying Zhao 1 / 52 Computer Graphics Three-Dimensional Graphics I.
Background Mathematics Aaron Bloomfield CS 445: Introduction to Graphics Fall 2006.
Introduction to Computer Graphics Geometric Transformations
Geometric Transformations
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
12/24/2015 A.Aruna/Assistant professor/IT/SNSCE 1.
Geometric Transformations Sang Il Park Sejong University Many slides come from Jehee Lee’s.
Affine Geometry.
Computer Graphics Matrices
CSCE 552 Fall 2012 Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
CS559: Computer Graphics Lecture 9: 3D Transformation and Projection Li Zhang Spring 2010 Most slides borrowed from Yungyu ChuangYungyu Chuang.
Computer Graphics I, Fall 2010 Transformations.
CS 376 Introduction to Computer Graphics 02 / 14 / 2007 Instructor: Michael Eckmann.
CS 551 / 645: Introductory Computer Graphics Viewing Transforms.
Computer Graphics Lecture 11 2D Transformations I Taqdees A. Siddiqi
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
3D Ojbects: Transformations and Modeling. Matrix Operations Matrices have dimensions: Vectors can be thought of as matrices: v=[2,3,4,1] is a 1x4 matrix.
Constructing Objects in Computer Graphics By Andries van Dam©
COMP 175: Computer Graphics February 9, 2016
2D Geometric Transformations
Rendering – Matrix Transformations and the Graphics Pipeline
Game Programming Algorithms and Techniques
Presentation transcript:

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Stuff Andries van Dam September 12, 2006 Transformations 1/33 Transformations

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Stuff Andries van Dam September 12, 2006 Transformations 2/33 Object construction using assemblies/hierarchy of parts à la Sketchpad’s masters and instances; leaves contain primitives Aid to realism – objects, camera use realistic motion Help form 3D “object hypothesis” (James Gibson) – kinesthetic feedback as user manipulates objects or synthetic camera Synthetic camera/viewing – definition – normalization (from arbitrary to canonical view) Note: Helpful applets – Experiment with these concepts on cs123 webpage: Applets->Linear Algebra and Applets->Scenegraphs “is composed of hierarchy” ROBOT transformation upper bodylower body headtrunkarm stanchionbase Scenegraph (see Sceneview assignment) How Are Geometric Transformations (T,R,S) Used in Computer Graphics?

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Stuff Andries van Dam September 12, 2006 Transformations 3/33 Lines and Polylines Convex: For every pair of points in the polygon, the line between them is fully contained in the polygon. Convex vs. Concave Polygons Concave: Not convex: some two points in the polygon are joined by a line not fully contained in the polygon. Polylines: lines drawn between ordered points Same first and last point make closed polyline or polygon If it does not intersect itself, called simple polygon 2D Object Definition (1/3)

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Stuff Andries van Dam September 12, 2006 Transformations 4/33 Circles Consist of all points equidistant from one predetermined point (the center) (radius) r = c, where c is a constant On a Cartesian grid with center of circle at origin equation is r 2 = x 2 + y 2 trianglesquare rectangle P0P0 P1P1 r 0 y x r Special polygons 2D Object Definition (2/3)

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Stuff Andries van Dam September 12, 2006 Transformations 5/33 Circle as polygon Informally: a regular polygon with > 15 sides (Aligned) Ellipses A circle scaled along the x or y axis Example: height, on y-axis, remains 3, while length, on x-axis, changes from 3 to 6 2D Object Definition (3/3)

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Stuff Andries van Dam September 12, 2006 Transformations 6/33 Vertices in motion (“Generative object description”) Line is drawn by tracing path of a point as it moves (one dimensional entity) Square drawn by tracing vertices of a line as it moves perpendicularly to itself (two dimensional entity) Cube drawn by tracing paths of vertices of a square as it moves perpendicularly to itself (three-dimensional entity) Circle drawn by swinging a point at a fixed length around a center point 2D to 3D Object Definition

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Stuff Andries van Dam September 12, 2006 Transformations 7/33 Triangles and tri-meshes Often parametric polynomials, called splines PatchesCurves Boundaries are Polynomial curves In 3D Building 3D Primitives

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Stuff Andries van Dam September 12, 2006 Transformations 8/33 3D Coordinate geometry Vectors in 2 space and 3 space Dot product and cross product – definitions and uses Vector and matrix notation and algebra Properties (associativity but NOT commutativity) Matrix transpose and inverse – definition, use, and calculation Homogeneous coordinates You will need to understand these concepts If you don’t think you do, go to the linear algebra help session on Wednesday! Useful concepts from Linear Algebra

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Stuff Andries van Dam September 12, 2006 Transformations 9/33 Let’s Go Shopping Need 6 apples, 5 cans of soup, 1 box of tissues, and 2 bags of chips Stores A, B, and C (East Side Market, Whole Foods, and Store 24) have following unit prices respectively East Side Whole Foods Store 24 1 apple $0.20 $0.65 $ can of soup $0.93 $0.95 $ box of tissues $0.64 $0.75 $ bag of chips $1.20 $1.40 $3.50 Short Linear Algebra Digression: Vector and Matrix Notation, A non-Geometric Example (1/2)

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Stuff Andries van Dam September 12, 2006 Transformations 10/33 Shorthand to representation of the situation (assuming we can remember order of items and corresponding prices): Column vector for quantities, q: Row vector corresponding prices at stores (P): store A (East Side) store B (Whole Foods) store C (Store 24) [ ] [ ] [ ] A Non-Geometric Example (2/2)

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Stuff Andries van Dam September 12, 2006 Transformations 11/33 Let’s calculate for each of the three stores. Store A: 4 totalCost A =  PA i q i = (0.20 6) + ( ) + (0.64 1) + (1.20 2) = ( ) = 8.89 Store B: 4 totalCost B =  PB i q i = = 12.2 Store C: 4 totalCost C =  PC i q i = = 19.1 What do I pay? i = 1

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Stuff Andries van Dam September 12, 2006 Transformations 12/33 Can express these sums more compactly: Determine totalCost vector by row-column multiplication – dot product is the sum of the pairwise multiplications Apply this operation to rows of prices and column of quantities Using Matrix Notation

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Stuff Andries van Dam September 12, 2006 Transformations 13/33 Component-wise addition of vectors v’ = v + t where and x’ = x + dx y’ = y + dy To move polygons: translate vertices (vectors) and redraw lines between them Preserves lengths (isometric) Preserves angles (conformal) Note: House shifts position relative to origin dx = 2 dy = 3 Y X D Translation

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Stuff Andries van Dam September 12, 2006 Transformations 14/33 Component-wise scalar multiplication of vectors v’ = Sv where and Does not preserve lengths Does not preserve angles (except when scaling is uniform) Y X D Scaling Note: House shifts position relative to origin

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Stuff Andries van Dam September 12, 2006 Transformations 15/33 Rotation of vectors through an angle  v’ = R q v where and x’ = x cos Ө – y sin Ө y’ = x sin Ө + y cos Ө Proof by double angle formula Preserves lengths and angles Y X NB: A rotation by 0 angle, i.e. no rotation at all, gives us the identity matrix 2D Rotation Note: House shifts position relative to origin

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Stuff Andries van Dam September 12, 2006 Transformations 16/33 Suppose object is not centered at origin Solution: move to the origin, scale and/or rotate, then move it back. Would like to compose successive transformations… 2D Rotation and Scale are Relative to Origin

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Stuff Andries van Dam September 12, 2006 Transformations 17/33 Translation, scaling and rotation are expressed (non-homogeneously) as: Composition difficult to express – translation not expressed as a matrix multiplication Homogeneous coordinates allows expression of all three as 3x3 matrices for easy composition w is 1 for affine transformations in graphics translation: scale: rotation: v’ = v + t v’ = Sv v’ = Rv Homogenous Coordinates

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Stuff Andries van Dam September 12, 2006 Transformations 18/33 P 2d is intersection of line determined by P h with the w = 1 plane Infinite number of points correspond to (x, y, 1) : they constitute the whole line (tx, ty, tw) P 2d (x/w,y/w,1) P h (x,y,w) Y X W 1 What is ?

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Stuff Andries van Dam September 12, 2006 Transformations 19/33 For points written in homogeneous coordinates, translation, scaling and rotation relative to the origin are expressed homogeneously as: 2D Homogeneous Coordinate Transformations (1/2) S(s x, s y ) = s x s y v’ = S(s x, s y )v R(  ) = cos  -sin  0 sin  cos  v’ = R(  )v

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Stuff Andries van Dam September 12, 2006 Transformations 20/33 Consider the rotation matrix: The 2 x 2 submatrix columns are: – unit vectors (length=1) – perpendicular (dot product=0) – vectors into which X-axis and Y-axis rotate (are images of x and y unit vectors) The 2 x 2 submatrix rows are: – unit vectors – perpendicular – rotate into X-axis and Y-axis (are pre- images of x and y unit vectors) Preserves lengths and angles of original geometry. Therefore, matrix is a “rigid body” transformation. 2D Homogeneous Coordinate Transformations (2/2) R(  ) = cos  -sin  0 sin  cos 

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Stuff Andries van Dam September 12, 2006 Transformations 21/33 Translate [1,3] by [7,9] Scale [2,3] by 5 in the x direction and 10 in the Y direction Rotate [2,2] by 90 ° Examples

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Stuff Andries van Dam September 12, 2006 Transformations 22/33 Avoiding unwanted translation when scaling or rotating an object not centered at origin: – translate object to origin, perform scale or rotate, translate back. How would you scale the house by 2 in “its” y and rotate it through 90° ? Remember: matrix multiplication is not commutative! Hence order matters! (refer to the Transformation Game at Applets->Scenegraphs) Matrix Compositions: Using Translation

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Stuff Andries van Dam September 12, 2006 Transformations 23/33 Y X Y X Translation → Rotation Rotation → Translation Transformations are NOT Commutative

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Stuff Andries van Dam September 12, 2006 Transformations 24/33 Translation Scaling (right-handed coordinate system) x y z 3D Basic Transformations (1/2)

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Stuff Andries van Dam September 12, 2006 Transformations 25/33 Rotation about X-axis (right-handed coordinate system) Rotation about Y-axis Rotation about Z-axis 3D Basic Transformations (2/2)

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Stuff Andries van Dam September 12, 2006 Transformations 26/33 Some uses we’ll be seeing later Placing sub-objects in parent’s coordinate system to construct hierarchical scene graph – transforming primitives in own coordinate system View volume normalization – mapping arbitrary view volume into canonical view volume along z-axis Parallel (orthographic, oblique) and perspective projection Perspective transformation Homogeneous Coordinates

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Stuff Andries van Dam September 12, 2006 Transformations 27/33 “Skew” a scene to the side: Squares become parallelograms - x coordinates skew to right, y coordinates stay same 90 ° between axes becomes Ө Like pushing top of deck of cards to the side – each card shifts relative to the one below Hmmm… Notice that the base of the house (at y=1) remains horizontal, but shifts to the right… Y X NB: A skew of 0 angle, i.e. no skew at all, gives us the identity matrix, as it should Skew/Shear/Translate (1/2)

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Stuff Andries van Dam September 12, 2006 Transformations 28/33 Everything along line y=1 stays on line y=1, but translated to the right Distance between points on line is preserved A 1D homogeneous coordinate translation looks like 2D skew transformation original y-axis Skew/Shear/Translate (2/2)

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Stuff Andries van Dam September 12, 2006 Transformations 29/33 3D scenes are often stored in a directed acyclic graph (DAG) called a scene graph – Open Scene Graph (used in the Cave) – Sun’s Java3D™ – X3D ™ (aka VRML ™) Typical scene graph format: – objects (cubes, sphere, cone, polyhedra etc.) – stored as nodes (default: unit size at origin) – attributes (color, texture map, etc.) and transformations are also nodes in scene graph (labeled edges on slide 2 are an abstraction) For your assignments, use simplified format: – attributes stored as a component of each object node (no separate attribute node) – transform node affects its subtree, but not siblings (unlike X3D, Open Scene Graph) – transform node can only have one child – only leaf nodes are graphical objects – all internal nodes that are not transform nodes are group nodes Transforms in Scene Graphs (1/3)

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Stuff Andries van Dam September 12, 2006 Transformations 30/33 ROBOT upper bodylower body headtrunk arm stanchionbase 1. Leaves of tree are standard size object primitives 2. We transform them 3. To make sub-groups 4. Transform subgroups 5. To get final scene Closer look at Scenegraph from slide 2 … Transforms in Scene Graphs (2/3)

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Stuff Andries van Dam September 12, 2006 Transformations 31/33 Below, transformation t0 affects all objects t2 affects only obj2 and one instance of group3 (includes instance of obj3 and obj4) – t2 doesn’t affect obj1, other instance of group3 Note: to use multiple instances of a sub- tree (i.e. group3), must define it before use – easier to implement object nodes (geometry) transformation nodes group nodes group3 obj3obj4 t5t6 t4 root t0 group1 t1t2 obj1group3 t3 group2 group3obj2 Transforms in Scene Graphs (3/3)

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Stuff Andries van Dam September 12, 2006 Transformations 32/33 Transformation nodes contain at least a matrix that handles the transformation; – may also contain individual transformation parameters – refer to scene graph hierarchy applet by Dave Karelitz (URL on slide 2) To determine final composite transformation matrix (CTM) for object node: – compose all parent transformations during prefix graph traversal – exact detail of how this is done varies from package to package, so be careful Composing Transformations in a Scene Graph (1/2)

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Stuff Andries van Dam September 12, 2006 Transformations 33/33 Example: - for o1, CTM = m1 - for o2, CTM = m2* m3 - for o3, CTM = m2* m4* m5 - for a vertex v in o3, position in the world (root) coordinate system is: CTM v = (m2*m4*m5)v g: group nodes m: matrices of transform nodes o: object nodes m5 m1m2 m3 m4 o1 o2 o3 g1 g2 g3 Composing Transformations in a Scene Graph (2/2)