DOC PREVIEW
UNM CS 433 - CS 433 Input and Interaction

This preview shows page 1-2-21-22 out of 22 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 22 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 22 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 22 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 22 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 22 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

1Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005Projection MatricesEd AngelProfessor of Computer Science,Electrical and ComputerEngineering, and Media ArtsUniversity of New Mexico2Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005Objectives• Derive the projection matrices used forstandard OpenGL projections• Introduce oblique projections• Introduce projection normalization3Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005Normalization• Rather than derive a different projectionmatrix for each type of projection, we canconvert all projections to orthogonalprojections with the default view volume• This strategy allows us to use standardtransformations in the pipeline and makesfor efficient clipping4Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005Pipeline View modelviewtransformation projectiontransformationperspective divisionclippingprojectionnonsingular4D → 3Dagainst default cube3D → 2DHidden surface removal5Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005Notes• We stay in four-dimensional homogeneouscoordinates through both the modelview andprojection transformations- Both these transformations are nonsingular- Default to identity matrices (orthogonal view)• Normalization lets us clip against simplecube regardless of type of projection• Delay final projection until end- Important for hidden-surface removal to retaindepth information as long as possible6Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005Orthogonal NormalizationglOrtho(left,right,bottom,top,near,far)normalization ⇒ find transformation to convertspecified clipping volume to default7Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005Orthogonal Matrix• Two steps- Move center to originT(-(left+right)/2, -(bottom+top)/2,(near+far)/2))- Scale to have sides of length 2S(2/(left-right),2/(top-bottom),2/(near-far))!!!!!!!!"#$$$$$$$$%&'+''+''''''1000200020002nearfarnearfarfarnearbottomtopbottomtopbottomtopleftrightleftrightleftrightP = ST =8Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005Final Projection• Set z =0• Equivalent to the homogeneous coordinatetransformation• Hence, general orthogonal projection in 4D is!!!!"#$$$$%&1000000000100001Morth = P = MorthST9Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005Oblique Projections• The OpenGL projection functions cannotproduce general parallel projections such as• However if we look at the example of thecube it appears that the cube has beensheared• Oblique Projection = Shear + OrthogonalProjection10Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005General Sheartop viewside view11Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005Shear Matrixxy shear (z values unchanged)Projection matrixGeneral case:! 1 0 "cot#00 1 "cot$00 0 1 00 0 0 1% & ' ' ' ' ( ) * * * * H(θ,φ) = P = Morth H(θ,φ) P = Morth STH(θ,φ)12Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005Equivalency13Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005Effect on Clipping• The projection matrix P = STH transformsthe original clipping volume to the defaultclipping volumetop viewDOPDOPnear planefar planeobjectclippingvolumez = -1z = 1x = -1x = 1 distorted object(projects correctly)14Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005Simple PerspectiveConsider a simple perspective with the COP at theorigin, the near clipping plane at z = -1, and a 90degree field of view determined by the planes x = ±z, y = ±z15Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005Perspective MatricesSimple projection matrix in homogeneouscoordinatesNote that this matrix is independent of thefar clipping plane! 1 0 0 00 1 0 00 0 1 00 0 "1 0# $ % % % % & ' ( ( ( ( M =16Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005Generalization! 1 0 0 00 1 0 00 0" #0 0 $1 0% & ' ' ' ' ( ) * * * * N =after perspective division, the point (x, y, z, 1) goes tox’’ = x/zy’’ = y/zZ’’ = -(α+β/z)which projects orthogonally to the desired point regardless of α and β17Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005Picking α and βIf we pickα = β = nearfarfarnear!+farnearfarnear2!"the near plane is mapped to z = -1the far plane is mapped to z =1and the sides are mapped to x = ± 1, y = ± 1Hence the new clipping volume is the default clipping volume18Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005NormalizationTransformationoriginal clipping volumeoriginal objectnew clipping volumedistorted objectprojects correctly19Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005Normalization andHidden-Surface Removal• Although our selection of the form of theperspective matrices may appear somewhatarbitrary, it was chosen so that if z1 > z2 in theoriginal clipping volume then the for thetransformed points z1’ > z2’• Thus hidden surface removal works if we firstapply the normalization transformation• However, the formula z’’ = -(α+β/z) implies that thedistances are distorted by the normalizationwhich can cause numerical problems especially ifthe near distance is small20Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005OpenGL Perspective•glFrustum allows for an unsymmetricviewing frustum (although gluPerspectivedoes not)21Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005OpenGL Perspective Matrix• The normalization in glFrustum requiresan initial shear to form a right viewingpyramid, followed by a scaling to get thenormalized perspective volume. Finally,the perspective matrix results in needingonly a final orthogonal transformationP = NSHour previously defined perspective matrixshear and scale22Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005Why do we do it this way?• Normalization allows for a single pipelinefor both perspective and orthogonalviewing• We stay in four dimensionalhomogeneous coordinates as long aspossible to retain three-dimensionalinformation needed for hidden-surfaceremoval and shading• We simplify


View Full Document

UNM CS 433 - CS 433 Input and Interaction

Download CS 433 Input and Interaction
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view CS 433 Input and Interaction and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view CS 433 Input and Interaction 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?