Angel: Interactive Computer Graphics CSE 409: Computer Graphics Camera Transformations and Projection Acknowledgements: parts of information and pictures.

Slides:



Advertisements
Similar presentations
Computer Graphics - Viewing -
Advertisements

Three Dimensional Viewing
Projection.
1 View Shandong University Software College Instructor: Zhou Yuanfeng
Three-Dimensional Viewing Sang Il Park Sejong University Lots of slides are stolen from Jehee Lee’s.
Based on slides created by Edward Angel
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Computer Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
OpenGL (II). How to Draw a 3-D object on Screen?
CS 4731: Computer Graphics Lecture 11: 3D Viewing Emmanuel Agu.
Rendering Pipeline Aaron Bloomfield CS 445: Introduction to Graphics Fall 2006 (Slide set originally by Greg Humphreys)
Projection Projection - the transformation of points from a coordinate system in n dimensions to a coordinate system in m dimensions where m
Introduction to 3D viewing 3D is just like taking a photograph!
UBI 516 Advanced Computer Graphics Three Dimensional Viewing
Advanced Computer Graphics Three Dimensional Viewing
Geometric transformations The Pipeline
1 2D Transformations 几何变换. 2 What is a transformation? A transformation is an operation that transforms or changes a shape (line, drawing etc.) There.
Chi-Cheng Lin, Winona State University CS430 Computer Graphics 3D Viewing and Projections.
CS559: Computer Graphics Lecture 9: Projection Li Zhang Spring 2008.
Viewing Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
C O M P U T E R G R A P H I C S Guoying Zhao 1 / 67 C O M P U T E R G R A P H I C S Guoying Zhao 1 / 67 Computer Graphics Three-Dimensional Graphics III.
Graphics Graphics Korea University cgvr.korea.ac.kr 3D Viewing 고려대학교 컴퓨터 그래픽스 연구실.
Computer Graphics Bing-Yu Chen National Taiwan University.
CAP 4703 Computer Graphic Methods Prof. Roy Levow Chapter 5.
Demetriou/Loizidou – ACSC330 – Chapter 5 Viewing Dr. Giorgos A. Demetriou Computer Science Frederick Institute of Technology.
CAP4730: Computational Structures in Computer Graphics 3D Transformations.
Computer Graphics I, Fall 2010 Computer Viewing.
CS 325 Introduction to Computer Graphics 02 / 22 / 2010 Instructor: Michael Eckmann.
Basic Projections 2D to 3D
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.
2003CS Hons RW778 Graphics1 Chapter 7: Three-Dimensional Viewing Chapter 5: Camera with parallel projection Chapter 5: Camera with parallel projection.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
The Camera Analogy ► Set up your tripod and point the camera at the scene (viewing transformation) ► Arrange the scene to be photographed into the desired.
Three-Dimensional Viewing
12/24/2015 A.Aruna/Assistant professor/IT/SNSCE 1.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Classical Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Rendering Pipeline Fall, D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination.
Classical Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Taxonomy of Projections FVFHP Figure Taxonomy of Projections.
Projections Angel: Interactive Computer Graphics.
Chap 3 Viewing and Transformation
Viewing and Projection
CS559: Computer Graphics Lecture 9: 3D Transformation and Projection Li Zhang Spring 2010 Most slides borrowed from Yungyu ChuangYungyu Chuang.
CS 376 Introduction to Computer Graphics 02 / 21 / 2007 Instructor: Michael Eckmann.
Viewing and Projection. The topics Interior parameters Projection type Field of view Clipping Frustum… Exterior parameters Camera position Camera orientation.
RAC/RA Projection Types of Projection Simple Projections Generalized Projection.
Classical Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
CS 551 / 645: Introductory Computer Graphics Viewing Transforms.
Viewing Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
CS5500 Computer Graphics March 20, Computer Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts.
OpenGL LAB III.
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
Projection. Conceptual model of 3D viewing process.
Computer Graphics Projections.
PROJECTIONS PROJECTIONS 1. Transform 3D objects on to a 2D plane using projections 2 types of projections Perspective Parallel In parallel projection,
Chapter 11 Three-Dimensional Geometric and Modeling Transformations
Three Dimensional Viewing
Rendering Pipeline Fall, 2015.
Projection Our 3-D scenes are all specified in 3-D world coordinates
3D Viewing cgvr.korea.ac.kr.
Rendering Pipeline Aaron Bloomfield CS 445: Introduction to Graphics
CSCE 441 Computer Graphics 3-D Viewing
Unit 4 3D Viewing Pipeline Part - 2
CSC461: Lecture 19 Computer Viewing
Three Dimensional Viewing
Computer Graphics (Spring 2003)
Planar Geometric Projection Classes
3D Graphics.
Viewing (Projections)
Presentation transcript:

Angel: Interactive Computer Graphics CSE 409: Computer Graphics Camera Transformations and Projection Acknowledgements: parts of information and pictures has been collected from the University of Virginia.

Conceptual Model of 3D Viewing Clip against View volume Project onto projection plane Transform into view port in 2D device coordinates for display 3D world coordinate output primitives Clipped world coordinate 2D Device Coordinate

In general, projections transform points in a coordinate system of dimension n into points in a coordinate system of dimension less than n. We shall limit ourselves to the projection from 3D to 2D. We will deal with planar geometric projections where:  The projection is onto a plane rather than a curved surface  The projectors are straight lines rather than curves In general, projections transform points in a coordinate system of dimension n into points in a coordinate system of dimension less than n. We shall limit ourselves to the projection from 3D to 2D. We will deal with planar geometric projections where:  The projection is onto a plane rather than a curved surface  The projectors are straight lines rather than curves Projection

 key terms…  Projection from 3D to 2D is defined by straight projection rays (projectors) emanating from the 'center of projection', passing through each point of the object, and intersecting the 'projection plane' to form a projection. Projection

Planer Geometric Projection 2 types of projections perspective and parallel.perspective and parallel. Key factor is the center of projection. if distance to center of projection is finite : perspectiveif distance to center of projection is finite : perspective if infinite : parallelif infinite : parallel 2 types of projections perspective and parallel.perspective and parallel. Key factor is the center of projection. if distance to center of projection is finite : perspectiveif distance to center of projection is finite : perspective if infinite : parallelif infinite : parallel Perspective projection Parallel projection

Perspective v Parallel Perspective: visual effect is similar to human visual system...visual effect is similar to human visual system... has 'perspective foreshortening'has 'perspective foreshortening' –size of object varies inversely with distance from the center of projection. Parallel lines do not in general project to parallel linesParallel lines do not in general project to parallel lines angles only remain intact for faces parallel to projection plane.angles only remain intact for faces parallel to projection plane.Perspective: visual effect is similar to human visual system...visual effect is similar to human visual system... has 'perspective foreshortening'has 'perspective foreshortening' –size of object varies inversely with distance from the center of projection. Parallel lines do not in general project to parallel linesParallel lines do not in general project to parallel lines angles only remain intact for faces parallel to projection plane.angles only remain intact for faces parallel to projection plane.

Parallel: less realistic view because of no foreshorteningless realistic view because of no foreshortening however, parallel lines remain parallel.however, parallel lines remain parallel. angles only remain intact for faces parallel to projection plane.angles only remain intact for faces parallel to projection plane.Parallel: less realistic view because of no foreshorteningless realistic view because of no foreshortening however, parallel lines remain parallel.however, parallel lines remain parallel. angles only remain intact for faces parallel to projection plane.angles only remain intact for faces parallel to projection plane. Parallel

Perspective projection- anomalies Perspective foreshortening The farther an object is from COP the smaller it appears

Vanishing Points: Any set of parallel lines not parallel to the view plane appear to meet at some point. There are an infinite number of these, 1 for each of the infinite amount of directions line can be orientedThere are an infinite number of these, 1 for each of the infinite amount of directions line can be oriented Vanishing Points: Any set of parallel lines not parallel to the view plane appear to meet at some point. There are an infinite number of these, 1 for each of the infinite amount of directions line can be orientedThere are an infinite number of these, 1 for each of the infinite amount of directions line can be oriented Vanishing point Perspective projection- anomalies

Vanishing Point

If a set of lines are parallel to one of the three axes, the vanishing point is called an axis vanishing point (Principal Vanishing Point). There are at most 3 such points, corresponding to the number of axes cut by the projection planeThere are at most 3 such points, corresponding to the number of axes cut by the projection planeOne-point: One principle axis cut by projection planeOne principle axis cut by projection plane One axis vanishing pointOne axis vanishing pointTwo-point: Two principle axes cut by projection planeTwo principle axes cut by projection plane Two axis vanishing pointsTwo axis vanishing pointsThree-point: Three principle axes cut by projection planeThree principle axes cut by projection plane Three axis vanishing pointsThree axis vanishing points If a set of lines are parallel to one of the three axes, the vanishing point is called an axis vanishing point (Principal Vanishing Point). There are at most 3 such points, corresponding to the number of axes cut by the projection planeThere are at most 3 such points, corresponding to the number of axes cut by the projection planeOne-point: One principle axis cut by projection planeOne principle axis cut by projection plane One axis vanishing pointOne axis vanishing pointTwo-point: Two principle axes cut by projection planeTwo principle axes cut by projection plane Two axis vanishing pointsTwo axis vanishing pointsThree-point: Three principle axes cut by projection planeThree principle axes cut by projection plane Three axis vanishing pointsThree axis vanishing points

Vanishing Point

Perspective Projection Angel Figure Point Perspective 2-Point Perspective 1-Point Perspective How many vanishing points?

Taxonomy of Projection

Parallel projection 2 principle types: orthographic and oblique.orthographic and oblique. Orthographic : direction of projection = normal to the projection plane.direction of projection = normal to the projection plane. Oblique : direction of projection != normal to the projection plane.direction of projection != normal to the projection plane. 2 principle types: orthographic and oblique.orthographic and oblique. Orthographic : direction of projection = normal to the projection plane.direction of projection = normal to the projection plane. Oblique : direction of projection != normal to the projection plane.direction of projection != normal to the projection plane.

Orthographic Projections Top Side Front DOP perpendicular to view plane

Axonometric Orthogonal Projection Projection plane are not normal to the principle axis and therefore show several faces of an object at once. Isometric Axonometric Orthogonal Projection: Projection plane normal makes equal angles with each principle axis. If the projection plane normal is (d x, d y, d z ) then | d x | = | d y | = | d z |. There are 8 directions to satisfy this condition.

Axonometric vs Perspective Axonometric projection shows several faces of an object at once like perspective projection. But the foreshortening is uniform rather than being related to the distance from the COP. Axonometric projection shows several faces of an object at once like perspective projection. But the foreshortening is uniform rather than being related to the distance from the COP. Projection Plane Isometric proj

Oblique Projections H&B DOP not perpendicular to view plane Cavalier (DOP  = 45 o ) tan(  ) = 1 Cabinet (DOP  = 63.4 o ) tan(  ) = 2

Oblique parallel projection Cavalier, cabinet and orthogonal projections can all be specified in terms of (α, β) or ( α, λ) since tan( α) = 1/λtan( α) = 1/λ Cavalier, cabinet and orthogonal projections can all be specified in terms of (α, β) or ( α, λ) since tan( α) = 1/λtan( α) = 1/λ β P=(0, 0, 1) P ׳ ( λ cos(β), λ sin(β),0) λ cos(β) λ sin(β) λ α

Oblique parallel projection =1  = 45 Cavalier projection  = =0.5  = 63.4 Cabinet projection  = 0 – 360 =0  = 90 Orthogonal projection  = 0 – 360

Oblique parallel projection PP‘ = (λ cos(α), λ sin(α),-1) = DOP Proj(P) = (λ cos(α), λ sin(α),0) Generally multiply by z and allow for (non-zero) x and ymultiply by z and allow for (non-zero) x and y x' = x + z cos  y' = y + z sin  PP‘ = (λ cos(α), λ sin(α),-1) = DOP Proj(P) = (λ cos(α), λ sin(α),0) Generally multiply by z and allow for (non-zero) x and ymultiply by z and allow for (non-zero) x and y x' = x + z cos  y' = y + z sin 

Taxonomy of Projection

Perspective Projection In the real world, objects exhibit perspective foreshortening: distant objects appear smaller The basic situation: In the real world, objects exhibit perspective foreshortening: distant objects appear smaller The basic situation:

Perspective Projection When we do 3-D graphics, we think of the screen as a 2-D window onto the 3-D world: How tall should this bunny be?

Perspective Projection The geometry of the situation is that of similar triangles. View from above: What is x’ ? The geometry of the situation is that of similar triangles. View from above: What is x’ ? d P (x, y, z) X Z View plane (0,0,0) x’ = ?

Perspective Projection Desired result for a point [x, y, z, 1] T projected onto the view plane: What could a matrix look like to do this? Desired result for a point [x, y, z, 1] T projected onto the view plane: What could a matrix look like to do this?

A Perspective Projection Matrix Answer:Answer:

Example: Or, in 3-D coordinates: Example:

Generalized Projection Matrix

Viewing in OpenGL OpenGL has multiple matrix stacks - transformation functions right- multiply the top of the stack Two most important stacks: GL_MODELVIEW and GL_PROJECTION Points get multiplied by the modelview matrix first, and then the projection matrix GL_MODELVIEW : Object->Camera GL_PROJECTION : Camera->Screen glViewport(0,0,w,h): Screen->Device OpenGL has multiple matrix stacks - transformation functions right- multiply the top of the stack Two most important stacks: GL_MODELVIEW and GL_PROJECTION Points get multiplied by the modelview matrix first, and then the projection matrix GL_MODELVIEW : Object->Camera GL_PROJECTION : Camera->Screen glViewport(0,0,w,h): Screen->Device

OpenGL Example void SetUpViewing() { // The viewport isn’t a matrix, it’s just state... glViewport( 0, 0, window_width, window_height ); // Set up camera->screen transformation first glMatrixMode( GL_PROJECTION ); glLoadIdentity(); gluPerspective( 60, 1, 1, 1000 ); // fov, aspect, near, far // Set up the model->camera transformation glMatrixMode( GL_MODELVIEW ); gluLookAt( 3, 3, 2, // eye point 0, 0, 0, // look at point 0, 0, 1 ); // up vector glRotatef( theta, 0, 0, 1 ); // rotate the model glScalef( zoom, zoom, zoom ); // scale the model }

Graphics Pipeline Revisited Modeling Transformation Modeling Transformation Projection Transformation Projection Transformation Clipping Viewing Transformation Viewing Transformation 3D Geometric Primitives Image Lighting Scan Conversion Scan Conversion glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); gluLookAt ( eyex, eyey, eyez, lookx, looky, lookz, upx, upy, upz );

Default Camera Position Near Plane Far Plane x y z F N Eye θ glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(viewAngle, aspectRatio, N, F);

38 General Camera Position u n v Eye

General Camera Position l = look - eye r = l X up u = r X l l r u eye look up To transform world coordinate into camera’s coordinate, transformTo transform world coordinate into camera’s coordinate, transform eye into the origineye into the origin r into the vector ir into the vector i u into the vector ju into the vector j -l into the vector k-l into the vector k To transform world coordinate into camera’s coordinate, transformTo transform world coordinate into camera’s coordinate, transform eye into the origineye into the origin r into the vector ir into the vector i u into the vector ju into the vector j -l into the vector k-l into the vector k So what is the matrix for viewing transform?

A 3D Scene Notice the presence of the camera, the projection plane, and the world coordinate axes Viewing transformations define how to acquire the image on the projection plane Notice the presence of the camera, the projection plane, and the world coordinate axes Viewing transformations define how to acquire the image on the projection plane

Viewing Transformations Create a camera-centered view Camera is at origin Camera is looking along negative z-axis Camera’s ‘up’ is aligned with y-axis Create a camera-centered view Camera is at origin Camera is looking along negative z-axis Camera’s ‘up’ is aligned with y-axis

2 Basic Steps Align the two coordinate frames by rotation

2 Basic Steps Translate to align origins

Creating Camera Coordinate Space Specify a point where the camera is located in world space, the eye point Specify a point in world space that we wish to become the center of view, the lookat point Specify a vector in world space that we wish to point up in camera image, the up vector Intuitive camera movement Specify a point where the camera is located in world space, the eye point Specify a point in world space that we wish to become the center of view, the lookat point Specify a vector in world space that we wish to point up in camera image, the up vector Intuitive camera movement

Constructing Viewing Transformation, V Create a vector from eye-point to lookat-point Normalize the vector Desired rotation matrix should map this vector to [0, 0, -1] T Why? Create a vector from eye-point to lookat-point Normalize the vector Desired rotation matrix should map this vector to [0, 0, -1] T Why?

Constructing Viewing Transformation, V Construct another important vector from the cross product of the lookat-vector and the vup- vector This vector, when normalized, should align with [1, 0, 0] T Why? Construct another important vector from the cross product of the lookat-vector and the vup- vector This vector, when normalized, should align with [1, 0, 0] T Why?

Constructing Viewing Transformation, V One more vector to define… This vector, when normalized, should align with [0, 1, 0] T Now let’s compose the results One more vector to define… This vector, when normalized, should align with [0, 1, 0] T Now let’s compose the results

Compositing Vectors to Form V We know the three world axis vectors (x, y, z) We know the three camera axis vectors (r, u, l) Viewing transformation, V, must convert from world to camera coordinate systems We know the three world axis vectors (x, y, z) We know the three camera axis vectors (r, u, l) Viewing transformation, V, must convert from world to camera coordinate systems

Compositing Vectors to Form V Remember Each camera axis vector is unit length.Each camera axis vector is unit length. Each camera axis vector is perpendicular to othersEach camera axis vector is perpendicular to others Camera matrix is orthogonal and normalized OrthonormalOrthonormal Therefore, M -1 = M T Remember Each camera axis vector is unit length.Each camera axis vector is unit length. Each camera axis vector is perpendicular to othersEach camera axis vector is perpendicular to others Camera matrix is orthogonal and normalized OrthonormalOrthonormal Therefore, M -1 = M T

Compositing Vectors to Form V Therefore, rotation component of viewing transformation is just transpose of computed vectors

Compositing Vectors to Form V Translation component too Multiply it through Translation component too Multiply it through

Final Viewing Transformation, V To transform vertices, use this matrix: And you get this: To transform vertices, use this matrix: And you get this:

Home work

Generalized Projection Using the origin as the center of projection, derive the perspective transformation onto the plane passing through the point R 0 (x 0, y 0, z 0 ) and having the normal vector N = n 1 I + n 2 J + n 3 K.Using the origin as the center of projection, derive the perspective transformation onto the plane passing through the point R 0 (x 0, y 0, z 0 ) and having the normal vector N = n 1 I + n 2 J + n 3 K. x y z P(x, y, z) P'(x', y', z') N = n 1 I + n 2 J + n 3 K R 0 =x 0,y 0, z 0 O

Generalized Projection x y z P(x, y, z) P'(x', y', z') N = n 1 I + n 2 J + n 3 K R 0 =x 0,y 0, z 0 O P'O = α PO x' = αx, y' = αy, z ' = αz N. R 0 P' = 0 n 1 x ' + n 2 y ' + n 3 z ' =n 1 x 0 + n 2 y 0 + n 3 z 0 = d 0

Generalized Projection Derive the general perspective transformation onto a plane with reference point R 0 and normal vector N and using C(a,b,c) as the center of projection.Derive the general perspective transformation onto a plane with reference point R 0 and normal vector N and using C(a,b,c) as the center of projection. x y z P(x, y, z) P'(x', y', z') N = n 1 I + n 2 J + n 3 K R 0 =x 0,y 0, z 0 C

Generalized Projection P'C = α PC x' = α(x-a) + a n 1 x' + n 2 y' + n 3 z‘ = d 0 d = (n 1 x 0 + n 2 y 0 + n 3 z 0 ) – (n 1 a + n 2 b + n 3 c) = d 0 – d 1 x y z P(x, y, z) P'(x', y', z') N = n 1 I + n 2 J + n 3 K R 0 =x 0,y 0, z 0 C

Generalized Projection Follow the steps –Follow the steps – Translate so that C lies at the originTranslate so that C lies at the origin PerPer Translate backTranslate back Follow the steps –Follow the steps – Translate so that C lies at the originTranslate so that C lies at the origin PerPer Translate backTranslate back

Ref. Projection: FV: p , Projection: FV: p , View transformation from this pptView transformation from this ppt Projection: FV: p , Projection: FV: p , View transformation from this pptView transformation from this ppt