projection part 2 derivation created by dr slim bechikh
play

Projection (Part 2) : Derivation Created by Dr. Slim BECHIKH for - PowerPoint PPT Presentation

Projection (Part 2) : Derivation Created by Dr. Slim BECHIKH for SPSU course - CS4363 Computer Graphics and Multimedia Fall 2014 Parallel Projection normalization find 4x4 matrix to transform user


  1. Projection (Part 2) : Derivation Created by Dr. Slim BECHIKH for SPSU course - CS4363 Computer Graphics and Multimedia Fall 2014

  2. Parallel � Projection � � normalization � find � 4x4 � matrix � to � transform � user � specified � view � volume to � canonical � view � volume � (cube) User � specified View � Volume Canonical � View � Volume glOrtho (left, right, bottom, top,near, far)

  3. Parallel � Projection: � Ortho � Parallel � projection: � 2 � parts Translation: centers � view � volume � at � origin 1.

  4. Parallel � Projection: � Ortho Scaling: reduces � user � selected � cuboid � to � canonical � 2. cube � (dimension � 2, � centered � at � origin)

  5. Parallel � Projection: � Ortho Translation � lines � up � midpoints: �� E.g. midpoint � of � x � = � (right � + � left)/2 � Thus � translation � factors: � � (right � + � left)/2, ���� (top � + � bottom)/2, ����� (far+near)/2 � � Translation � matrix: � � � � 1 0 0 ( right left ) / 2 � � � � � � 0 1 0 ( top bottom ) / 2 � � � � 0 0 1 ( far near ) / 2 � � � � � 0 0 0 1 �

  6. Parallel � Projection: � Ortho Scaling � factor: � ratio � of � ortho � view � volume � to � cube � dimensions � Scaling � factors: �� 2/(right �� left), ��� 2/(top �� bottom), ��� 2/(far �� near) � Scaling � Matrix � M2: � � � 2 � � 0 0 0 � � right left � � � 2 0 0 0 � � � top bottom � � 2 � � 0 0 0 � � � far near � � � 0 0 0 1 �

  7. Parallel � Projection: � Ortho Concatenating Translation x Scaling , we get Ortho Projection matrix � � 2 � � � � � � 0 0 0 1 0 0 ( right left ) / 2 � � � � right left � � � � � 2 � � 0 1 0 ( top bottom ) / 2 0 0 0 � � X � � � top bottom � � � � 0 0 1 ( far near ) / 2 2 � � � � 0 0 0 � � � � � far near � 0 0 0 1 � � � � 0 0 0 1 � � � � 2 right left � 0 0 � � � � right left right left � � � 2 top bottom � � � 0 0 � � � � top bottom top bottom P = ST = � � � 2 far near � � 0 0 � � near far far near � � � � � 0 0 0 1 �

  8. Final � Ortho � Projection � Set � z =0 � Equivalent � to � the � homogeneous � coordinate � transformation � � 1 0 0 0 � � 0 1 0 0 � � M orth = � � 0 0 0 0 � � 0 0 0 1 � � � Hence, � general � orthogonal � projection � in � 4D � is P = M orth ST

  9. Perspective � Projection � Projection � – map � the � object �� from � 3D � space � to � 2D � screen � y z x Perspective() Frustrum( )

  10. Perspective � Projection: � Classical � Projectors Object in 3 space Projected image VRP COP Projection plane y (x,y,z) Based on similar triangles: (x’,y’,z’) (0,0,0) y’ N = y -z - z + z -N N y’ = y x -z -z Eye (COP) Near Plane (VOP)

  11. Perspective � Projection: � Classical � So � (x*,y*) � projection � of � point, � (x,y,z) � unto � near � plane � N � is � given � as: Projectors Object in 3 space � � N N � � � � � Projected image x *, y * x , y � � � � z z � � VRP COP � Numerical � example: Q. � Where � on � the � viewplane does � P � = � (1, � 0.5, �� 1.5) � lie � for � a � near � plane � at � N � = � 1? � � � � N N 1 1 � � � � � � � � � � � x *, y * x , y 1 , 0 . 5 ( 0 . 666 , 0 . 333 ) � � � � � � z z 1 . 5 1 . 5 � �

  12. Pseudodepth � Classical � perspective � projection � projects � (x,y) � coordinates � to � (x*, � y*), � drops � z � coordinates Map to same (x*,y*) Projectors Compare their z values? Object in 3 space Projected image (0,0,0) VRP z COP � But � we � need � z � to � find � closest � object � (depth � testing)!!!

  13. Perspective � Transformation � Perspective � transformation maps � actual � z � distance � of � perspective � view � volume � to � range � [ � –1 � to � 1] � ( Pseudodepth ) � for � canonical � view � volume Actual view volume We want perspective Actual depth Transformation and NOT classical projection!! -Near -Far Canonical view volume Pseudodepth Set scaling z Pseudodepth = az + b Next solve for a and b -1 1

  14. Perspective � Transformation � We � want � to � transform � viewing � frustum � volume � into � canonical � view � volume (1, 1, -1) y z (-1, -1, 1) x Canonical View Volume

  15. Perspective � Transformation � using � Pseudodepth � � � N az b N � � � � � x *, y *, z * x , y , � � � � � z z z � � � Choose � a, � b � so � as � z � varies � from � Near � to � Far , � pseudodepth varies � from � –1 � to 1 � (canonical � cube) Actual view volume Boundary � conditions � Actual depth z* � = �� 1 � when � z � = �� N � � Z z* � = � 1 � when � z � = �� F � -Near -Far Pseudodepth Canonical view Z* volume 1 -1

  16. Transformation � of � z: � Solve � for � a � and � b � Solving: � az b � z * � z � Use � boundary � conditions � z* � = �� 1 � when � z � = �� N………(1) � � z* � = � 1 � when � z � = �� F………..(2) � Set � up � simultaneous � equations � � aN b � � � � � � � 1 N aN b ........( 1 ) N � � aF b � � � � � 1 F aF b ........( 2 ) F

  17. Transformation � of � z: � Solve � for � a � and � b � � � � N aN b ........( 1 ) � � � F aF b ........( 2 ) � Multiply � both � sides � of � (1) � by �� 1 � � � N aN b ........( 3 ) � Add � eqns (2) � and � (3) � � � F N aN aF � � � F N ( F N ) � � � a .........( 4 ) � � N F F N � Now � put � (4) � back � into � (3)

  18. Transformation � of � z: � Solve � for � a � and � b � Put � solution � for � a � back � into � eqn � (3) � � N aN b ........( 3 ) � � N ( F N ) � � � N b � F N � � N ( F N ) � � � � b N � F N � � � � � � � � � 2 2 N ( F N ) N ( F N ) NF N NF N 2 NF � � � � b � � � F N F N F N � So � � � � ( F N ) 2 FN � � a b � � F N F N

  19. What � does � this � mean? � Original � point � z � in � original � view � volume, � transformed � into � z* � in � canonical � view � volume Actual view Original volume � az b vertex z value � z * � z -Near -Far � where � � ( F N ) � a � Transformed F N Canonical view vertex z* value volume � 2 FN � b � F N -1 1

  20. Homogenous � Coordinates � Want � to � express � projection � transform � as � 4x4 � matrix � Previously, � homogeneous � coordinates � of � P � = � (Px,Py,Pz) �� => �� (Px,Py,Pz,1) � Introduce � arbitrary � scaling � factor, � w, � so � that � P � = � (wPx, � wPy, � wPz, � w) ����� ( Note: � w � is � non � zero) � For � example, � the � point � P � = � (2,4,6) � can � be � expressed � as � (2,4,6,1) � � or � (4,8,12,2) � where � w=2 � � or � (6,12,18,3) � where �� w � = � 3, � or…. � To � convert � from � homogeneous � back � to � ordinary � coordinates, � first � divide � all � four � terms � by � w and � discard � 4 th term

  21. Perspective � Projection � Matrix � Recall � Perspective � Transform � � � N az b N � � � � � x *, y *, z * x , y , � � � � � z z z � � � � We � have: � N N az b � � � y * y x * x z * � � � z z z � In � matrix � form: � � N � � x � � � � � � � N 0 0 0 wx wNx z � � � � � � � � N � � � � � � � � 0 N 0 0 wy wNy y � � � � � � � � � � � z � 0 0 a b wz w ( az b ) � � � � � � � � � az b � � � � � � � � � � � 0 0 1 0 � � w � � wz � � z � � � 1 � Perspective Transformed Original Transformed Vertex Transform Matrix Vertex vertex after dividing by 4 th term

Recommend


More recommend