Transformations Dr. Amy Zhang.

Slides:



Advertisements
Similar presentations
Today Composing transformations 3D Transformations
Advertisements

Computer Graphics Lecture 4 Geometry & Transformations.
Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 51 Today’s class Geometric objects and transformations.
Math 1Hofstra University – CSC171A1 Modeling Objects by Polygonal Approximations Define volumetric objects in terms of surfaces patches that surround the.
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.
Modeling Objects by Polygonal Approximations
CS5500 Computer Graphics March 22, Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 Coordinate-Free Geometry When we learned simple.
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.
Computer Graphics (Fall 2005) COMS 4160, Lecture 2: Review of Basic Math
3D Graphics Goal: To produce 2D images of a mathematically described 3D environment Issues: –Describing the environment: Modeling (mostly later) –Computing.
2D Transformations. World Coordinates Translate Rotate Scale Viewport Transforms Hierarchical Model Transforms Putting it all together.
CS 450: Computer Graphics 2D TRANSFORMATIONS
Geometric Objects and Transformations Geometric Entities Representation vs. Reference System Geometric ADT (Abstract Data Types)
Foundations of Computer Graphics (Fall 2012) CS 184, Lecture 2: Review of Basic Math
COS 397 Computer Graphics Svetla Boytcheva AUBG, Spring 2013.
Transformations Aaron Bloomfield CS 445: Introduction to Graphics
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.
Graphics Graphics Korea University kucg.korea.ac.kr Transformations 고려대학교 컴퓨터 그래픽스 연구실.
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.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
Transformations Jehee Lee Seoul National University.
Week 5 - Wednesday.  What did we talk about last time?  Project 2  Normal transforms  Euler angles  Quaternions.
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.
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.
Introduction to Computer Graphics Geometric Transformations
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 OpenGL Transformations.
Geometric Transformations
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.
Computer Graphics Matrices
Learning Objectives Affine transformations Affine transformations Translation Translation Rotation Rotation Scaling Scaling Reflection Reflection Shear.
CS559: Computer Graphics Lecture 9: 3D Transformation and Projection Li Zhang Spring 2010 Most slides borrowed from Yungyu ChuangYungyu Chuang.
1 Geometric Transformations-II Modelling Transforms By Dr.Ureerat Suksawatchon.
Geometric Transformations. Transformations Linear transformations Rigid transformations Affine transformations Projective transformations T Global reference.
Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.
Computer Graphics I, Fall 2010 Transformations.
1 Geometric Transformations Modelling Transforms By Dr.Ureerat Suksawatchon.
CS 551 / 645: Introductory Computer Graphics Viewing Transforms.
CS 325 Introduction to Computer Graphics 02 / 19 / 2010 Instructor: Michael Eckmann.
4. Affine transformations. Reading Required:  Watt, Section 1.1. Further reading:  Foley, et al, Chapter  David F. Rogers and J. Alan Adams,
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
Modeling Transformation
Transformations. Modeling Transformations  Specify transformations for objects  Allows definitions of objects in own coordinate systems  Allows use.
Forward Projection Pipeline and Transformations CENG 477 Introduction to Computer Graphics.
CSE 167 [Win 17], Lecture 2: Review of Basic Math Ravi Ramamoorthi
Transforms.
3. Transformation
Review: Transformations
Introduction to Computer Graphics CS 445 / 645
Review: Transformations
Lecture 2 Transformations
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University Transformations.
Geometric Camera Models
(c) University of Wisconsin, CS559
Transformations 고려대학교 컴퓨터 그래픽스 연구실 kucg.korea.ac.kr.
Transformations in OpenGL
Geometric Objects and Transformations (II)
Presentation transcript:

Transformations Dr. Amy Zhang

Reading • Hill, Chapter 4, Section 4.5 • Hill, Chapter 5

Vectors and Points Recap Vectors, basis, frames, and points:

Geometric Transformations Functions to map points from one place to another Geometric transformations can be applied to: Drawing primitives (lines, triangles) Pixel coordinates of an image

Use of Transformations Map points from one coordinate system to points in another coordinate system Change the shape of objects Position objects in a scene Create multiple copies of objects in the scene Projection for virtual cameras Animations

Outline Matrix Algebra * Linear Transformations Multiple Transformations OpenGL Geometry Transformations

Matrices Matrix: An array of elements that follow certain rules. We use uppercase letters to indicate a matrix: A matrix that has n rows and m columns is said to be of order n x m. We always mention the numbers of rows first.

Square Matrices A matrix is square if the number of row equals the number of columns, i.e., if n = m. Common square matrices: Zero matrix: a square matrix with all 0’s. Identity matrix: all 0’s, except elements along the main diagonal which are 1’s. The diagonal of a square matrix:

Row and Column Vectors A 1 x n matrix is called a row vector. A n x 1 matrix is called a column vector. We will use lower case bold letters to indicate vectors. In graphics (and in this class) we mostly use column vectors.

Transpose of a Matrix The transpose of A is written as AT. AT is formed by interchanging rows and columns of matrix A. The transpose of a row vector is a column vector.

Addition and Subtraction Addition and subtraction of matrices is defined by addition and subtraction of their corresponding elements. Note: We can only add / subtract matrices of the same order.

Multiplication by a Scalar To multiply a matrix by a scalar, we multiply each element of the matrix by the number. Examples:

Matrix x Vector Multiplication If v is a column vector, M goes on the left: If v is a row vector, MT goes to the right: We will use column vectors.

Matrix x Column Vector We say the column vector v is pre‐multiplied by M. The number of rows in M is equal to the number of elements in v.

Matrix x Column Vector The product Mv is a linear combination of the columns:

Examples Compute the matrix‐vector product:

Matrix Multiplication Just apply matrix‐vector multiplication a few times. Remember: the new vector ( ) is a linear combination of columns.

Just apply matrix‐vector multiplication a few times.

Just apply matrix‐vector multiplication a few times.

Matrix Multiplication Examples:

Properties of Matrix Multiplication (AB) C = A (BC) A (B + C) = AB + AC A (sB) = sAB, where s is a scalar. (AB)T = BT AT But: Example:

Outline Matrix Algebra Linear Transformations Multiple Transformations OpenGL Geometry Transformations The Viewing Transformation

Linear Transformations A linear transformation L of vectors is just a mapping from v to L(v) that satisfies the following properties: We can use matrices to express linear transformations of points:

Notational Convention Consider the point P in frame We will use M to mean “transformed” The point is transformed with respect to the basis that appears immediately to the left of the transformation

Translations glTranslatef(dx, dy, dz);

Translations We have already see how points can be displaced: For every translation, there exists an inverse function which undoes the translation: There also exists a special translation, called the identity, that leaves every point unchanged:

Groups and Composition For translations: There exists an inverse mapping for each function There exists an identity mapping When these conditions are met by any class of functions, that class is closed under composition i.e., any series of translations can be composed to a single translation with matrix multiplication Mathematically speaking, translations form an algebraic group

Rotations Rotation about the origin glRotatef(theta, vx, vy, vz); theta in degrees, (vx, vy, vz) define axis of rotation

Rotations Counter‐clockwise rotation by about the z-axis: Rotation about the x- and y-axis:

Orthonormal Matrices The rotation matrix M has certain properties: The norm of each row/column is one: The rows/columns are orthogonal: We say that rotation matrices are orthonormal. The inverse of an orthonormal matrix is its transpose

Rotation about an Axis • Rotation about an arbitrary unit vector k = [kx, ky, kz] (Rodrigues Formula):

Rigid Body Transformations The union of translation and rotation functions defines the Euclidean group, also known as rigid body transformations Properties of rigid body transformations: They preserve distances They preserve angles

Scaling Scaling about the origin: glScalef( sx, sy, sz); Each vertex is moved: sx times farther from the origin in x‐direction sy times farther from the origin in y‐direction sz times farther from the origin in z‐direction

Uniform Scaling Uniform scaling by:

Reflection about X and Y Reflection about x-axis: Reflection about y-axis: Reflection about x- and y-axis:

Similarity Transformations Add reflections and uniform scaling to the rigid body transformations Properties of similarity transformations: Angles are preserved Distances between points are changed by a fixed ratio Maintains a “similar” shape (similar triangles, circles map to circles, etc.)

Non‐Uniform Scaling An unbalanced scaling distorts shape:

Skews or Shears Along x: Along y: Shears matrices have a determinant of 1: The area of the sheared figure stays the same.

3D Shears Shears along different planes: along y-z plane, along x-z plane, along x-y plane Shears parallel to different axis: along x-axis, along y-axis, along z-axis

No OpenGL statement: we can load and multiply by arbitrary matrices glLoadMatrixf(m) glMultMatrixf(m) The matrix m is a one dimension array of 16 elements which are the components of the desired 4 x 4 matrix stored by columns In glMultMatrixf, m multiplies the existing matrix on the right

Matrix Stacks In many situations we want to save transformation matrices for use later Traversing hierarchical data structures Avoiding state changes when executing display lists OpenGL maintains stacks for each type of matrix Access present type (as set by glMatrixMode) by glPushMatrix() glPopMatrix()

Affine Transformations Affine transformations add non-uniform scales and shears to the similarity transformations Properties of affine transformations: They preserve our selected plane (sometimes called the affine plane) They preserve parallel lines Affine transformations are what we will mostly deal with Are there other linear transformations?

Projective Transformation The most general linear transformation that can be applied to 2D points There is something different about this group of Transformations

Types of Transformations Rigid Body (preserve distances) Translation and rotations Similarity (preserve angles) Reflections Uniform scale Affine (preserve parallel lines) Non-uniform scales Shears Projective (lines remain lines) Non-linear (lines become curves) Twists, bends, warps, morphs, ...

Outline Matrix Algebra Linear Transformations Multiple Transformations OpenGL Geometry Transformations

Multiple Transformations It is quite frequent that we want to apply more than one transformation. Example: Translate by vector t. Rotate by  degrees about the origin. If we call these transformations T and R, and the resulting transformation Q, we get:

Combined Matrix Expression Each transformation is expressed in matrix form: We can compute the combined matrix as follows: The matrices appear in reverse order of how the transformations are applied

Matrix Multiplication The new, combined matrix is: Again: This means we are performing the translation with MT first, followed by the rotation with MR The order matters AB is unequal to BA

The Order Matters

2D Rotation about a Point Translate by t = [‐h, ‐k] Rotate CCW around origin by  . Translate by t’ = [h, k]

2D Rotation about a Point Writing the composite matrix:

Two Points of View Each step is a change of coordinates: Each step is a change of frames:

Outline Appendix: Matrix Algebra Linear Transformations Multiple Transformations OpenGL Geometry Transformations

Scenes, Actors, Cameras Use an analogy to classical theatre or photography Virtual world is called a scene We call objects in the scene actors A camera specifies our viewing position and certain viewing parameters (focal length, image size, etc.) Use 3D affine transformations to position and move actors and cameras in the scene

The Scene

World, Object, Camera Frames Use the global world coordinates   to place actors and cameras within the scene Define points (vertices) of objects in some convenient local object coordinates oT  Define eye / camera coordinates  for the camera There could be more than one camera in the scene

OpenGL Coordinate Spaces These coordinate spaces are connected by transformations as follows:

Modeling Transformation The modeling transformation orients / places objects within the world space

Viewing Transformation The viewing transformation maps points from world space into eye space

Projection Transformation The projection transformation maps the viewing frustum to clip space, a cube that extends from -1 to 1 in x, y, and z

OpenGL Coordinate Spaces Eye World Screen (3D) Clip

Why does OpenGL do this? Normalization allows for a single pipeline for both perspective and orthogonal viewing We stay in four dimensional homogeneous coordinates as long as possible to retain three dimensional information needed for hidden‐surface removal and shading We simplify clipping

Transforming Normals Or: What happens to normals under affine transformations? The normal to a surface is a vector that is orthogonal to the tangent plane. The tangent plane is the plane of vectors that are defined by subtracting nearby surface points. Or:

Transforming Normals Suppose we transform all points with the affine matrix A. What vector remains orthogonal to the tangent vector? Or:

Transforming Normals So the coordinates of the normal are transformed using the inverse transpose of the affine matrix A If A is a rotation, then the inverse transpose is the same matrix A If A is a diagonal matrix (non-uniform or uniform scaling), then its inverse transpose is the same as its inverse A-1 In OpenGL, we simply transform the normals with the inverse transpose of the modelview matrix

The end Questions and answers