CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University Transformations.

Slides:



Advertisements
Similar presentations
Today Composing transformations 3D Transformations
Advertisements

Computer Graphics Lecture 4 Geometry & Transformations.
Linear Algebra and SVD (Some slides adapted from Octavia Camps)
2/7/2001Hofstra University – CSC290B1 Review: Math (Ch 4)
Elementary 3D Transformations - a "Graphics Engine" Transformation procedures Transformations of coordinate systems Translation Scaling Rotation.
1 CSCE 441 Computer Graphics: 2D Transformations Jinxiang Chai.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Representation Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
©College of Computer and Information Science, Northeastern UniversityJune 26, CS U540 Computer Graphics Prof. Harriet Fell Spring 2009 Lecture 11.
Representation CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
2D Transformations x y x y x y. 2D Transformation Given a 2D object, transformation is to change the object’s Position (translation) Size (scaling) Orientation.
2D Transformations Unit - 3. Why Transformations? In graphics, once we have an object described, transformations are used to move that object, scale it.
3D Graphics Goal: To produce 2D images of a mathematically described 3D environment Issues: –Describing the environment: Modeling (mostly later) –Computing.
CS 450: Computer Graphics 2D TRANSFORMATIONS
Geometric Objects and Transformations Geometric Entities Representation vs. Reference System Geometric ADT (Abstract Data Types)
CS 480/680 Computer Graphics Representation Dr. Frederick C Harris, Jr. Fall 2012.
Geometric Transformation. So far…. We have been discussing the basic elements of geometric programming. We have discussed points, vectors and their operations.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Transformations Dr. Amy Zhang.
CS 480/680 Computer Graphics Transformations Dr. Frederick C Harris, Jr.
Graphics Graphics Korea University kucg.korea.ac.kr Transformations 고려대학교 컴퓨터 그래픽스 연구실.
Lecture Notes: Computer Graphics.
Geometric Transformations Jehee Lee Seoul National University.
Transformations Jehee Lee Seoul National University.
CS 376 Introduction to Computer Graphics 02 / 16 / 2007 Instructor: Michael Eckmann.
Geometric Objects and Transformation
1 Computer Graphics Week9 -3D Geometric Transformation.
16/5/ :47 UML Computer Graphics Conceptual Model Application Model Application Program Graphics System Output Devices Input Devices API Function.
CSE Real Time Rendering Week 5. Slides(Some) Courtesy – E. Angel and D. Shreiner.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Affine Transformation. Affine Transformations In this lecture, we will continue with the discussion of the remaining affine transformations and composite.
Geometric Transformations Sang Il Park Sejong University Many slides come from Jehee Lee’s.
Affine Geometry.
1 Representation. 2 Objectives Introduce concepts such as dimension and basis Introduce coordinate systems for representing vectors spaces and frames.
Learning Objectives Affine transformations Affine transformations Translation Translation Rotation Rotation Scaling Scaling Reflection Reflection Shear.
Geometric Transformations. Transformations Linear transformations Rigid transformations Affine transformations Projective transformations T Global reference.
Computer Graphics I, Fall 2010 Transformations.
1 Geometric Transformations Modelling Transforms By Dr.Ureerat Suksawatchon.
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
CSCE 441 Computer Graphics: 2D Transformations
Modeling Transformation
Transformations. Modeling Transformations  Specify transformations for objects  Allows definitions of objects in own coordinate systems  Allows use.
Objectives Introduce standard transformations Introduce standard transformations Derive homogeneous coordinate transformation matrices Derive homogeneous.
Computer Graphics 2D Transformations
CSE 167 [Win 17], Lecture 3: Transformations 1 Ravi Ramamoorthi
CPSC 641: Computer Graphics Rotation Representation and Interpolation
Geometric Transformations
Transformations Objectives
Geometric Transformations Hearn & Baker Chapter 5
Computer Graphics CC416 Week 15 3D Graphics.
Computer Graphics Transformations.
2D Transformations with Matrices
Review: Transformations
3D Geometric Transformations
Computer Graphics Transformations.
3D Transformations Source & Courtesy: University of Wisconsin,
Introduction to Computer Graphics CS 445 / 645
Review: Transformations
Computer Graphics Transformations
Lecture 2 Transformations
COMP 175: Computer Graphics February 9, 2016
Computer Graphics Imaging
Transformations 3 University of British Columbia
Lecture 6 and 7 Transformations
(c) University of Wisconsin, CS559
2D Geometric Transformations
Transformations 고려대학교 컴퓨터 그래픽스 연구실 kucg.korea.ac.kr.
Geometric Objects and Transformations (II)
Advanced Graphics Algorithms Ying Zhu Georgia State University
TWO DIMENSIONAL TRANSFORMATION
Presentation transcript:

CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University Transformations

Outline 3D transformations Concatenation of transformations Transformations in OpenGL Anatomy of a simple OpenGL program

Coordinate systems Each point and vector is defined in reference to a coordinate system Once we fix the origin of the coordinate system, we can represent all points unambiguously The same point may have different 3D coordinates in different coordinate systems Remember that part of the job of 3D graphics pipeline is to convert vertices from model space to 2D window space Each vertex with go through several coordinate systems along the pipeline

Coordinate systems A 3D coordinate system is defined by its three base vectors (x, y, and z axis) Get familiar with OpenGL’s coordinate system

Geometric transformation In 3D graphics, animation is achieved by transforming geometric objects in the virtual world Transforming geometric objects means transforming points (vertices) and vectors Transformation of points and vectors can be conveniently achieved by matrix multiplications Introduced by Larry Roberts in 1966

Linear Algebra Review Matrix: An array of elements Vectors: A n x 1 matrix is called a column vector In computer graphics, vertex coordinates and vectors (directed line segments) and are represented by column vectors.

Linear Algebra Review Matrix-column vector multiplication

Linear Algebra Review Matrix-matrix multiplication V1 V2 V3

Linear Algebra Review Homogeneous representation A vertex coordinate representation has 1 as the 4th component. OpenGL uses homogeneous coordinates for all vertices. (x, y, z) => (x, y, z, 1) Why use homogeneous coordinates? So that all transformations can be defined by matrix multiplication.

Affine Matrix An affine matrix is a 4x4 matrix with last low [0 0 0 1] Why include the bottom row of (0,0,0,1)? It’ll be useful in perspective transforms. Affine matrix is used to define affine transformation.

Affine Transformation Any transformation preserving collinearity (i.e., all points lying on a line initially still lie on a line after transformation) ratios of distances (e.g., the midpoint of a line segment remains the midpoint after transformation). Affine transformations preserve parallel lines. We can transform vertices with affine transformation. Affine transformations are what we use all the time in computer graphics.

Other Transformations Isometry (preserves distance) Similarity (preserves angles) Collineation (lines remains lines) Perspective projections Non-linear (lines become curves) Twists, bends, etc. Can be used for deformation.

Elementary Affine Transformations Four elementary affine transformations Translation Scaling Rotation (about an axis) Shear Translation, scaling and rotation are the most commonly used transformations.

Translation Translation P’ P d x y

Scaling Scaling

Rotation Rotation about the origin Counter-clock wise rotation by 90 degree.

2D Transformation Summary Translation Scaling Rotation

Composition of Affine Transforms Most of the time we want to apply more than one transformation. Example: Translate by vector t Rotate by r degree about the origin This can be represented by multiple matrix multiplications:

Composition of Affine Transforms Matrix multiplication is associative: We can group the combined transformation as The affine matrices are applied right side first. We can also apply all the transformations to form a single matrix This called composing or concatenation of transforms. The result is another affine transformation.

Composition of Affine Transforms It is important to always remember that matrix multiplication is not commutative The order of transforms DOES matter E.g. scaling then rotating is usually different than rotating then scaling Keep this in mind when you write OpenGL program – you need to know in which order your OpenGL transform calls are executed

Decomposition of Affine Transforms Any affine transform can be decomposed into the product of a rotation, a scale, and a rotation.

Coordinate Transformations We have discussed how to use transformation matrices to move points around We can also think of them as simply changing the coordinate system in which the point is presented The origin of the coordinate system is transformed but the relative position of the point is unchanged In different contexts, either interpretation may be more suitable.

Why use matrix formalisms? Can’t I just hardcode transforms rather than use the matrix multiplication? Yes. But it’s harder to derive, harder to debug, and not any more efficient All current graphics APIs use this matrix formalism Must understand this to use OpenGL or other graphics libraries

3D Affine Transformations 3D affine transformations are an extension of the 2D transformations. Use 4x4 matrices instead of 3x3 matrices in 2D transformations. For example 3D scaling

3D Translation 3D translation matrix OpenGL function: glTranslatef(tx, ty, tz)

3D Scaling 3D scaling matrix OpenGL Function: glScalef(Sx, Sy, Sz)

3D Rotation About the Origin 3D rotation is more complicated than 2D rotation. Rotation about X axis Rotation about Y axis Rotation about Z axis

Arbitrary 3D Rotations Normal practice is to decompose an arbitrary 3D rotation into rotations about x, y, z axes. Create a single transformation matrix by composing.

Rotation in OpenGL (GLfloat angle, GLfloat x, GLfloat y, GLfloat z) Equivalent to multiplying the following matrix

Rotation in OpenGL Rotations are specified by a rotation axis and an angle Normal practice is to decompose an arbitrary 3D rotation into rotations about x, y, z axes Achieved by 3 glRotatef() calls

Rotation About a Fixed Point The order is important: Translate to the origin Rotate about the origin Translate back Example: To rotate by r about z around

Quaternions A quaternion is a 4-tuple of real numbers [s,x,y,z] or [s,v], s is a scalar and v is a three-dimensional vector. Quaternions provide an alternative for describing and manipulating rotations. Quaternions are more efficient than rotation matrices Can be interpolated to obtain smooth sequence of rotations for animation You can convert between a transformation matrix and a quaternion

Multiple 3D Transformations By combining a scaling, rotation, and a translation matrix we get a single transformation matrix. Notice that in the single matrix, translation is separated from scaling and rotation part. We can think of an affine matrix as having a scaling-rotation part and a translation part. If a transformation consists of only translations and rotations, then it’s called a rigid-body transformation.

Transformations in OpenGL Internally each vertex in OpenGL is represented as homogeneous points i.e. a column vector with 1 as the last item. However you don’t need to specify the 1 in your program Each vertex is transformed by the modelview matrix. There is always a current modelview matrix that is applied to all vertices.

Model-view Matrix

Transformation in OpenGL It is important to understand the relationship among Current modelview matrix, Vertices of 3D Object So you can understand why OpenGL code has to be arranged in certain way

What happens inside OpenGL during transformation? Final modelview matrix Matrices are often created dynamically by the OpenGL program. Matrix multiplications are performed in vertex shaders. Vertex coordinates before transformation Vertex coordinates after transformation

Summary Affine transformations are used for transforming 3D objects. Three elementary affine transformations: Translation Scaling Rotation 3D rotation is the most complicated among the three. If we use homogeneous coordinates, then all affine transformations can be represented by affine matrix multiplication. Notice the pattern of transformation in OpenGL programming.

OpenGL Tutorial Programs Download OpenGL transformation tutorial program from http://www.xmission.com/~nate/tutors.html