Search code examples
graphics3dvisualizationviewportprojection

Painter's theorem inside and outside test


I have read from Hearn and Baker computer graphics book. I read the test#2 painter's theorem which image is given below. Painter's theorem of test#2 image from Hearn and Baker

This image showing surface S is completely behind the surface S', by checking Substitute the coordinates of all vertices of S(x, y,z) into the plane equation of S' and check for the sign. If all vertices of S are inside S' then S is behind S'. (Fig. 1).

i. e. Ax + By+ Cz + D < 0 ,x, y, z are S vertices.

But I have read from this websites which showing this concepts but in totally opposite manner. See this image I read from that site, which showing opposite thing on same image. This showing all vertices of S are outside of S'.

i. e. Ax + By+ Cz + D > 0 ,x, y, z are S vertices.

My question is how is it possible Hearn and Baker saying S is completely inside the surface S' but my mentioned website saying S is outside of S' by sign test of plane equation?


Solution

  • The sign of the distance depends on S' orientation. Let me explain what is happening. When you substitute the points of S into the "implicit" equation of the S' plane you get a signed distance from the point to the S' plane. That distance is the shortest one because it goes in the direction of the normal vector of the S' plane.

    Now, there are two possible directions for the normal vector of the S' plane. Lets say you compute the normal vector N using whatever suitable method, then the negaive of that vector -N is also a normal vector to the plane i.e., you can form a valid plane equation using either N or -N.

    Usually in computer graphics the sense of normal vector is determined by the order of the vertices of the polygons. If they are clockwise the normal is -N (by convention) and if order is counterclock wise the notmal is N (by convention). Anyway, usually all planes in your space should have the same orientation so you don't need to care about that.

    So the discrepance on the sign can be regarded as a difference in orientation of the planes (CW v.s. CCW) or difference in coordinate systems (e.g., right handed v.s. left handed coordinate system). So both are correct under adequate assumptions. In the end, picking an orientation is a tecnicism or implementation detail.