1 Chapter 7 Geometric Transformation  3D transformations  3D affine transforms including translation, rotation, scaling, shearing, and reflections 

Slides:



Advertisements
Similar presentations
Today Composing transformations 3D Transformations
Advertisements

Transformations Ed Angel Professor Emeritus of Computer Science
COMPUTER GRAPHICS 2D TRANSFORMATIONS.
Computer Graphics Lecture 4 Geometry & Transformations.
Geometric Transformations
Three Dimensional Modeling Transformations
1 Computer Graphics Chapter 6 2D Transformations.
Two-Dimensional Geometric Transformations
CMPE 466 COMPUTER GRAPHICS
Geometry (Many slides adapted from Octavia Camps and Amitabh Varshney)
HCI 530 : Seminar (HCI) Damian Schofield. HCI 530: Seminar (HCI) Transforms –Two Dimensional –Three Dimensional The Graphics Pipeline.
1 Geometrical Transformation 2 Outline General Transform 3D Objects Quaternion & 3D Track Ball.
2D Geometric Transformations
CMPE 466 COMPUTER GRAPHICS
Linear Algebra and SVD (Some slides adapted from Octavia Camps)
Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 7 Geometric Transformation.
Ch. 2: Rigid Body Motions and Homogeneous Transforms
CSCE 590E Spring 2007 Basic Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
3-D Geometry.
3D orientation.
Transformations CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
3D Graphics Goal: To produce 2D images of a mathematically described 3D environment Issues: –Describing the environment: Modeling (mostly later) –Computing.
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology 3D Engines and Scene Graphs Spring 2012.
CS 450: Computer Graphics 2D TRANSFORMATIONS
CS 450: COMPUTER GRAPHICS 3D TRANSFORMATIONS SPRING 2015 DR. MICHAEL J. REALE.
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 CMSC 435 / 634 Transformations 1/29 Geometric Transformations Readings: Chapters 5-6.
Geometric Transformation. So far…. We have been discussing the basic elements of geometric programming. We have discussed points, vectors and their operations.
Transformations Dr. Amy Zhang.
CS 480/680 Computer Graphics Transformations Dr. Frederick C Harris, Jr.
Computer Graphics Bing-Yu Chen National Taiwan University.
Graphics Graphics Korea University kucg.korea.ac.kr Transformations 고려대학교 컴퓨터 그래픽스 연구실.
2D Transformation of Graphics
Geometric Transforms Changing coordinate systems.
Dx = 2 dy = 3 Y X D Translation A translation is applied to an object by repositioning it along a straight-line path.
Rotations and Translations
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.
Geometric Camera Models
Geometric Objects and Transformation
16/5/ :47 UML Computer Graphics Conceptual Model Application Model Application Program Graphics System Output Devices Input Devices API Function.
Computer Graphics 3D Transformations. Translation.
Two-Dimensional Geometric Transformations ch5. 참조 Subjects : Basic Transformations Homogeneous Coordinates Composite Transformations Other Transformations.
Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.
Geometric Transformations
UW EXTENSION CERTIFICATE PROGRAM IN GAME DEVELOPMENT 2 ND QUARTER: ADVANCED GRAPHICS Math Review.
2D Geometric Transformation Translation A translation is applied to an object by repositioning it along a straight-line path from one coordinate location.
3D Geometric Transformation
CS559: Computer Graphics Lecture 9: 3D Transformation and Projection Li Zhang Spring 2010 Most slides borrowed from Yungyu ChuangYungyu Chuang.
Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.
Computer Graphics I, Fall 2010 Transformations.
Week 5 - Monday.  What did we talk about last time?  Lines and planes  Trigonometry  Transforms  Affine transforms  Rotation  Scaling  Shearing.
CS 325 Introduction to Computer Graphics 02 / 19 / 2010 Instructor: Michael Eckmann.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Transformations Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
REFERENCE: QUATERNIONS/ Ogre Transformations.
3D Geometry and Transformations
Modeling Transformation
Transformations. Modeling Transformations  Specify transformations for objects  Allows definitions of objects in own coordinate systems  Allows use.
Instructor: Dr. Shereen Aly Taie Basic Two-Dimensional Geometric Transformation 5.2 Matrix Representations and Homogeneous Coordinates 5.3 Inverse.
Transformations University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2016 Tamara Munzner.
Transforms.
3D Geometric Transformation
3. Transformation
Review: Transformations
Review: Transformations
Homogeneous Coordinates (Projective Space)
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University Transformations.
(c) University of Wisconsin, CS559
UMBC Graphics for Games
Transformations 고려대학교 컴퓨터 그래픽스 연구실 kucg.korea.ac.kr.
Presentation transcript:

1 Chapter 7 Geometric Transformation  3D transformations  3D affine transforms including translation, rotation, scaling, shearing, and reflections  Transformation matrices  Applying transforms in scene graphs  Composite transformations  Using transforms in constructing geometries

2 Transformations in 3D  Transformations are used to –define and manipulate objects –project from 3D to 2D  Different levels of abstraction –Matrix4d –Transform3D –TransformGroup

3 Types of Transformations  Affine transform maps lines to lines –preserves parallelism  Rigid motions (aka isometries, Euclidean motions) preserve shape  There are the same types of transformations in 3D as in 2D but they can be more complicated

4 Representing 3D Transformations  3D affine transformation  In homogeneous coordinates

5 Matrix Classes  Low-level representation for transformations  Matrix classes for 3x3 and 4x4 matrices for both float and double type Matrix3f Matrix3d Matrix4f Matrix4d  GMatrix can be used for matrices of arbitrary size, not necessarily square GMatrix

6 Matrix Operations  Update the current matrix (similar to compound assignment)‏ void add(Matrix4d m1)‏ void sub(Matrix4d m1)‏ void mul(Matrix4d m1)‏  Combine two MatrixObjects and put result into current Matrix void add(Matrix4d m1, Matrix4d m2)‏ void sub(Matrix4d m1, Matrix4d m2)‏ void mul(Matrix4d m1, Matrix4d m2)‏

7 Matrix Operations  Matrix times its inverse gives identity matrix void invert()‏ void invert(Matrix4d m1)‏  Exchange rows and columns void transpose()‏  Multiply all elements by the same value void mul(double scalar)‏  Determinant as a scalar value associated with a matrix (sort of like the magnitude of a vector)‏ double determinant()‏

8 Transform3D  A higher-level representation for transformations  Has constructors to create from both Matrix objects and from vectors  Also has set and get methods for the internal 4 x 4 matrix  Can also set a particular type of transformation

9 Translation in 3D  Translation can be specified by a vector which becomes the fourth column of the transformation matrix void set(Vector3d trans)‏ void set(Vector3f trans)‏ void setTranslation(Vector3d trans)‏ void setTranslation(Vector3f trans)‏

10 Scaling in 3D  Can scale the entire object uniformly by specifying a single scale factor void set(double scale)‏ void setScale(double scale)‏  Can scale the object non- uniformly by specifying a vector with a scale factor for each direction void setScale(Vector3d scales)‏

11 Reflection in 3D  In 3D, reflection is performed into a plane  Reflection of plane through origin with normal vector u can be expressed as –vector equation  Matrix representation: –inverse is same matrix

12 Shear in 3D  In 3D, shear along a plane  Can affect a single coordinate x ' = x + sh x z  or two coordinates x ' = x + sh x z y ' = y + sh y z

13 3D Rotation  In 3D, can rotate about an arbitrary line –hard to come up with a matrix for an arbitrary rotation  AxisAngle4d allows you to specify the line to rotate about – AxisAngle4d( x, y, z, q) represents rotation by angle  about the vector (x, y, z)‏  Set a general rotation in Transform3D using AxisAngle4d void set(AxisAngle4d r)‏

14 Quaternions  Quaternions provide an extension of complex numbers –instead of two values, a quaternion has 4  An arbitrary quaternion has the form p = A + b i + c j + d k  i, j and k satisfy i 2 = j 2 = k 2 = ijk = -1  Tuple operations plus conjugate and inverse

15 Quaternions for Rotation  A point represented as a pure quaternion –no real part p = x i + y j + z k  A rotation defined by quaternion operations –θ is the angle of rotation and u defines the axis of rotation through the origin

16 Euler Angles  Another way to think about rotations in 3D  Use three rotations about the coordinate axes –elevation, azimuth, tilt –roll, pitch, yaw –precession, nutation, spin –heading, altitude, bank  Transform3D method void setEuler(Vector3d eulerAngles)‏

17 Quaternion to Euler Angle  No Transform3D method for retrieving Euler angles  Compute them from the quaternion public static Vector3d quatToEuler(Quat4d q1) { double sqw = q1.w*q1.w; double sqx = q1.x*q1.x; double sqy = q1.y*q1.y; double sqz = q1.z*q1.z; double heading = Math.atan2(2.0 * (q1.x*q1.y + q1.z*q1.w), (sqx - sqy - sqz + sqw)); double bank = Math.atan2(2.0 * (q1.y*q1.z + q1.x*q1.w), (-sqx - sqy + sqz + sqw)); double attitude = Math.asin(-2.0 * (q1.x*q1.z - q1.y*q1.w)); return new Vector3d(bank, attitude, heading); }

10/17/08 TestTransform.java  Use this to explore different transformations –Enter a transformation matrix and see what it does –Enter data for particular kind of transformation and see what it does

10/17/08 Transform3D Node  Within a SceneGraph, a TransformGroup node implements a transformation that is applied to all of its children  This allows us to build hierarchical scenes

20 Scene Graph for Axes class

10/17/08 Rotation.java  Create ColorCubes  Use a series of rotation transformations to position the cubes uniformly in a ring around an axis

22 Composite Transforms  Composition of T 1 and T 2 is (T 2 T 1 )(P) = (T 2 ( T 1 (P) ) )‏  Order matters –The first transformation to be applied is the second in the list T 2 T 1 != T 1 T 2

10/17/08 A Common Pattern  Arbitrary transformations are hard to write matrices for –Rotation about an arbitrary axis –Reflection into an arbitrary plane  Solution: T -1 RT –Translate the scene so that the desired operation is trivial to write down –Do the desired transfromation –Translate back after the transformation

10/17/08 Example 1  Rotation about an arbitrary axis –  / 3 rotation about line through (1,1,0) and (1,2,1)‏  Translate by (-1, -1, 0) so first point goes through origin  Use a quaternion to specify the rotation  Translate by (1, 1, 0) to get back to original position

10/17/08 Example 2: Mirror.java  Reflection into an arbitrary plane a x + b y + c z = 0  Solution –Rotate to map the plane into the x-y plane d = sqrt( a 2 + b 2 )‏ cos(  ) = c / sqrt( a 2 + b 2 + c 2 )‏ q = cos(  /2) + (b/d i - a/d j) sin (  /2)‏ –Reflection into x-y plane (z -> -z)‏ –Do inverse rotation to get back to original

26 Transform3D methods  Transform Point3D objects void transform(Point3d p)‏ void transform(Point3d p, Point3d pOut)‏ void transform(Point3f p)‏ void transform(Point3f p, Point3f pOut)‏  Transform Vectors void transform(Vector3d v)‏ void transform(Vector3d v, Vector3d vOut)‏ void transform(Vector3f v)‏ void transform(Vector3f v, Vector3f vOut)‏ void transform(Vector4d v)‏ void transform(Vector4d v, Vector4d vOut)‏ void transform(Vector4f v)‏ void transform(Vector4f v, Vector4f vOut)‏

27 Shape Construction by Extrusion  Extend a 2D shape to 3D –Get a PathIterator for the shape –Construct quadrilateral (or triangular) polygon mesh between successive points along the path –see extrudeShape.java for method that does this  Java3D provides a class to do this automatically to create Font3D objects –See Hello3D example from chapter 5

10/17/08 PathIterator  An interface that allows Shape objects to return an iterator to their sub-parts  Defines constants to represent the different types of path segments  Methods int currentSegment( double [] coordinates)‏ boolean isDone()‏ void next()‏ int getWindingRule()‏

29 Shape Construction by Rotation  Many shapes can be created by rotating a curve around an axis –create a polygon mesh between points at successive angles  Example: constructing a torus –See Torus.java, TestTorus.java

30 Transformation and Shared Branch