Previous: clppg3 Up: ../plot79_c.html Next: clppi
SUBROUTINE CLPPH (P1,P2,NORMAL,NPLANE,MOVED1,MOVED2,REJECT,
X ALPHA1,ALPHA2)
C$ (4-Dimensional Polyhedron Clip)
C$ Clip a line segment defined by its endpoints in
C$ 4-dimensional homogeneous coordinates to a convex
C$ polyhedron defined by a series of planes in space. The
C$ arguments are:
C$
C$ P1(*)..........(X,Y,Z,H) coordinates of first point.
C$ P2(*)..........(X,Y,Z,H) coordinates of second point.
C$ NORMAL(4,*)....REAL array containing the homogeneous
C$ surface normals of the planes defining the
C$ polyhedron. These must point to the visible
C$ side of the plane.
C$ NPLANE.........Number of clipping planes.
C$ MOVED1.........LOGICAL value set .TRUE. if point 1 is moved.
C$ MOVED2.........LOGICAL value set .TRUE. if point 2 is moved.
C$ REJECT.........LOGICAL value set .TRUE. if the segment is
C$ rejected (i.e. invisible). If the line is
C$ rejected, ALPHA1 and ALPHA2 will be
C$ unchanged on return.
C$ ALPHA1.........Parameter alpha for the first point in the
C$ parametric line representation (1-alpha)*P1
C$ + alpha*P2.
C$ ALPHA2.........Parameter alpha for the second point.
C$
C$ The normal vectors need not be unit vectors. If the
C$ equation defining a plane is AX + BY + CZ + D = 0, then the
C$ homogeneous normal vector is simply (A,B,C,D). To ensure
C$ that the normal points to the visible side, it is
C$ sufficient to choose its sign such that the dot product of
C$ the normal with the homogeneous coordinates of any point on
C$ the visible side is positive. As an example, the planes
C$ defining a box with X in (-2,3), Y in (-4,5), and Z in
C$ (-6,7) are as follows:
C$
C$ ( A B C D)
C$ LEFT = ( 1, 0, 0, 2)
C$ RIGHT = (-1, 0, 0, 3)
C$ BOTTOM = ( 0, 1, 0, 4)
C$ TOP = ( 0,-1, 0, 5)
C$ NEAR = ( 0, 0, 1, 6)
C$ FAR = ( 0, 0,-1, 7)
C$
C$ The far plane is defined by the equation 0X + 0Y - Z + 7 =
C$ 0, or Z = 7 (assuming a left-handed coordinate system as is
C$ usually the case in computer graphics). The point
C$ (0,0,0,1) is inside the box, and its dot product with the
C$ far clipping plane normal is 0*0 + 0*0 - 0*1 + 1*7 = 7,
C$ which is positive and thus verifies that the normal points
C$ to the visible side.
C$
C$ Author: John Halleck, University of Utah Computing Center,
C$ Salt Lake City, Utah 84112, USA
C$ (03-APR-82)