0% found this document useful (0 votes)
6 views51 pages

Lecture 20

Lecture 20 focuses on prospective projection in computer graphics, detailing how to calculate screen pixels from 3D points using geometric principles. It discusses the importance of the point of view and the screen's orientation, along with the mathematical transformations required to convert 3D coordinates into 2D. The lecture also introduces the perspective projection matrix and the concept of the viewing frustum, which defines the visible volume in 3D space.

Uploaded by

usmansaeed1512
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views51 pages

Lecture 20

Lecture 20 focuses on prospective projection in computer graphics, detailing how to calculate screen pixels from 3D points using geometric principles. It discusses the importance of the point of view and the screen's orientation, along with the mathematical transformations required to convert 3D coordinates into 2D. The lecture also introduces the perspective projection matrix and the concept of the viewing frustum, which defines the visible volume in 3D space.

Uploaded by

usmansaeed1512
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 51

Computer

Graphics
Lecture 20
Computer Graphics

Lecture 20
PROJECTIONS
II

Taqdees A. Siddiqi
[email protected]
Prospective Projection

How do you calculate the corresponding screen pixel?


This is a mathematical task as pictured. However , we
can make it much simpler if we impose the following
requirements:
The point of View(POV) must lie on the Z axis, The
screen plane must be prallel to the X,Y plane, with the
left and right edges of the screen parallel to the Y-axis,
And the top and bottom edges of the screen parallel to
the X-axis
For our view to come out correctly, we will also want the Z
axis to pass through the middle of the screen.
Why ?
Two common apporaches are used with this:
1. The first is where the POV is at same point (0,0,-z) and
the screen lies on the X-Y plane, graphically, this looks
like figure:
1. The second is where the POV lies at the origin, and the
screen lies on a plane at some +Z coordinate, as
shown in figure given below:
 Calculating the screen pixel that correlates to a 3D
point is now a matter of simple geometry. From a
viewpoint above the screen and POV (looking at the X-
Z plane), the geometry appears like the one shown in
this figure:
In geometric terms, we say that the triangle from A to B to
S is similar to the triangle from A to C to P because the
three angles that make up the triangles are the same;
the angle from AB to AS is the same as the angle from
AC to AP.
0
 The two rithg angles i.e. 90 , and therefore the
remaining two angles are the same (the sum of the
angles in a triangle is always 180 degrees).
What also holds true from similar triangles is that the ratio
of two sides also holds between the similar triangles;
this means that the ratio of BS to AB is the same as the
ratio of CP to AC.
But we know what AB is –it is Screen.z! and
But we know what AB is –it is Screen.z! and
we know what AC is – it is point.z! and
But we know what AB is –it is Screen.z! and
we know what AC is – it is point.z! and
we know what CP is – it is point.x!
Therefore:
|BS| / |AB| = |CP| / |AC|
|BS| = |AB| * |CP| / |AC|
|BS| = Screen.z *
point.x / point.z
Note that :
 Screen.z is the distance d from the point of view at
origin or the scaling factor.
 There is a final transformation that the points must go
through in this transformation process.
This transformation maps 3D points defined with respect
to the view origin (in view space) and turns them into
2D points that can be drawn on the display
 After transforming and clipping the polygons that make
up the scene such that they are visible on the screen,
the final step is to move them into 2D coordinates
 Since in order to actually draw things on the screen we
need to have absolute x,y coordinates
 The way this used to be done was without matrices,
just as an explicit projection calculation. The point
(x,y,z) would be mapped to (x`,y`) using the following
equations:
x
x`scale  xCenter
z
y
y`height  ( scale  yCenter )
z
The perspective Projection Matrix

 The aspect ratio of screen (in terms of width and


height), is calculated as:
height
aspect 
width
cos( fov)
w aspect
sin( fov)
cos( fov)
h
sin( fov)
Zfar
q
Zfar  Znert
 With these parameters, the following projection matrix
can be made:

w 0 0 0
0 h 0 0
0 0 q 1
 0 0  q( Znear ) 0 
 Just for a sanity check, check out the result of this
matrix multiplication:

w 0 0 0
 0 h 0 0  wx hy qz  q(Znear ) z
 x y z 1  0 0 q 1  
 0 0  q( Znear ) 0
 Since, after the multiplication, ‘w’ is set to z (which can
be any value)
 All four components need to be divided by z to get
normalized.
 This gives the following Cartesian coordinates:
 wx hy  ( Znear )  
 z z q 1   1 
  Z  
 As you can see, this is exactly what was wanted. The
width and height are still scaled by values as in the
above equation and they are still divided by z
 We then multiply the world, view, and projection
matrices together (in that order) to get a total matrix
that transforms point from object space to screen
space
Vworld = VlocalMworld
Vview =VworldMview
Vscreen = VviewMprojecton
Vscreen = Vlocal (MworldMviewMprojection)
The Viewing Frustm

 The volume within the pyramid between the frotn and


back clipping planes is the viewing frustum. Objects
are visible only when they are in this volume.
 The viewing frustum is defined by fov (field of view)
front and back clipping planes, specified in z-
coordinates.
1 0 0 0 
0 1 0 0 
P  1 
0 0 1
 D
0 0 0 1 
1 0 0 0
T  0 1 0 0
0 0 1 0
 0 0 D 1 
T *P
1 0 0 0 
0 1 0 0 
0 0 1 1 D
 0 0  D 0 
w 0 0 0
0 h 0 0
0 0 Q 1
 0 0  QZn 0 
w cot  fovw 
 2 

h cot  fov h 
 2 
Zf
Q
Zf  Zn

You might also like