





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Computer Graphics involves technology to accept, process, transform and present information in a visual form that also concerns with producing images and animations using a computer. This course teach how to make your own design in computer using OpenGl. This lecture includes: Transformation, Matrix, Producing, Perpendicular, Projection, Orthongraphic, Obligue, Special, Alpha
Typology: Study notes
1 / 9
This page cannot be seen from the preview
Don't miss anything!






The transformation matrix for producing any parallel projection onto the xy plane can be written as
Now if Alpha = 90° (projection line is perpendicular to Projection Plane) then tan (Alpha) = infinity => L1 = 0, so have an orthographic projection. Two special cases of oblique projection Cavalier Cabinet 1) Cavalier Alpha = 45°, tan (Alpha) = 1 => L1 = 1 this is a Cavalier projection such that all lines perpendicular to the projection plane are projected with no change in length.
2) Cabinet tan (Alpha) = 2, Alpha= 63.40°, L1 = 1 / 2 Lines which are perpendicular to the projection plane are projected at 1 / 2 length. This is a Cabinet projection
Now that you have a structure that can store a three dimensional point (Point3D), how do you calculate the corresponding screen pixel? First, let’s look at what you are modeling. Following figure shows how it would look.
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, and the screen plane must be parallel 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 your view to come out correctly, you will also want the Z axis to pass through the middle of the screen. Why? The POV represents the viewer’s eye, and we presume that the viewer will be behind the center of the screen. Note : We will use Left hand rule to describe 3D coordinate system. Two common approaches are used with this;
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, the two right angles are both 90 degrees, 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 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 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
Screen.z is the distance d from the point of view at origin or the scaling factor. Notice that |BS| is the length of the line segment that goes from B to S in world units. But we normally address the screen with the point (0,0) at the top left, with +X pixels moving to the right, and +Y pixels moving down—and not from the middle of the screen. And we draw to the screen in pixel units – not our world units (unless, of course, 1.0 in your world represents one pixel).
There is a final transformation that the points must go through in the 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 you need to have absolute x, y coordinates on the screen to draw. 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
Where xCenter and yCenter were half of the width and height of the screen respectively, these days more complex equations are used, especially since there is now the need to make provisions for z-buffering. While you want x and y to still behave the same way, you don't want to use a value as arbitrary as scale. Instead, a better value to use in the calculation of the projection matrix is the horizontal field of view (fov). The horizontal fov will be hard coded, and the code chooses a vertical field of view that will keep the aspect ratio of the screen. This makes sense: You couldn't get away with using the same field of view for both horizontal and vertical directions unless the screen was square; it would end up looking vertically squashed. Finally, you also want to scale the z values appropriately. In future, We'll teach you about z-buffering, but for right now just make note of an important feature: They let you clip out certain values of z-range. Given the two variables znear and zfar , nothing in front of znear will be drawn, nor will anything behind zfar. To make the z-buffer work swimmingly on all ranges of znear and zfar , you need to scale the valid z values to the range of 0.0 to 1.0.
The Perspective Projection Matrix
The aspect ratio of screen, width and height is calculated as
With these parameters, the following projection matrix can be made:
Just for a sanity check, check out the result of this matrix multiplication:
positioned at the tip. This pyramid is intersected by a front and back clipping plane. The volume within the pyramid between the front and back clipping planes is the viewing frustum. Objects are visible only when they are in this volume.
If you imagine that you are standing in a dark room and looking through a square window, you are visualizing a viewing frustum. In this analogy, the near clipping plane is the window, and the back clipping plane is whatever finally interrupts your view—the skyscraper across the street, the mountains in the distance, or nothing at all. You can see everything inside the truncated pyramid that starts at the window and ends with whatever interrupts your view, and you can see nothing else.
The viewing frustum is defined by fov (field of view) and by the distances of the front and back clipping planes, specified in z-coordinates.
In this illustration, the variable D is the distance from the camera to the origin of the space that was defined in the last part of the geometry pipeline—the viewing transformation. This is the space around which you arrange the limits of your viewing frustum. For information about how this D variable is used to build the projection matrix The Matrix In the viewing frustum , the distance between the camera and the origin of the viewing
The viewing matrix translates the camera to the origin by translating in the z direction by
Multiplying the translation matrix by the projection matrix (T*P) gives the composite projection matrix. It looks like:
The following illustration shows how the perspective transformation converts a viewing frustum into a new coordinate space. Notice that the frustum becomes cuboid and also that the origin moves from the upper-right corner of the scene to the center.
In the perspective transformation, the limits of the x- and y-directions are -1 and 1. The limits of the z-direction are 0 for the front plane and 1 for the back plane. This matrix translates and scales objects based on a specified distance from the camera to the near clipping plane, but it doesn't consider the field of view ( fov ), and the z-values that it produces for objects in the distance can be nearly identical, making depth comparisons difficult. The following matrix addresses these issues, and it adjusts vertices to account for the aspect ratio of the viewport, making it a good choice for the perspective projection.