Transformations and Projections (Some slides adapted from Amitabh Varshney)

Slides:



Advertisements
Similar presentations
Computer Graphics - Viewing -
Advertisements

Image formation. Image Formation Vision infers world properties form images. How do images depend on these properties? Two key elements –Geometry –Radiometry.
Three Dimensional Viewing
1 Computer Graphics Chapter 8 3D Transformations.
Three-Dimensional Viewing Sang Il Park Sejong University Lots of slides are stolen from Jehee Lee’s.
Camera Models A camera is a mapping between the 3D world and a 2D image The principal camera of interest is central projection.
Based on slides created by Edward Angel
Viewing and Transformation
Cameras (Reading: Chapter 1) Goal: understand how images are formed Camera obscura dates from 15 th century Basic abstraction is the pinhole camera Perspective.
Image Formation (approximately) Vision infers world properties form images. So we need to understand how images depend on these properties. Two key elements.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Computer Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
CS 352: Computer Graphics Chapter 5: Viewing. Interactive Computer GraphicsChapter Overview Specifying the viewpoint Specifying the projection Types.
Lecture 5: Projection CS6670: Computer Vision Noah Snavely.
Image Formation (approximately) Vision infers world properties form images. So we need to understand how images depend on these properties. Two key elements.
CS485/685 Computer Vision Prof. George Bebis
Computer Vision - A Modern Approach
Computer Vision : CISC4/689
Lecture 12: Projection CS4670: Computer Vision Noah Snavely “The School of Athens,” Raphael.
Viewing Doug James’ CG Slides, Rich Riesenfeld’s CG Slides, Shirley, Fundamentals of Computer Graphics, Chap 7 Wen-Chieh (Steve) Lin Institute of Multimedia.
OpenGL (II). How to Draw a 3-D object on Screen?
Cameras, lenses, and calibration
Rendering Pipeline Aaron Bloomfield CS 445: Introduction to Graphics Fall 2006 (Slide set originally by Greg Humphreys)
Perspective projection
Viewing and Projections
Computer Graphics (fall 2009)
Image Formation Fundamentals Basic Concepts (Continued…)
The Viewing Pipeline (Chapter 4) 5/26/ Overview OpenGL viewing pipeline: OpenGL viewing pipeline: – Modelview matrix – Projection matrix Parallel.
Geometric transformations The Pipeline
CS559: Computer Graphics Lecture 9: Projection Li Zhang Spring 2008.
Viewing Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
Computer Graphics I, Fall 2010 Computer Viewing.
Graphics Graphics Korea University kucg.korea.ac.kr Viewing 고려대학교 컴퓨터 그래픽스 연구실.
Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0.
Chapters 5 2 March Classical & Computer Viewing Same elements –objects –viewer –projectors –projection plane.
Three-Dimensional Viewing
Foundations of Computer Graphics (Spring 2012) CS 184, Lecture 5: Viewing
12/24/2015 A.Aruna/Assistant professor/IT/SNSCE 1.
©2005, Lee Iverson Lee Iverson UBC Dept. of ECE EECE 478 Viewing and Projection.
Graphics CSCI 343, Fall 2015 Lecture 16 Viewing I
Geometric Transformations Sang Il Park Sejong University Many slides come from Jehee Lee’s.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Classical Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Classical Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Introduction to Computer Graphics: Viewing Transformations Rama C
Taxonomy of Projections FVFHP Figure Taxonomy of Projections.
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.
Viewing and Projection. The topics Interior parameters Projection type Field of view Clipping Frustum… Exterior parameters Camera position Camera orientation.
Lecture 14: Projection CS4670 / 5670: Computer Vision Noah Snavely “The School of Athens,” Raphael.
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.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Computer Viewing Isaac Gang University of Mary Hardin-Baylor.
Lecture 18: Cameras CS4670 / 5670: Computer Vision KavitaBala Source: S. Lazebnik.
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
OpenGL LAB III.
CS 490: Computer Graphics Chapter 5: Viewing. Interactive Computer GraphicsChapter Overview Specifying the viewpoint Specifying the projection Types.
Outline 3D Viewing Required readings: HB 10-1 to 10-10
Viewing.
Computer Viewing.
Isaac Gang University of Mary Hardin-Baylor
Rendering Pipeline Aaron Bloomfield CS 445: Introduction to Graphics
CSCE 441 Computer Graphics 3-D Viewing
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.
CSC461: Lecture 19 Computer Viewing
Lecture 13: Cameras and geometry
Computer Graphics (Spring 2003)
Last Time Canonical view pipeline Projection Local Coordinate Space
University of New Mexico
THREE-DIMENSIONAL VIEWING II
CS 352: Computer Graphics Chapter 5: Viewing.
Presentation transcript:

Transformations and Projections (Some slides adapted from Amitabh Varshney)

Transformation of lines/normals 2D. Line is set of points (x,y) for which (a,b,c).(x,y,1) T =0. Suppose we rotate points by R. Notice that: (a,b,c)R T R(x,y,1) T So, (a,b,c)R T is the rotation of the line (a,b,c). Surface normals are similar, except they are defined by (a,b,c).(x,y,z) T = 0

Rotation about a known axis Suppose we want to rotate about u. Find R so that u will be the new z axis. –u is third row of R. –Second row is anything orthogonal to u. –Third row is cross-product of first two. –Make sure matrix has determinant 1. Then rotate about (new) z axis. Then apply inverse of first rotation.

OpenGL Transformation Support Three matrices –GL_MODELVIEW, GL_PROJECTION, GL_TEXTURE – glMatrixMode( mode ) specifies the active matrix glLoadIdentity( ) –Set the active matrix to identity glLoadMatrix{fd}(TYPE *m) –Set the 16 values of the current matrix to those specified by m glMultMatrix{fd}(TYPE *m) –Multiplies the current active matrix by m m 1 m 5 m 9 m 13 m 2 m 6 m 10 m 14 m 3 m 7 m 11 m 15 m 4 m 8 m 12 m 16 m =

Transformation Example glMatrixMode(GL_MODELVIEW); glLoadIdentity( ); // matrix = I glMultMatrix(N); // matrix = N glMultmatrix(M); // matrix = NM glMultMatrix(L); // matrix = NML glBegin(GL_POINTS); glVertex3f(v); // v will be transformed: NMLv glEnd( );

OpenGL Transformations glTranslate{fd}(TYPE x, TYPE y, TYPE z) –Multiply the current matrix by the translation matrix glRotate{fd}(TYPE angle, TYPE x, TYPE y, TYPE z) –Multiply the current matrix by the rotation matrix that rotates an object about the axis from (0,0,0) to (x, y, z) glScale{fd}(TYPE x, TYPE y, TYPE z) –Multiply the current matrix by the scale matrix

Examples glMatrixMode(GL_MODELVIEW); glRecti(50,100,200,150); glTranslatef(-200.0, -50.0, 0.0); glRecti(50,100,200,150); glLoadIdentity(); glRotatef(90.0, 0.0, 0.0, 1.0); glRecti(50,100,200,150); glLoadIdentity(); glscalef(-.5, 1.0, 1.0) glRecti(50,100,200,150);

Hierarchical Transformations in OpenGL Stacks for Modelview and Projection matrices glPushMatrix( ) –push-down all the matrices in the active stack one level –the top-most matrix is copied (the top and the second- from-top matrices are initially the same). glPopMatrix( ) –pop-off and discard the top matrix in the active stack Stacks used during recursive traversal of the hierarchy. Typical depths of matrix stacks: –Modelview stack = 32 (aggregating several transformations) –Projection Stack = 2 (eg: 3D graphics and 2D help- menu)

Viewing in 3D World (3D)  Screen (2D) Orienting Eye coordinate system in World coordinate system – View Orientation Matrix Specifying viewing volume and projection parameters for  n  d (d < n) – View Mapping Matrix

World to Eye Coordinates (Images Removed)

World to Eye Coordinates We need to transform from the world coordinates to the eye coordinates The eye coordinate system is specified by: –View reference point (VRP) ( VRP x, VRP y, VRP z ) –Direction of the axes: eye coordinate system U = ( u x, u y, u z ) V = ( v x, v y, v z ) N = ( n x, n y, n z )

World to Eye Coordinates There are two steps in the transformation (in order) –Translation –Rotation

World to Eye Coordinates Translate World Origin to VRP VRP x VRP y VRP z x y z 1 a b c 1 =

World to Eye Coordinates Rotate World X, Y, Z to the Eye coordinate system u, v, n, also known as the View Reference Coordinate system a b c 1 x’ y’ z’ 1 = u x u y u z 0 v x v y v z 0 n x n y n z

Camera Analogy (Images Removed)

Specifying 3D View (Camera Analogy) Center of camera (x, y, z) : 3 parameters Direction of pointing ( ,  ) : 2 parameters Camera tilt (  ) : 1 parameter Area of film (w, h) : 2 parameters Focus (f) : 1 parameter

Specifying 3D View Center of camera (x, y, z) : View Reference Point (VRP) Direction of pointing ( ,  ) : View Plane Normal (VPN) Camera tilt (  ) : View Up (VUP) Area of film (w, h) : Aspect Ratio (w/h), Field of view (fov) Focus (f) : Will consider later

Eye Coordinate System View Reference Point (VRP) View Plane Normal (VPN) View Up (VUP) VRP (origin) VUP (Y-axis) VPN (Z-axis) Viewing Plane VUP  VPN (X-axis)

World to Eye Coordinates Translate World Origin to VRP Rotate World X, Y, Z to the Eye coordinate system, also known as the View Reference Coordinate system, VRC = (VUP  VPN, VUP, VPN), respectively: ( VUP  VPN ) 0 ( VUP ) 0 ( VPN )

Eye Coordinate System (OpenGL/GLU library) gluLookAt (eye x, eye y, eye z, lookat x, lookat y, lookat z, up x, up y, up z ); In our terminology: eye = VRP lookat = VRP + VPN up = VUP gluLookAt also works even if: –lookat is any point along the VPN –VUP is not perpendicular to VPN

gluLookAt() Image from: Interactive Computer Graphics by Ed Angel (Images Removed)

Eye Coordinate System (OpenGL/GLU library) This how the gluLookAt parameters are used to generate the eye coordinate system parameters: VRP = eye VPN = (lookat - eye) /  lookat - eye)   VUP = VPN  (up  VPN) The eye coordinate system parameters are then used in translation T(VRP) and rotation R(XYZ  VRC) to get the view-orientation matrix

(Russell Naughton) Camera Obscura "When images of illuminated objects... penetrate through a small hole into a very dark room... you will see [on the opposite wall] these objects in their proper form and color, reduced in size... in a reversed position, owing to the intersection of the rays". Da Vinci

Used to observe eclipses (eg., Bacon, ) By artists (eg., Vermeer).

(Jack and Beverly Wilgus) Jetty at Margate England, 1898.

Pinhole cameras Abstract camera model - box with a small hole in it Pinhole cameras work in practice (Forsyth & Ponce)

The equation of projection (Forsyth & Ponce)

The equation of projection Cartesian coordinates: –We have, by similar triangles, that (x, y, z) -> (f x/z, f y/z, f) –Ignore the third coordinate, and get

Perspective Projection Homogenize (divide by w’’= z / f) to get: –x’ = x / (z / f) = x’’/ w’’ –y’ = y / (z / f) = y’’/ w’’ –z’ = z / (z / f) = z’’/ w’’ = f /f 0 x y z 1 x’’ y’’ z’’ w’’ =

Distant objects are smaller (Forsyth & Ponce)

For example, consider one line segment from (x,0,z) to (x,y,z), and another from (x,0,2z) to (x,y,2z). These are the same length. These project in the image to a line from (fx/z,0) to (fx/z, fy/z) and from (fx/z,0) to (fx/2z, fy/2z), where we can rewrite the last point as: (1/2)(fx/z,fy/z). The second line is half as long as the first.

Parallel lines meet Common to draw image plane in front of the focal point. Moving the image plane merely scales the image. (Forsyth & Ponce)

Vanishing points Each set of parallel lines meets at a different point –The vanishing point for this direction Sets of parallel lines on the same plane lead to collinear vanishing points. –The line is called the horizon for that plane

For example, let’s consider a line on the floor. We describe the floor with an equation like: y = -1. A line on the floor is the intersection of that equation with x = az + b. Or, we can describe a line on the floor as: (a, -1, b) + t(c, 0, d) (Why is this correct, and why does it have more parameters than the first way?) As a line gets far away, z -> infinity. If (x,-1,z) is a point on this line, its image is f(x/z,-1/z). As z -> infinity, -1/z - > 0. What about x/z? x/z = (az+b)/z = a + b/z -> a. So a point on the line appears at: (a,0). Notice this only depends on the slope of the line x = az + b, not on b. So two lines with the same slope have images that meet at the same point, (a,0), which is on the horizon.

Properties of Projection Points project to points Lines project to lines Planes project to the whole image Angles are not preserved Degenerate cases –Line through focal point projects to a point. –Plane through focal point projects to line –Plane perpendicular to image plane projects to part of the image (with horizon).

Weak perspective (scaled orthographic projection) Issue –perspective effects, but not over the scale of individual objects –collect points into a group at about the same depth, then divide each point by the depth of its group (Forsyth & Ponce)

The Equation of Weak Perspective s is constant for all points. Parallel lines no longer converge, they remain parallel.

Parallel Projection Project on the plane, z = x y z 1 x’ y’ z’ 1 =

Cameras with Lenses (Forsyth & Ponce)

OpenGL for Projection Projection specifies clipping windows. glMatrixMode(GL_PROJECTION) glOrtho(xmin,xmax,ymin,ymax,dnear,dfar) gluPerspective(theta,aspect,dnear,dfar)