C4 Engine Terathon Software C4 Engine API Documentation

• Math Library

API Links
Developer Links

Math::ClipSegmentAgainstPlane

Defined in:  C4Computation.h
Clips a line segment against a plane.
Prototype

bool ClipSegmentAgainstPlane(Point3D *p1, Point3D *p2, const Antivector4D& plane);

Parameters
p1 A pointer to the first endpoint of the line segment.
p2 A pointer to the second endpoint of the line segment.
plane The plane against which the line segment is clipped.
Description
The ClipSegmentAgainstPlane function clips the line segment specified by the p1 and p2 parameters against the plane specified by the plane parameter. Any portion of the line segment that falls on the negative side of the clipping plane is removed, and the endpoints of the clipped segment are returned by replacing the values pointed to by the p1 and p2 parameters. If both endpoints lie on the negative side of the clipping plane, then this function returns false, and the endpoints are not modified. If either one of the endpoints lies on the positive side of the plane (or on the plane itself), then this function returns true.