How perspective projection differs from orthogonal projection? Give OpenGL functions for the same


Q.) How perspective projection differs from orthogonal projection? Give OpenGL functions for the same

Subject: Computer Graphics and Visualization

Introduction

Projection in computer graphics is a method that involves transforming three-dimensional objects into a two-dimensional plane. This is crucial in the field of computer graphics and visualization as it allows us to represent 3D objects on 2D screens. There are two main types of projection used in computer graphics: perspective projection and orthogonal projection.

Perspective Projection

Definition and Explanation

Perspective projection is a type of projection where the lines of projection converge at a single point called the center of projection. This type of projection gives the illusion of depth and perspective, making faraway objects appear smaller than those close by. It is often used in 3D games and simulations to create a realistic view of the scene.

Mathematical Formula

The mathematical formula for perspective projection is given by:

P = M * V

where:

  • P is the projected point
  • M is the projection matrix
  • V is the 3D point in homogeneous coordinates

OpenGL Function

In OpenGL, the function used for perspective projection is gluPerspective(). This function specifies a viewing frustum into the world coordinate system. Here is an example of how to use it:

gluPerspective(45.0, aspect_ratio, 0.1, 100.0);

In this example, 45.0 is the field of view angle, aspect_ratio is the aspect ratio of the viewport, and 0.1 and 100.0 are the near and far clipping planes.

Properties

The properties of perspective projection include:

  • Parallel lines converge at a single point
  • Faraway objects appear smaller than nearby objects
  • It provides a realistic view of the scene

Example

An example of perspective projection in a real-world application is in 3D games where it is used to create a realistic view of the game environment.

Orthogonal Projection

Definition and Explanation

Orthogonal projection, also known as orthographic projection, is a type of projection where the lines of projection are parallel to each other. This means that the size and shape of the objects remain the same regardless of their position in the scene. Orthogonal projection is often used in technical drawings and CAD applications where accuracy and scale are important.

Mathematical Formula

The mathematical formula for orthogonal projection is given by:

P = M * V

where:

  • P is the projected point
  • M is the projection matrix
  • V is the 3D point in homogeneous coordinates

OpenGL Function

In OpenGL, the function used for orthogonal projection is glOrtho(). This function multiplies the current matrix with an orthographic matrix. Here is an example of how to use it:

glOrtho(left, right, bottom, top, nearVal, farVal);

In this example, left, right, bottom, and top specify the coordinates for the left, right, bottom, and top of the clipping plane, and nearVal and farVal specify the distances to the nearer and farther depth clipping planes.

Properties

The properties of orthogonal projection include:

  • Parallel lines remain parallel
  • The size and shape of objects remain the same regardless of their position in the scene
  • It does not provide a realistic view of the scene

Example

An example of orthogonal projection in a real-world application is in CAD software where it is used to create accurate and to-scale technical drawings.

Comparison between Perspective and Orthogonal Projection

Perspective Projection Orthogonal Projection
Parallel lines converge at a single point Parallel lines remain parallel
Faraway objects appear smaller The size and shape of objects remain the same
Provides a realistic view of the scene Does not provide a realistic view of the scene

Conclusion

Understanding the difference between perspective and orthogonal projection is crucial in the field of computer graphics and visualization. While perspective projection provides a realistic view of the scene, orthogonal projection is used when accuracy and scale are important. Both types of projection have their own uses and are essential tools in the field of computer graphics.

Note: Diagrams are not necessary for this question as the explanations and examples provided are sufficient to understand the concepts. However, if you prefer to include diagrams, you can draw a diagram showing the lines of projection for both perspective and orthogonal projection.

Summary

Projection in computer graphics is a method that involves transforming three-dimensional objects into a two-dimensional plane. There are two main types of projection used in computer graphics: perspective projection and orthogonal projection. Perspective projection converges lines of projection at a single point, giving the illusion of depth and perspective. OpenGL function for perspective projection is gluPerspective(). Orthogonal projection keeps parallel lines parallel and is used for technical drawings and CAD applications. OpenGL function for orthogonal projection is glOrtho().

Analogy

Projection in computer graphics is like taking a photograph of a three-dimensional object and transforming it into a two-dimensional image. Perspective projection is like taking a photo with a wide-angle lens, where objects closer to the camera appear larger than those farther away. Orthogonal projection is like taking a photo with a telephoto lens, where objects maintain their size regardless of their distance from the camera.

Quizzes
Flashcards
Viva Question and Answers

Quizzes

What is perspective projection?
  • A type of projection where lines of projection converge at a single point
  • A type of projection where parallel lines remain parallel
  • A method of transforming three-dimensional objects into a two-dimensional plane
  • A function in OpenGL for perspective projection