Download presentation
Presentation is loading. Please wait.
1
Computer Graphics Lecture 20
2
Computer Graphics Lecture 20 PROJECTIONS II Taqdees A. Siddiqi cs602@vu.edu.pk
3
Prospective Projection
How do you calculate the corresponding screen pixel?
5
This is a mathematical task as pictured
This is a mathematical task as pictured. However , we can make it much simpler if we impose the following requirements:
6
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
7
For our view to come out correctly, we will also want the Z axis to pass through the middle of the screen. Why ?
8
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:
10
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:
12
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:
14
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.
15
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).
16
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.
17
But we know what AB is –it is Screen.z! and
18
But we know what AB is –it is Screen.z! and
we know what AC is – it is point.z! and
19
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:
20
|BS| / |AB| = |CP| / |AC| |BS| = |AB| * |CP| / |AC| |BS| = Screen.z * point.x / point.z
21
Note that : Screen.z is the distance d from the point of view at origin or the scaling factor.
22
There is a final transformation that the points must go through in this transformation process.
23
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
24
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
25
Since in order to actually draw things on the screen we need to have absolute x,y coordinates
26
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:
29
The perspective Projection Matrix
The aspect ratio of screen (in terms of width and height), is calculated as:
31
With these parameters, the following projection matrix can be made:
32
Just for a sanity check, check out the result of this matrix multiplication:
33
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:
35
As you can see, this is exactly what was wanted
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
36
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
37
Vworld = VlocalMworld Vview =VworldMview Vscreen = VviewMprojecton Vscreen = Vlocal (MworldMviewMprojection)
38
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.
40
The viewing frustum is defined by fov (field of view) front and back clipping planes, specified in z-coordinates.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.