Transforms 1 Christian Miller CS Fall 2011

Similar documents
Computer Graphics Hands-on

3D Viewing Episode 2

Computer Graphics Geometric Transformations

Describe the Orthographic and Perspective projections. How do we combine together transform matrices?

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

Graphics pipeline and transformations. Composition of transformations

CS 428: Fall Introduction to. Transformations in OpenGL + hierarchical modeling. Andrew Nealen, Rutgers, /21/2009 1

2D/3D Geometric Transformations and Scene Graphs

Affine Transformations in 3D

COMP3421. Week 2 - Transformations in 2D and Vector Geometry Revision

6.837 Computer Graphics Hierarchical Modeling Wojciech Matusik, MIT EECS Some slides from BarbCutler & Jaakko Lehtinen

Linear and Affine Transformations Coordinate Systems

Chapter 3 - Basic Mathematics for 3D Computer Graphics

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

CS 4204 Computer Graphics

Review of Thursday. xa + yb xc + yd

CT5510: Computer Graphics. Transformation BOCHANG MOON

Two possible ways to specify transformations. Each part of the object is transformed independently relative to the origin

CS4202: Test. 1. Write the letter corresponding to the library name next to the statement or statements that describe library.

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

TIEA311 Tietokonegrafiikan perusteet kevät 2018

E.Order of Operations

COMP 175 COMPUTER GRAPHICS. Lecture 07: Scene Graph. COMP 175: Computer Graphics March 10, Remco Chang 07 Scene Graph

Fachhochschule Regensburg, Germany, February 15, 2017

Using GLU/GLUT Objects

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

Hierarchical Modelling

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

COMP3421. Week 2 - Transformations in 2D and Vector Geometry Revision

EECE 478. Learning Objectives. Learning Objectives. Linear Algebra and 3D Geometry. Linear algebra in 3D. Coordinate systems

GEOMETRIC TRANSFORMATIONS AND VIEWING

Transforms. COMP 575/770 Spring 2013

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

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

Spring 2013, CS 112 Programming Assignment 2 Submission Due: April 26, 2013

Notes on Assignment. Notes on Assignment. Notes on Assignment. Notes on Assignment

Hierarchical Modeling

Reading. Hierarchical Modeling. Symbols and instances. Required: Angel, sections , 9.8. Optional:

Hierarchical Modeling and scene graphs

Computer Graphics. Chapter 5 Geometric Transformations. Somsak Walairacht, Computer Engineering, KMITL

Hierarchy I. Guoying Zhao 1 / 40

CS380: Computer Graphics 2D Imaging and Transformation. Sung-Eui Yoon ( 윤성의 ) Course URL:

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

Where We Are: Static Models

Advanced Computer Graphics Transformations. Matthias Teschner

Lecture 4. Viewing, Projection and Viewport Transformations

Mouse Ray Picking Explained

Computer Graphics (CS 543) Lecture 6a: Hierarchical 3D Models. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

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

Vector Algebra Transformations. Lecture 4

Hierarchical Modeling and Scene Graphs

Linear transformations Affine transformations Transformations in 3D. Graphics 2009/2010, period 1. Lecture 5: linear and affine transformations

Fall CSCI 420: Computer Graphics. 2.2 Transformations. Hao Li.

3D Viewing Episode 2

Hierarchical Modeling and Scene Graphs

Geometric Transformations

The Viewing Pipeline adaptation of Paul Bunn & Kerryn Hugo s notes

CSE528 Computer Graphics: Theory, Algorithms, and Applications

Computer Graphics Hands-on

CS 559 Computer Graphics Midterm Exam March 22, :30-3:45 pm

(Refer Slide Time: 00:04:20)

HIERARCHICAL TRANSFORMATIONS A Practical Introduction

Introduction to OpenGL

Computer Viewing. CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science

Overview. By end of the week:

Viewing and Projection

CSC 470 Computer Graphics

CSE 690: GPGPU. Lecture 2: Understanding the Fabric - Intro to Graphics. Klaus Mueller Stony Brook University Computer Science Department

3.1 Viewing and Projection

Rendering Pipeline and Coordinates Transforms

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

CS559: Computer Graphics

CSE328 Fundamentals of Computer Graphics

Modeling with Transformations

GRAFIKA KOMPUTER. ~ M. Ali Fauzi

Transformations. Rotation and Scaling

OpenGL: Setup 3D World

CIS 636 Interactive Computer Graphics CIS 736 Computer Graphics Spring 2011

Prof. Feng Liu. Fall /19/2016

Transformations. CSCI 420 Computer Graphics Lecture 4

Lecture 5 2D Transformation

Viewing and Projection

Viewing and Projection

You will have the entire period (until 9:00pm) to complete the exam, although the exam is designed to take less time.

Surface Graphics. 200 polys 1,000 polys 15,000 polys. an empty foot. - a mesh of spline patches:

Computer Vision Projective Geometry and Calibration. Pinhole cameras

OpenGL Transformations

Something noteworthy

API for creating a display window and using keyboard/mouse interations. See RayWindow.cpp to see how these are used for Assignment3

Graphics and Visualization

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

Lecture 5b. Transformation

COMP3421. Introduction to 3D Graphics

Lecture 5: Viewing. CSE Computer Graphics (Fall 2010)

3D Geometry and Camera Calibration

GL_MODELVIEW transformation

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

Chapter 2 - Basic Mathematics for 3D Computer Graphics

2D and 3D Transformations AUI Course Denbigh Starkey

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

Transcription:

Transforms 1 Christian Miller CS 354 - Fall 2011

Transformations What happens if you multiply a square matrix and a vector together? You get a different vector with the same number of coordinates These are linear transformations

Scaling Stretches each of the coordinates by a factor alpha Origin stays unchanged

Reflection α = < -1, 1 > α = < 1, 1 > α = < -1, -1 > α = < 1, -1 > Just scaling with negative values Flips over the origin

Rotation Rotates CCW around the chosen axis Also through the origin

Rotation

Shear Stretches one dimension at an angle Not very useful

Translation Everything you can do with 3x3 matrices happens around the origin How do we just move something around?

Homogeneous coordinates We go up to 4D Add a w coordinate to each point / vector Add an additional row and column to matrices (It s actually 3D projective space, but uses 4 coordinates)

Homogeneous points and vectors Points have w = 1 Vectors have w = 0

Translation v Use the extra coordinates to perform translation Vectors are unaffected by translation

Homogeneous matrices Can take existing transformation matrices, and extend them with the identity to get 4x4 versions

Rotation through a point Translate to origin, rotate, translate back Multiply the transform matrices together

Inverse shortcuts Scale: replace α with 1/α Rotate: inverse is the transpose Shear: I don t even remember Translation: replace v with -v Composite transforms: recall

General transforms Multiplying transforms makes them harder to read This is the general form of a 3D affine transform R: rotational / scaling part (3x3) t: translational part (3x1)

Transforming normals Normals get distorted when scaled Must use the inverse transpose of a transform

Note on coordinates We ll use 4x1 vectors and 4x4 matrices from here on What about that last row? (always 0, 0, 0, 1) Required to keep w coordinate intact Changes when perspective is brought in

Change of coordinates A matrix transforms coordinates from one frame to another The final coordinate frame is called the world or spatial frame A coordinate frame attached to an object is called a local frame

Change of coordinates Point in world frame Point in local frame Positioning of local frame relative to world frame

Change of coordinates v = < 0.6, 0.6 > v = < 1.1, 2.1 > Local frame World frame

Change of coordinates v = < 0.6, 0.6 > v = < 1.1, 2.1 > Local frame World frame

Change of coordinates v = < 0.6, 0.6 > v = < 1.1, 2.1 > Local frame World frame

Change of coordinates v = < 0.6, 0.6 > v = < 1.1, 2.1 > Local frame World frame

Change of coordinates v = < 0.6, 0.6 > v = < 1.1, 2.1 > Local frame World frame

Direct specification v u M p w Local World A coordinate frame is just a point and 3 vectors Write the coordinates of a new frame relative to the world frame into a matrix, and you have a transformation

Inverse The inverse of a transform does the opposite Converts world frame coordinates to local

Composing transforms Matrices can be multiplied together If you multiply several transform matrices together, the result has the same effect as doing them all separately

Composing transforms Matrix multiplication is non-commutative The order in which you apply transforms is crucial

Intuition There are two ways to interpret what sequences of transforms do: forwards and backwards Both methods yield the same results Use whichever one is more intuitive for a given problem We ll use translate / rotate / scale as an example

What we want Local World Use translate, rotate, scale to get this result

Forwards Multiply new transforms on the right of the previous one Every transform is specified in the local coordinate system of the previous one Imagine that you re carrying the local frame along as you stack up transformations

Forwards: M = T Translate first to target location

Forwards: M = TR Rotate next, which happens relative to the already translated frame

Forwards: M = TRS Then scale, which happens with respect to the already translated and rotated frame

Backwards Multiply new transforms on the left of the previous one Every transform is specified with respect to the world frame, regardless of what has already been done Imagine that you re discarding the local frame and reusing to the world frame after every transform

Scale first Backwards: M = S

Backwards: M = RS Rotate next

Backwards: M = TRS Finally, translate to the final location

Intuition We got the same result (M = TRS) each time It s important to be able to interpret transforms in both ways! If you re having trouble coming up with a transform, try using the other method

Scene graph A scene graph is how anything with a position and orientation is stored in graphics software A hierarchical tree of transformations, rooted at the world frame Transforms for objects are multiplied together (on the right) traversing down the tree

Scene graph World Knight Dragon Torso Leg1 Leg2 Leg1 Leg4 Arm1 Arm2 Leg2 Leg3 Sword Shield Damsel

Scene graph Rendering implemented with a matrix stack Do a depth-first traversal of the tree Enter node: push matrix and apply transform Render object Traverse children Exit node: pop matrix

OpenGL: ordering OpenGL uses the forward method Calling glrotate, gltranslate, etc. multiplies the new transform onto the right of the old E.g.: M = MX

OpenGL: matrix stack glpushmatrix() and glpopmatrix() will do the respective operation on the matrix stack Objects are rendered using the top matrix Push will copy the existing top matrix Use to implement scene graphs

OpenGL: matrix funcs glloadidentity(): replaces current M with I glloadmatrix(): loads a given matrix into M glmultmatrix(): multiplies a given matrix onto the right of M

But watch out OpenGL stores matrices in column-major order Normal C multidimensional arrays are row-major You may have to transpose matrices before handing them off to OpenGL

One last thing Look up glulookat()