3-D Transformations Kurt Akeley CS248 Lecture 8 18 October 2007

Slides:



Advertisements
Similar presentations
Today Composing transformations 3D Transformations
Advertisements

Computer Graphics 2D & 3D Transformation.
Using GLU/GLUT Objects GLU/GLUT provides very simple object primitives glutWireCube glutWireCone gluCylinder glutWireTeapot.
CLASS 4 CS770/870. Translation Scale Multiplying Matrices. The R C rule What happens when we do two translates? What happens when we do two scales?
Graphics Pipeline.
2 COEN Computer Graphics I Evening’s Goals n Discuss the fundamentals of lighting in computer graphics n Analyze OpenGL’s lighting model n Show.
Computer Graphic Creator: Mohsen Asghari Session 2 Fall 2014.
CMPE 466 COMPUTER GRAPHICS
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Transformations II Week.
Shading in OpenGL CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
Based on slides created by Edward Angel
Shading in OpenGL Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Transformations Objectives Understand how transformations work in 2D and 3D Understand the concept of homogenous coordinate system Understand scene graphs.
Objectives Learn to build arbitrary transformation matrices from simple transformations Learn to build arbitrary transformation matrices from simple transformations.
Viewing and Perspective Kurt Akeley CS248 Lecture 9 23 October 2007
OpenGL (II). How to Draw a 3-D object on Screen?
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)
COMP 175: Computer Graphics March 10, 2015
Transformations Aaron Bloomfield CS 445: Introduction to Graphics
Basic Graphics Concepts Day One CSCI 440. Terminology object - the thing being modeled image - view of object(s) on the screen frame buffer - memory that.
Geometric Transformation. So far…. We have been discussing the basic elements of geometric programming. We have discussed points, vectors and their operations.
Shading in OpenGL.
Transformations Dr. Amy Zhang.
TWO DIMENSIONAL GEOMETRIC TRANSFORMATIONS CA 302 Computer Graphics and Visual Programming Aydın Öztürk
The Viewing Pipeline (Chapter 4) 5/26/ Overview OpenGL viewing pipeline: OpenGL viewing pipeline: – Modelview matrix – Projection matrix Parallel.
2D Transformations.
Geometric Transformations Jehee Lee Seoul National University.
Image Synthesis Rabie A. Ramadan, PhD 2. 2 Java OpenGL Using JOGL: Using JOGL: Wiki: You can download JOGL from.
Data Structures for Scenes, The Basics of Scene Graphs Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Friday,
Computer Graphics I, Fall 2010 Shading in OpenGL.
Foundations of Computer Graphics (Fall 2012) CS 184, Lectures 13,14: Reviews Transforms, OpenGL
CS559: Computer Graphics Lecture 15: Hierarchical Modeling and Shading Li Zhang Spring 2008.
Foundations of Computer Graphics (Fall 2012) CS 184, Lecture 4: Transformations 2
CS 445 / 645: Introductory Computer Graphics Light.
10/3/02 (c) 2002 University of Wisconsin, CS 559 Last Time 2D Coordinate systems and transformations.
Computer Graphics I, Fall 2010 Computer Viewing.
16/5/ :47 UML Computer Graphics Conceptual Model Application Model Application Program Graphics System Output Devices Input Devices API Function.
OpenGL: Introduction Yanci Zhang Game Programming Practice.
Shading in OpenGL Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E.
1/50 CS148: Introduction to Computer Graphics and Imaging Transforms CS148: Introduction to Computer Graphics and Imaging Transforms.
2 COEN Computer Graphics I Evening’s Goals n Discuss viewing and modeling transformations n Describe matrix stacks and their uses n Show basic geometric.
3D Transformations. Translation x’ = x + tx y’ = y + ty z’ = z + tz P = P’ = T = P’ = T. P tx ty tz xyz1xyz1 x’ y’ z’ 1 x y.
Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Chapters 5 2 March Classical & Computer Viewing Same elements –objects –viewer –projectors –projection plane.
12/24/2015 A.Aruna/Assistant professor/IT/SNSCE 1.
Lecture 5: Introduction to 3D
CS552: Computer Graphics Lecture 4: 2D Graphics. Recap 2D Graphics Coordinate systems 2D Transformations o Translation o Scaling o Rotation Combining.
CS5500 Computer Graphics April 23, Today’s Topic Details of the front-end of the 3D pipeline: –How to construct the viewing matrix? –How to construct.
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.
Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.
Some Notes on 3-D Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Friday, October 24, 2003.
CS5500 Computer Graphics March 20, Computer Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts.
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
CSCE 441: Computer Graphics: Hierarchical Models Jinxiang Chai.
Transformation Example. Order of Transformation Matters Scale, translate Scale, translate Translate scale Translate scale Rotate, Translate Rotate, Translate.
OpenGL LAB III.
4. Geometric Objects and Transformations
Modeling Transformations Mario Costa Sousa University of Calgary CPSC 453, Fall 2001 Mario Costa Sousa University of Calgary CPSC 453, Fall 2001.
Introduction to 3-D Viewing Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 27, 2003.
Summary of Properties of 3D Affine Transformations
Geometric Transformations
Projection in 3-D Glenn G. Chappell
Geometric Transformations
Geometric Objects and Transformations (II)
Geometric Transformations
Presentation transcript:

3-D Transformations Kurt Akeley CS248 Lecture 8 18 October

CS248 Lecture 8Kurt Akeley, Fall 2007 Overview Tuesday n 2-D transformation n Composition of 2-D transformations n Line equations, 2-D normals, and inverses Today n Apply 2-D concepts to 3-D n Look at OpenGL in some detail

CS248 Lecture 8Kurt Akeley, Fall 2007 Homogeneous 3-D coordinates

CS248 Lecture 8Kurt Akeley, Fall 2007 Homogeneous 3-D transformation Specify translation Specify rotation, scale, and shear (Almost) always have these values

CS248 Lecture 8Kurt Akeley, Fall 2007 Homogeneous translation and scale Translation: Scaling (about the origin):

CS248 Lecture 8Kurt Akeley, Fall 2007 Homogeneous rotation (about a coordinate axis) x y z Right-hand rule for rotations by positive θ

CS248 Lecture 8Kurt Akeley, Fall 2007 Homogeneous rotation (ccw about axis a )

CS248 Lecture 8Kurt Akeley, Fall 2007 Composition of transformations

CS248 Lecture 8Kurt Akeley, Fall 2007 The plane equation

CS248 Lecture 8Kurt Akeley, Fall 2007 Transforming the plane equation Plane equations are transformed by the inverse of the matrix used to transform vertexes

CS248 Lecture 8Kurt Akeley, Fall 2007 The normal to the plane n

CS248 Lecture 8Kurt Akeley, Fall 2007 Derivation

CS248 Lecture 8Kurt Akeley, Fall 2007 Transformation of normals (correct) Convert to plane equation, transform, and convert back:

CS248 Lecture 8Kurt Akeley, Fall 2007 Transformation of normals (approximation)

CS248 Lecture 8Kurt Akeley, Fall 2007 Elemental inverse transforms are simple

CS248 Lecture 8Kurt Akeley, Fall 2007 Transformation in OpenGL

CS248 Lecture 8Kurt Akeley, Fall 2007 The vertex pipeline Vertex assembly Primitive assembly Rasterization Fragment operations Display Vertex operations Application Primitive operations struct { float x,y,z,w; float nx,ny,nz; float r,g,b,a; } vertex; Framebuffer

CS248 Lecture 8Kurt Akeley, Fall 2007 Conceptual coordinate systems Vertex operations Transform v o by M Transform n o by M -1 Transform v w by V Transform v e by P Object coordinates World coordinates (lighting calculations) Eye coordinates Clip coordinates vovo vwvw veve vcvc nono nwnw Model transformation View transformation Projection transformation

CS248 Lecture 8Kurt Akeley, Fall 2007 Why not collapse to a single transformation? Move world-coordinate and eye-coordinate operations (e.g., vertex lighting) to object coordinates Collapse the M, V, and P matrixes to a single M MVP matrix Advantages: n Efficient implementation (less arithmetic) n Simplified semantics Costs: n Must transform lights to object coordinates n And how would the light positions be defined? n Incorrect answers …

CS248 Lecture 8Kurt Akeley, Fall 2007 Rigid-body transformations Change orientation and position, but not shape Preserve geometric lengths and (relative) angles Rigid-body transformations are: n Translation and Rotation n Not Scale and Shear (with occasional exceptions) A homogeneous matrix is a rigid-body matrix if its upper-left 3x3 matrix is orthogonal A matrix is orthogonal if and only if n All columns are orthogonal and unit-length, and n All rows are orthogonal and unit-length

CS248 Lecture 8Kurt Akeley, Fall 2007 Non-rigid transformations warp normals

CS248 Lecture 8Kurt Akeley, Fall 2007 Conceptual coordinate systems Vertex operations Transform v o by M Transform n o by M -1 Transform v w by V Transform v e by P Object coordinates World coordinates (lighting calculations) Eye coordinates Clip coordinates vovo vwvw veve vcvc nono nwnw Model transformation (non-rigid) View transformation (rigid) Projection transformation (non-rigid)

CS248 Lecture 8Kurt Akeley, Fall 2007 Collapsed coordinate systems (obvious) Vertex operations Transform v o by M Transform n o by M -1 Transform v w by M VE Object coordinates World coordinates (lighting calculations) Clip coordinates vovo vwvw vcvc nono nwnw Model transformation (non-rigid) View and projection transformation (non-rigid)

CS248 Lecture 8Kurt Akeley, Fall 2007 OpenGL coordinate systems (actual) Vertex operations Transform v o by M Transform n o by M -1 Transform v e by P Object coordinates Eye coordinates (lighting calculations) Clip coordinates vovo veve vcvc nono nene “Model-view” transformation (non-rigid) Projection transformation (non-rigid)

CS248 Lecture 8Kurt Akeley, Fall 2007 Why compute lighting in eye coordinates? Simplicity n Eliminates the need to explicitly specify viewer location Efficiency n In eye coordinates n View location is (0 0 0) n View direction is (0 0 -1) n These zeros and ones lead to efficient lighting calculations n But the optimizations are no longer important  You are free to treat the intermediate coordinates as world coordinates: Compose view transform V into P rather than M n There is little penalty for doing so: –Diffuse, ambient, and emission lighting work well –But specular lighting, which depends on viewer location, doesn’t n In X-Window terminology: “Mechanism, not policy” n Write your own vertex “shader” n OpenGL 2.0 allows you to redefine everything I’ll describe today

CS248 Lecture 8Kurt Akeley, Fall 2007 OpenGL matrix commands Transform v o by M Transform n o by M -1 Transform v e by P Object coordinates Eye coordinates (lighting calculations) Clip coordinates vovo veve vcvc nono nene “Model-view” transformation (non-rigid) Projection transformation (non-rigid) glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_PROJECTION);

CS248 Lecture 8Kurt Akeley, Fall 2007 OpenGL matrix assignment commands glLoadIdentity(); glLoadMatrixf(float m[16]); glLoadMatrixd(double m[16]); glLoadTransposeMatrixf(float m[16]); glLoadTransposeMatrixd(double m[16]); Remember to do this!

CS248 Lecture 8Kurt Akeley, Fall 2007 OpenGL matrix composition commands glMultMatrixf(float m[16]); glMultMatrixd(double m[16]); glMultTransposeMatrixf(float m[16]); glMultTransposeMatrixd(double m[16]);

CS248 Lecture 8Kurt Akeley, Fall 2007 OpenGL transformation commands glRotatef(float θ, float x, float y, float z); glRotated(double θ, double x, double y, double z); glTranslatef(float x, float y, float z); glTranslated(double x, double y, double z); glScalef(float x, float y, float z); glScaled(double x, double y, double z);

CS248 Lecture 8Kurt Akeley, Fall 2007 Why post-multiplication ? glTranslated(px, py, pz); glRotated(θ, a); glTranslated(-px, -py, -pz); DrawObject();

CS248 Lecture 8Kurt Akeley, Fall 2007 Duality glMultMatrixf(mat1); glMultMatrixf(mat2); glMultMatrixf(mat3); DrawObject(); Transform the coordinate system Transform the object

CS248 Lecture 8Kurt Akeley, Fall 2007 Rotation about a specified point glTranslated(2, 3, 0); glRotated(45, 0, 0, 1); glTranslated(-2, -3, 0); DrawObject(); Transform the coordinate system Transform the object

CS248 Lecture 8Kurt Akeley, Fall 2007 Transform the object Transformations are applied opposite the specified order Each transformation operates in the fixed coordinate system ( )

CS248 Lecture 8Kurt Akeley, Fall 2007 Transform the coordinate system Transformations are applied in the order specified Each transformation operates relative to the current coordinate system ( )

CS248 Lecture 8Kurt Akeley, Fall 2007 OpenGL matrix stack Separate stacks are maintained for M and P Minimum (queryable) depths are 32 for M and 2 for P glPushMatrix(); // pushes C onto the appropriate stack // leaves C unchanged glPopMatrix(); // restores C from top of stack and pops

CS248 Lecture 8Kurt Akeley, Fall 2007 Transforming the coordinate system glPushMatrix(); glRotatef(shoulder, 1, 0, 0); SolidBox(1.5*unit, 1.5*unit, 5*unit, RED); glTranslatef(0, 0, 5*unit); glPushMatrix(); glRotatef(elbow, 1, 0, 0); SolidBox(1.25*unit, 1.25*unit, 4*unit, WHITE); glTranslatef(0, 0, 4*unit); glPushMatrix(); glRotatef(wrist, 1, 0, 0); SolidBox(unit, unit, 1.5*unit, GREEN); glTranslatef(0, 0, 1.5*unit); glPushMatrix(); glTranslatef(0, 0.25*unit, 0); glRotatef(finger, 1, 0, 0); SolidBox(0.75*unit, 0.5*unit, 1.5*unit, YELLOW); glPopMatrix(); glPushMatrix(); glTranslatef(0, -0.25*unit, 0); glRotatef(thumb, 1, 0, 0); SolidBox(0.75*unit, 0.5*unit, 1.5*unit, YELLOW); glPopMatrix();

CS248 Lecture 8Kurt Akeley, Fall 2007 Details (x y z 0) specifies a 3-D direction n Division by zero pushes the point to infinity n Normals are a special kind of direction n Transformed by the inverse of the vertex matrix n Other directions are correctly transformed by the vertex matrix itself n E.g., surface tangents OpenGL provides no mechanism to pre-multiply C n Why?

CS248 Lecture 8Kurt Akeley, Fall 2007 Summary Our 2-D understanding translated easily to 3-D n Lines  planes n Rotation becomes more involved Normals are transformed by the upper-left 3x3 of M There is a duality to transformation n Transform the coordinate system n Transformations are applied in the specified order n Each transformation is relative to the current coordinate system n Transform the object n Transformations are applied opposite the specified order n Each transformation operates in the fixed coordinate system OpenGL matrixes are post-multiplied n Matches vertex semantics (interesting) n Enables hierarchical modeling (important)

CS248 Lecture 8Kurt Akeley, Fall 2007 Assignments Reading assignment for Thursday’s class n FvD chapter 6 n OpenGL chapter 3 Project 2: n Assigned this past Tuesday n Due next Tuesday, 23 October (midnight, almost Wednesday) n Help session this Friday from 4:15 to 5 pm, Gates B03

CS248 Lecture 8Kurt Akeley, Fall 2007 End