2/19/04© University of Wisconsin, CS559 Spring 2004 Last Time Painterly rendering 2D Transformations –Transformations as coordinate system changes –Transformations.

Slides:



Advertisements
Similar presentations
Today Composing transformations 3D Transformations
Advertisements

Lecture 8 Transparency, Mirroring
1 Computer Graphics Chapter 8 3D Transformations.
10/10/02 (c) 2002 University of Wisconsin, CS 559 Last Time Finished viewing: Now you know how to: –Define a region of space that you wish to view – the.
3-D Geometry.
Viewing Doug James’ CG Slides, Rich Riesenfeld’s CG Slides, Shirley, Fundamentals of Computer Graphics, Chap 7 Wen-Chieh (Steve) Lin Institute of Multimedia.
CHAPTER 7 Viewing and Transformations © 2008 Cengage Learning EMEA.
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)
Introduction to 3D Graphics John E. Laird. Basic Issues u Given a internal model of a 3D world, with textures and light sources how do you project it.
2/26/04© University of Wisconsin, CS559 Spring 2004 Last Time General Orthographic Viewing –Specifying cameras in world coordinates –Building world  view.
10/5/04© University of Wisconsin, CS559 Fall 2004 Last Time Compositing Painterly Rendering Intro to 3D Graphics Homework 3 due Oct 12 in class.
CS 450: COMPUTER GRAPHICS 3D TRANSFORMATIONS SPRING 2015 DR. MICHAEL J. REALE.
10/13/200© NTUST Last Time Compositing Painterly Rendering Intro to 3D Graphics Homework 2, 3 due Oct 13 in class.
Viewing and Projections
CS 480/680 Computer Graphics Representation Dr. Frederick C Harris, Jr. Fall 2012.
CS 480/680 Computer Graphics Transformations Dr. Frederick C Harris, Jr.
02/26/02 (c) 2002 University of Wisconsin, CS 559 Last Time Canonical view pipeline Orthographic projection –There was an error in the matrix for taking.
Week 2 - Wednesday CS361.
Week 5 - Wednesday.  What did we talk about last time?  Project 2  Normal transforms  Euler angles  Quaternions.
MIT EECS 6.837, Durand and Cutler Graphics Pipeline: Projective Transformations.
CS559: Computer Graphics Lecture 9: Projection Li Zhang Spring 2008.
2/24/04© University of Wisconsin, CS559 Spring 2004 Last Time 3D Transformations –Most are natural extensions of 2D transforms –Rotations can be represented.
CS-378: Game Technology Lecture #2.1: Projection Prof. Okan Arikan University of Texas, Austin Thanks to James O’Brien, Steve Chenney, Zoran Popovic, Jessica.
Computer Graphics Bing-Yu Chen National Taiwan University.
1 CS 430/536 Computer Graphics I 3D Transformations World Window to Viewport Transformation Week 2, Lecture 4 David Breen, William Regli and Maxim Peysakhov.
CAP4730: Computational Structures in Computer Graphics 3D Transformations.
Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.
Jinxiang Chai Composite Transformations and Forward Kinematics 0.
Geometric Objects and Transformation
10/3/02 (c) 2002 University of Wisconsin, CS 559 Last Time 2D Coordinate systems and transformations.
CS559: Computer Graphics Lecture 9: Rasterization Li Zhang Spring 2008.
CS 450: COMPUTER GRAPHICS PROJECTIONS SPRING 2015 DR. MICHAEL J. REALE.
CS559: Computer Graphics Lecture 8: 3D Transforms Li Zhang Spring 2008 Most Slides from Stephen Chenney.
10/7/04© University of Wisconsin, CS559 Fall 2004 Last Time Transformations Homogeneous coordinates Directions Rotation Geometry 101 – Points, edges, triangles/polygons.
OpenGL The Viewing Pipeline: Definition: a series of operations that are applied to the OpenGL matrices, in order to create a 2D representation from 3D.
Basic 3D Concepts. Overview 1.Coordinate systems 2.Transformations 3.Projection 4.Rasterization.
Basic Perspective Projection Watt Section 5.2, some typos Define a focal distance, d, and shift the origin to be at that distance (note d is negative)
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0.
Three-Dimensional Viewing
Three-Dimensional Viewing Hearn & Baker Chapter 7
12/24/2015 A.Aruna/Assistant professor/IT/SNSCE 1.
©2005, Lee Iverson Lee Iverson UBC Dept. of ECE EECE 478 Viewing and Projection.
Rendering Pipeline Fall, D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination.
Taxonomy of Projections FVFHP Figure Taxonomy of Projections.
CS559: Computer Graphics Lecture 9: 3D Transformation and Projection Li Zhang Spring 2010 Most slides borrowed from Yungyu ChuangYungyu Chuang.
CS559: Computer Graphics Lecture 5: Color and Edge Li Zhang Spring 2008 Most Slides from Stephen Chenney.
Computer Graphics I, Fall 2010 Transformations.
Viewing and Projection. The topics Interior parameters Projection type Field of view Clipping Frustum… Exterior parameters Camera position Camera orientation.
CS 551 / 645: Introductory Computer Graphics Viewing Transforms.
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
Viewing. Classical Viewing Viewing requires three basic elements - One or more objects - A viewer with a projection surface - Projectors that go from.
Outline 3D Viewing Required readings: HB 10-1 to 10-10
Rendering Pipeline Fall, 2015.
- Introduction - Graphics Pipeline
© University of Wisconsin, CS559 Spring 2004
Computer Graphics CC416 Week 15 3D Graphics.
CSCE 441 Computer Graphics 3-D Viewing
3D Transformations Source & Courtesy: University of Wisconsin,
CSC461: Lecture 20 Parallel Projections in OpenGL
Modeling 101 For the moment assume that all geometry consists of points, lines and faces Line: A segment between two endpoints Face: A planar area bounded.
CENG 477 Introduction to Computer Graphics
CS451Real-time Rendering Pipeline
Last Time Canonical view pipeline Projection Local Coordinate Space
(c) University of Wisconsin, CS559
Geometric Objects and Transformations (II)
Viewing (Projections)
Lecture 8: 3D Transforms Li Zhang Spring 2008
Presentation transcript:

2/19/04© University of Wisconsin, CS559 Spring 2004 Last Time Painterly rendering 2D Transformations –Transformations as coordinate system changes –Transformations as geometric operations to an object –Translation, scaling, rotation, shear –How to rotate and scale about an arbitrary point Homogeneous coordinates –2D becomes 3D, but many points in 3D map to same 3D point –Homogeneous to 2D: (x,y,w)->(x/w,y/w) –2D to homogeneous: (x,y)->(x,y,1) –Transformations are now single 3x3 matrices

2/19/04© University of Wisconsin, CS559 Spring 2004 Today 3D Transformations Geometry 101 Orthogonal viewing

2/19/04© University of Wisconsin, CS559 Spring D Transformations Homogeneous coordinates: (x,y,z)=(wx,wy,wz,w) Transformations are now represented as 4x4 matrices Typical graphics packages allow for specification of translation, rotation, scaling and arbitrary matrices –OpenGL: glTranslate[fd], glRotate[fd], glScale[fd], glMultMatrix[fd]

2/19/04© University of Wisconsin, CS559 Spring D Translation

2/19/04© University of Wisconsin, CS559 Spring D Rotation Rotation in 3D is about an axis in 3D space passing through the origin Using a matrix representation, any matrix with an orthonormal top-left 3x3 sub-matrix is a rotation –Rows are mutually orthogonal (0 dot product) –Determinant is 1 –Implies columns are also orthogonal, and that the transpose is equal to the inverse

2/19/04© University of Wisconsin, CS559 Spring D Rotation

2/19/04© University of Wisconsin, CS559 Spring 2004 Problems with Rotation Matrices Specifying a rotation really only requires 3 numbers –Axis is a unit vector, so requires 2 numbers –Angle to rotate is third number Rotation matrix has a large amount of redundancy –Orthonormal constraints reduce degrees of freedom back down to 3 –Keeping a matrix orthonormal is difficult when transformations are combined Rotations are a very complex subject, and a detailed discussion is way beyond the scope of this course

2/19/04© University of Wisconsin, CS559 Spring 2004 Alternative Representations Specify the axis and the angle (OpenGL method) –Hard to compose multiple rotations Euler angles: Specify how much to rotate about X, then how much about Y, then how much about Z –Hard to think about, and hard to compose Specify the axis, scaled by the angle –Only 3 numbers, called the exponential map Quaternions

2/19/04© University of Wisconsin, CS559 Spring 2004 Quaternions 4-vector related to axis and angle, unit magnitude –Rotation about axis (n x,n y,n z ) by angle  : Reasonably easy to compose Reasonably easy to go to/from rotation matrix Only normalized quaternions represent rotations, but you can normalize them just like vectors, so it isn’t a problem Easy to perform spherical interpolation

2/19/04© University of Wisconsin, CS559 Spring 2004 Other Rotation Issues Rotation is about an axis at the origin –For rotation about an arbitrary axis, use the same trick as in 2D: Translate the axis to the origin, rotate, and translate back again Rotation is not commutative –Rotation order matters –Experiment to convince yourself of this

2/19/04© University of Wisconsin, CS559 Spring 2004 Transformation Leftovers Scale, shear etc extend naturally from 2D to 3D Rotation and Translation are the rigid-body transformations: –Do not change lengths or angles, so a body does not deform when transformed

2/19/04© University of Wisconsin, CS559 Spring 2004 Modeling 101 For the moment assume that all geometry consists of points, lines and faces Line: A segment between two endpoints Face: A planar area bounded by line segments –Any face can be triangulated (broken into triangles)

2/19/04© University of Wisconsin, CS559 Spring 2004 Modeling and OpenGL In OpenGL, all geometry is specified by stating which type of object and then giving the vertices that define it glBegin(…) …glEnd() glVertex[34][fdv] –Three or four components (regular or homogeneous) –Float, double or vector (eg float[3]) Chapter 2 of the red book

2/19/04© University of Wisconsin, CS559 Spring 2004 Rendering Generate an image showing the contents of some region of space –The region is called the view volume, and it is defined by the user Determine where each object should go in the image –Viewing, Projection Determine which object is in front at each pixel –Hidden surface elimination, Hidden surface removal, Visibility Determine what color it is –Lighting, Shading

2/19/04© University of Wisconsin, CS559 Spring 2004 Graphics Pipeline Graphics hardware employs a sequence of coordinate systems –The location of the geometry is expressed in each coordinate system in turn, and modified along the way –The movement of geometry through these spaces is considered a pipeline Local Coordinate Space World Coordinate Space View Space Canonical View Volume Display Space

2/19/04© University of Wisconsin, CS559 Spring 2004 Local Coordinate Space It is easiest to define individual objects in a local coordinate system –For instance, a cube is easiest to define with faces parallel to the coordinate axes Key idea: Object instantiation –Define an object in a local coordinate system –Use it multiple times by copying it and transforming it into the global system –This is the only effective way to have libraries of 3D objects

2/19/04© University of Wisconsin, CS559 Spring 2004 Global Coordinate System Everything in the world is transformed into one coordinate system - the global coordinate system –Actually, some things, like dashboards, may be defined in a different space, but we’ll ignore that Lighting is defined in this space –The locations, brightness’ and types of lights The camera is defined with respect to this space Some higher level operations, such as advanced visibility computations, can be done here

2/19/04© University of Wisconsin, CS559 Spring 2004 View Space Define a coordinate system based on the eye and image plane –The eye is the center of projection, like a lens in a camera –The image plane is the orientation of the plane in space on which the image should “appear,” like the film plane of a camera –Defined by three vectors: One normal to the image plane, one up in the image plane, one right in the image plane –These define a coordinate system Some camera parameters are easiest to define in this space –Focal length, image size Depth is represented by a single number in this space –The “normal to image plane” coordinate

2/19/04© University of Wisconsin, CS559 Spring 2004 Canonical View Volume Transform view space into a cube: [-1,1]×[-1,1]×[-1,1] –The cube is the canonical view volume –Parallel sides and unit dimensions make many operations easier –Only things that end up inside the canonical volume can appear in the window Tasks to do: –Clipping – decide what you can see –Rasterization - decide which pixels are covered –Hidden surface removal - decide what is in front –Shading - decide what color things are

2/19/04© University of Wisconsin, CS559 Spring 2004 Window Space Also called screen space Convert the virtual screen into real screen coordinates –Drop the depth coordinates and translate The windowing system takes care of this

2/19/04© University of Wisconsin, CS559 Spring 2004 Canonical  Window Transform Screen space has a physical realization – the screen –Origin at top left (or bottom left) corner –X is horizontal, Y is down (or up) Windows appear somewhere on the screen –Typically you want the thing you are drawing to appear in your window You want to be able to work in a standard coordinate system – your code should not depend on where the window is You work in canonical view space, and the windowing system takes care of putting it on the screen

2/19/04© University of Wisconsin, CS559 Spring 2004 Canonical  Window Transform Typically, windows are specified by a corner, width and height –Corner expressed in terms of screen location –This representation can be converted to (x min,y min ) and (x max,y max ) We want to map points in Canonical View Space into the window –3D Screen Space goes from (-1,-1,-1) to (1,1,1) –Lets say we want to leave z unchanged What basic transformations will be involved in the total transformation from 3D screen to window coordinates?

2/19/04© University of Wisconsin, CS559 Spring 2004 Canonical  Window Transform How much do we translate? How much do we scale? (-1,-1) (1,1) (x min,y min ) (x max,y max )

2/19/04© University of Wisconsin, CS559 Spring 2004 Canonical  Window Transform (-1,-1) (1,1) (x min,y min ) (x max,y max )

2/19/04© University of Wisconsin, CS559 Spring 2004 Canonical  Window Transform You almost never have to worry about the canonical to window transform In OpenGL, you tell it which part of your window to draw in – relative to the window’s coordinates –That is, you tell it where to put the canonical view volume –Window (not the screen) has origin at bottom left –glViewport(minx, miny, maxx, maxy) –Typically: glViewport(0, 0, width, height) fills the entire window with the image The textbook derives a different transform, but the same idea

2/19/04© University of Wisconsin, CS559 Spring 2004 View Volumes Only stuff inside the canonical view volume gets drawn –The window is of finite size, and the canonical view volume reflects this –We can only store a discrete, finite range of depths, and the canonical view volume also recognizes that –Points too close or too far away will not be drawn –But, it is inconvenient to make sure everything appears in a unit cube A view volume is the region of space we wish to map into the canonical view volume for drawing –Only stuff inside the view volume gets drawn –One task in specifying a view is describing the view volume

2/19/04© University of Wisconsin, CS559 Spring 2004 Orthographic Projection Orthographic projection projects all the points in the world along parallel lines onto the image plane –Projection lines are perpendicular to the image plane –Like a camera with infinite focal length The result is that parallel lines in the world project to parallel lines in the image, and ratios of lengths are preserved –This is important in some applications, like medical imaging and some computer aided design tasks

2/19/04© University of Wisconsin, CS559 Spring 2004 Simple Orthographic Projection z y x The view volume is a rectilinear box for orthographic projection Assume that the viewer is looking in the –z direction, with x to the right and y up –Assuming a right-handed coordinate system The view volume has: –a near plane at z=n –a far plane at z=f, (f < n) –a left plane at x=l –a right plane at x=r, (r>l) –a top plane at y=t –and a bottom plane at y=b, (b<t) (r,b,n) (l,t,f)

2/19/04© University of Wisconsin, CS559 Spring 2004 Rendering the Volume To project, map the view volume onto the canonical view volume –After that, we know how to map the view volume to the window The mapping looks similar to the one for canonical → window: