written 6.7 years ago by |
Back-Surface Detection method:-
We know that a polygon has two surfaces, a front and a back, just as a piece of paper does. we might picture our polygons with one side’ painted light and the other painted dark. But the question is how to find which surface is light or dark. When we are looking at the light surface. the polygon will appear to be drawn with Counter clockwise pen motions, and when we are looking at the dark surface the polygon will appear to be drawn with clockwise pen motions, as shown in the figure (a).
Let us assume that all solid objects are to be constructed out of polygons in such a way that only the light surfaces are open to the air; the dark faces meet the material inside the object. This means that when we look at an object face from the outside, it will appear to be drawn counter clockwise, as shown in the figure (b).
If a polygon is visible, the light surface should face towards us and the dark surface should face away from us. Therefore, if the direction of the light face is pointing towards the viewer, the face is visible (a front face), otherwise, the face is hidden (a back face) and should be removed.
The direction of the light face can be identified by examining the result
N.V > 0
where
N: Normal vector to the polygon surface with cartesian components (A, B, C).
V: A vector in the viewing direction from the eye (or camera) position (Refer Fig. (c)).
We know that, the dot product of two vector gives the product of the lengths of the two vectors times the cosine of the angle between them. This cosine factor is important to us because if the vectors are in the same direction (0 ≤ θ ≤ π/2), then the cosine is positive and the overall dot product is positive. However, if the directions are opposite (π/2 < θ ≤ π) then the cosine and the overall dot product is negative (Refer Fig (d)).
If the dot product is positive, we can say that the polygon faces towards the viewer; otherwise it faces away and should be removed.
In case, if object description has been converted to projection coordinates and our viewing direction is parallel to the viewing Zv, axis, then V = (0, 0, Vz) and
V. N = Vz C
So that we only have to consider the sign of C, the z component of the normal vector N. Now, if the z component is positive, then the polygon faces towards the viewer, if negative, it faces away.