Back-Face Detection Method


Programming languages are used for many purposes such as making websites, developing mobile applications, etc. Graphic designing is one of the things that we can do by using the programming language. While graphic designing, we can face a problem where we have to project a 3-D object on the 2-D plane and due to which one dimension will be reduced or one face will be hidden. In this problem, we have to detect that hidden face.

Back-Face detection is also known as the name Plane Equation method, and it is a method for the object space methods in which objects or basically the parts of the given objects are compared with each other to find if a 3-D object will be cast on the 2-D surface then what surfaces are the visible.

Let us assume we have a prism that consists of three triangular faces and one face will not be visible. We will go for the current face of the prism that may not be visible to the user, if the current face is not visible to the user, then we will leave it or discard it and move to the next face.

Each plane has a normal vector, if the current’s plane normal vector is pointing away from the centre of the projection, then the face is not visible to the user otherwise it is visible to the user.

Three-Dimension Systems

In three-dimension system we have three dimensions, let us say x, y, and z dimensions. We assume the x and y dimensions are our final 2-Dimensions and the z dimension is the 3rd dimension which will be reduced.

The z dimension can be assumed in two ways, first either it's going inward or the left-handed system or it is coming outside from the 2-D plane and it is the right-handed system. For both systems, the algorithm will be different. Let us see both dimensions one by one −

Algorithm for Left-handed System

For the left-handed system the steps will be as follow −

  • First, we will get the normal vector N, for each face of the given object.

  • Then we will compute its dot product with the normal vector of the centre C.

  • If the Z component is less than zero then the current face is the back face and no need to draw it.

  • Otherwise, the current face will be visible and we will draw it.

From the above steps, we can conclude that the back-face detection method is very simple for the right-handed system. If the z-component of the given vector is greater than zero then the current face is the front face otherwise it is the back face.

Algorithm for Right-handed System

For the left-handed system the steps will be as follow −

  • First, we will get the normal vector N, for each face of the given object.

  • Then we will compute its dot product with the normal vector of the centre C.

  • If the Z component is less than zero then the current face is the back face and no need to draw it.

  • Otherwise, the current face will be visible and we will draw it.

From the above steps, we can conclude that the back-face detection method is very simple for the right-handed system. If the z-component of the given vector is greater than zero then the current face is the front face otherwise it is the back face.

Example

For example, we have a polygon, and a particular point of the face has the coordinates (A, B, C) or the normal vector has these variables in it. Also, from the equation of the polygon we can have −

Ax + By + Cz + D < 0

Where, D is a constant.

The normal vector of the current face is the

N = (A, B, C)

The current face is a front face if we have V.N < 0. Which is equivalent to the equation for back face as −

(0, 0, -1).N > 0
Or 
C < 0

Here V is the surface vector.

Limitations of Current Method

The above method works fine most of the times but there are some limitations of the given method −

  • For the concave polyhedral this method may not work properly but for the convex polyhedral this works always fine.

  • The above given method only works fine with the solid objects and not the modelled for example polygon mesh.

Conclusion

In the above tutorial, we have learned a method to detect the back face when casting 3-D objects on the 2-D plane. The back-face detection method is very simple for the left-handed system. If the z-component of the given vector is less than zero then the current face is the front face. If the z-component of the given vector is greater than zero then the current face is the front face otherwise it is the back face.

Updated on: 01-Sep-2023

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements