Projection and Transformations Projection Linear Projection by nikeborome

VIEWS: 29 PAGES: 9

									                                                                                              Projection
 Projection and 3D Transformations                                                             Process of going from 3D scene to 2D scene
                                                                                               Studied throughout history (e.g. painters)
                                                                                               Different types of projection
              CS-184: Computer Graphics                                                         –   Linear
                                                                                                       Orthographic
                   Prof. James O’Brien                                                                 Perspective
                                                                                                –   Nonlinear
                                                                                               Many other “types” of linear mentioned in books
                                                                                                –   Just special cases of orthographic or perspective

                                                                                          1                                                             2




Linear Projection                                                                             Linear Projection

 Projection onto planar surface                                                                A 2D view
 Projection directions either
  –   converge to point
  –   are all parallel (a point at infinity)




                                                                                                Perspective                     Orthographic

                                                                                          3                                                             4




Linear Projection                                                                             Orthographic Projection

 A 2D view              Note how different things can be seen                                  No foreshortening
                                                      Parallel lines “meet” at infinity
                                                                                               Parallel lines stay parallel
                                                                                               Examples:




  Perspective                              Orthographic

                                                                                          5                                                             6




                                                                                                                                                            1
Orthographic Projection                                                         Orthographic Projection

  Assume looking down –Z axis                                                     Converting to canonical view setup
   –   “Z is in your face”
  View center at the origin
  View region is box defined by
   [-1,-1,-1] and [1,1,1]


                                                                     -Z

            [1,1,1]
                                            [-1,-1,-1]
                                                                                                                                     -Z
Throw X and Y coordinates map to normalized view port                                                         [1,1,1]   [-1,-1,-1]

                                                                           7                                                          8




Orthographic Projection                                                         Orthographic Projection

                                                          View vector           Step 1: translate center to origin

                Up vector


                                                         far,bottom,left

        Center

                      Right = view    up                 near,top,right


       Origin               *Assume up is perpendicular to view.
                                                                           9                                                          10




Orthographic Projection                                                         Orthographic Projection

Step 2: Rotate so that view aligns with –Z axis and                             Step 3: Center view volume
  up with +Y axis                                                               Step 4: Scale view volume




                                                                           11                                                         12




                                                                                                                                           2
  Orthographic Projection                                                              Orthographic Projection

   Step 1: translate center to origin                                                  Step 1: translate center to origin
   Step 2: Rotate so that view aligns with –Z axis and                                 Step 2: Rotate so that view aligns with –Z axis and
      up with +Y axis                                                                    up with +Y axis
   Step 3: Center view volume                                                          Step 3: Center view volume
   Step 4: Scale view volume                                                           Step 4: Scale view volume                  Mo
                       M = ST2 RT1                                                                   M = ST2 RT1 M
                                                                                                                   v
                                                                                  13                                                         14




  Window Transformation                                                                Detour: 3D Transformations

      Convert from [-1,-1],[+1,+1] window region to                                      With the exception of rotations, basically the
      image space                                                                        same as in 2D:
              y                                           x                                                     2D
                        [1,1]               [0,0]
                                                                   ce
                                                                 pa




                                               y
                                                                                                           tx
                                                               es




                         x
                                                              ag
                                                          im




                                                                                       ~          A
                                                           e
                                                        pl




                                                                                       A=
                                                      am




                                                                                                   ty                         A is 2 × 2
                                                    Ex




[-1,-1]                                                                 [MaxX,MaxY]

          Pixel centers offset by 0.5 ( e.g. 0.5, 1.5, 2.5 … MaxX-0.5 )
                                                                                               0 0 1
                         Mw       = Translate and scale
                                                                                  15                                                         16




  Detour: 3D Transformations                                                           Detour: 3D Transformations
                                                                                         Axis-aligned scales are still diagonal
      With the exception of rotations, basically the                                     Rotations still orthonormal w/ Det = +1
      same as in 2D:
                                                                                         Shear is a composition of rotation and scale
                                      3D
                                                                                         SVD and polar decomposition have the same
                                       tx                                                properties

   ~                   Aty                                                             BUT:
   A=                                                          A is 3 × 3                More than one way to rotate
                        tz                                                               Can rotate about any axis in space
                  0 0 0 1                                                                3 DOF for rotation, not just 1
                                                                                  17                                                         18




                                                                                                                                                  3
Detour: 3D Rotations                                        Detour: 3D Rotations

 2D implicitly rotating about axis “out of the page”         In 3D can rotate about one of coordinate axes

                                                              Example: rotation about X axis. (Other axes similar, see text.)

                                                                        1    0        0
            Cos(θ ) − Sin(θ )                                     R x = 0 Cos(θ ) − Sin(θ )
            Sin(θ ) Cos(θ )                                             0 Sin(θ ) Cos(θ )
                                                             Or about arbitrary axis (we’ll see shortly…)
                                                       19                                                                       20




Detour: 3D Rotations                                        Detour: 3D Rotations

Rotation Matrix Trivia:                                     Euler Angles
 AKA direction-cosine matrices                               Any rotation can be composed of one rotations
                                                             about each of the primary axes
 Orthonormal
 Det = +1                                                                        R = RzRyRx
 One real eigenvalue = 1                                     Allows tumbling
 Corresponding eigenvector is axis of rotation               Suffers from gimbal-lock
 Unique                                                      Non-unique

                                                       21                                                                       22




Detour: 3D Rotations                                        Detour: 3D Rotations

Angular Displacement                                        Angular Displacement
 AKA: exponential map, axis-angle                            Method 1 to arrive at rotation matrix
 Rotate degrees about axis                                    1. Rotate axis about X axis into X-Y plane
   is given by the length of the vector                       2. Rotate axis about Z axis to align with X axis
                                                              3. Rotate about X axis
                                                              4. Undo step 2
                                                              5. Undo step 3
                                                              –   Composite 5.4.3.2.1 together

                                                       23                                                                       24




                                                                                                                                     4
Detour: 3D Rotations                                 Detour: 3D Rotations

Angular Displacement                                 Angular Displacement
 Method 2 to arrive at rotation matrix                Method 2 to arrive at rotation matrix
                                                       –   x does not change
  r                                                    –   x ⊥ rotates like 2D rotation
                           x⊥              x⊥                                                        x⊥
         x                           r                                                        x⊥ r
                    x                                                                     x

                                                25                                                    26




Detour: 3D Rotations                                 Detour: 3D Rotations

Angular Displacement                                 Angular Displacement
 Method 2 to arrive at rotation matrix                Method 2 to arrive at rotation matrix




                                                27                                                    28




Detour: 3D Rotations                                 Detour: 3D Rotations
                                                     Quaternions
Angular Displacement
 Allows tumbling
 No gimbal lock
 Orientations are space within   radius ball
 Nearly unique representation
 Singularities are shells at 2
 Nice for interpolation

                                                29                                                    30




                                                                                                           5
Detour: 3D Rotations                              Detour: 3D Rotations
Quaternions                                       Quaternions
 Multiplication                                    Represent vectors with



 Conjugate
                                                   Represent rotation with
 Mgnitude



                                             31                                                        32




Detour: 3D Rotations                              Detour: 3D Rotations
Quaternions
 Rotate a point using quaternions                 Quaternions
                                                   No tumbling
                                                   No gimbal lock
                                                   Orientations are 3D sphere in R4
 Compose rotations                                 Double representation
                                                   No singularities
                                                   Nice for interpolation

                                             33                                                        34




Detour: 3D Rotations                              Detour: 3D Rotations

 Relationship between exponential maps and         Consider
 quaternions…                                                   rxx    rxy   rxz   1 0 0
                                                           RI = ryx    ryy   ryz   0 1 0
                                                                rzx    rzy   rzz   0 0 1
                                                   Columns of rotation matrix are axes of coordinate
                                                   system after rotation
                                                   Rows are original axes expressed in the rotated
                                                   coordinate system
                                             35                                                        36




                                                                                                            6
Orthographic Projection (back from a long detour)          Orthographic Projection

Step 1: translate center to origin                         Step 2: Rotate so that view aligns with –Z axis and
Step 2: Rotate so that view aligns with –Z axis and         up with +Y axis
  up with +Y axis
Step 3: Center view volume                                         Right x        Up x         − View x
Step 4: Scale view volume                 Mo               R = Right y            Up y         − View y
              M = ST2 RT1 M                                    Right z            Up z         − View z
                            v
                                                      37                                                         38




Perspective Projection                                     Pinhole Camera

  Foreshortening: further things get smaller
  Some parallel lines stay parallel, most don’t
  Lines still look like lines
  Z ordering preserved for what we care about




                                                      39                                                         40




Perspective Projection                                     Perspective Projection
  Foreshortening: distant things are smaller                Draw “ film” in front or pinhole




                                                      41                                                         42




                                                                                                                      7
Perspective Projection                                               Perspective Projection

 Vanishing points                                                      Vanishing points
  –   Depend on scene, not intrinsic to camera                         –   Depend on scene, not intrinsic to camera

                                       One point perspective                                               Two point perspective




                                                                43                                                                 44




Perspective Projection                                               Perspective Projection

 Vanishing points                                                                                          View frustrum
  –   Depend on scene, not intrinsic to camera

                                      Three point perspective



                                                                                                                  u
                                                                                                       v
                                                                                                              n

                                                                45                                                                 46




Perspective Projection                                               Perspective Projection
              Far
      Near                                             Top           Step 1: Translate Center to origin


  Y                                                    Bottom          Y
                                        View
                Up




             Center
                                 Distance to image plane
                        -Z                                                                   -Z
                                                                47                                                                 48




                                                                                                                                        8
Perspective Projection                                           Perspective Projection

Step 2: Rotate to align                                          Step 3: Shear so that center-line moves to –Z axis
          view with –Z axis
          up with Y axis                                                               Y
    Y




                                                                                                          -Z
                          -Z
                                                            49                                                        50




Perspective Projection                                           Perspective Projection

Step 4: Scale so that image plane is at Z=-1                     Step 5: Perspective

                      Y




                                         -Z

                                                            51                                                        52




Perspective Projection

Step 5: Perspective                                                  Vanishing points limits


           1 0         0       0
           0 1         0       0
                      n+ f
   Mp = 0 0                    −f
                       n
                       1
           0 0                 0
                       n
                                               Err n vs i
                                                            53                                                        54




                                                                                                                           9

								
To top