Algorithm for Back Face Detection Method Visual Realism:
(a) Identify the first polygon of the solid, numbered in a counter-clockwise fashion for the viewer. Let the mj vertices of this polygon 1 be
vi (1), v j (2), . . . , v j (m j )
(b) Set v j (m j + 1), v j (1).
(c) Find k = ( x3 - x2 ) ( x1 - x2 ) + ( y3 - y2 ) ( y1 - y2 ) + ( z3 - z2 ) , from the coordinates of the first three vertices of polygon 1. If k < 0, go to Step (a), renumbering if necessary.
(d) Start polygon loop on i = 1 to n, n being the number of polygons.
(i) If i = 1 go to Step (e)
(ii) Let the number of vertices for polygon i be mi, and let the vertices be
vi (1), vi (2), . . . , vi (m) . Set vi (mi + 1) = vi (1) .
(iii) Start polygon loop on j = 1 to n.
(1) Let the number of vertices for polygon j be mj, and let the vertices be
v j (1), v j (2), . . . , v j (m j ) . Set v j (m j + 1) = v j (1) .
(2) Compare every sequential pair of vertex numbers p and q for polygon i, with every sequential pair of vertex numbers r and s for polygon j, except for j = i.
(3) If p = r and q = s, a straight match, then reverse the order of all mi vertices for polygon i. Go to Step (v).
(4) If p = s and q = r, a reverse match, then go to Step (v).
(iv) End loop on j.
(v) Find k = ( x2 - x1 ) ( y3 - y1 ) - ( x3 - x1 ) ( y2 - y1 ) , from the coordinates of the first three vertices of polygon i.
(vi) If k > 0, pass the coordinates of all mi vertices, and the edge and surface attributes of polygon i to the plot module.
(e) End loop on i.