Class NearClip_Line


  • public final class NearClip_Line
    extends Object
    Clip in camera space any LineSegment that crosses the camera's near clipping plane z = -near. Interpolate Vertex color from any clipped off Vertex to the new Vertex.

    This clipping algorithm is a simplification of the Liang-Barsky Parametric Line Clipping algorithm.

    • Method Detail

      • clip

        public static Optional<Primitiveclip​(Model model,
                                               LineSegment ls,
                                               Camera camera)
        If the LineSegment crosses the camera's near plane, then return a clipped version that is contained in the far side of the near plane. The new, clipped LineSegment object is returned wrapped in an Optional object.

        One new clipped Vertex object may be added to the Model's vertex list and one new interpolated Color object may be added to the model's color list.

        If the LineSegment is completely on the camera side of the near plane, then return an empty Optional object to indicate that the LineSegment should be discarded from the model's Primitive list.

        Parameters:
        model - Model that the LineSegment ls comes from
        ls - LineSegment to be clipped
        camera - Camera that determines the near clipping plane
        Returns:
        a clipped version of ls wrapped in an Optional object