Module org.dyn4j

Class Visvalingam

  • All Implemented Interfaces:
    Simplifier

    public final class Visvalingam
    extends VertexClusterReduction
    implements Simplifier
    Simple polygon (without holes) simplifier that reduces the number of vertices by inspecting the area created by adjacent vertices. If the area created by three adjacent vertices is less than the given minimum, it's removed.

    This algorithm is typically used to pre-process a simple polygon before another simplification algorithm is used.

    This algorithm has O(n log n) complexity where n is the number of vertices in the source polygon. This algorithm prevents self-intersections arising from the simplification process by skipping the simplification.

    This method does not require the polygon to have any defined winding, but does assume that it does not have holes and is not self-intersecting.

    This method handles null/empty lists, null elements, and all null elements. In these cases it's possible the returned list will be empty or have less than 3 vertices.

    NOTE: This algorithm's result is highly dependent on the given cluster tolerance, minimum area and the input polygon. There's no guarantee that the result will have 3 or more vertices.

    Since:
    4.2.0
    Version:
    4.2.0
    Author:
    William Bittle
    See Also:
    Visvalingam
    • Constructor Detail

      • Visvalingam

        public Visvalingam​(double clusterTolerance,
                           double minimumTriangleArea)
        Minimal constructor.
        Parameters:
        clusterTolerance - the minimum distance between adjacent points
        minimumTriangleArea - the minimum triangular area at each vertex
        Throws:
        IllegalArgumentException - if clusterTolerance is less than zero or minimumTriangleArea is less than zero