Package org.dyn4j.geometry.simplify
Three implementations of the Simplifier
interface are provided:
VertexClusterReduction
,
Visvalingam
, and
DouglasPeucker
.
All three Simplifier
require tuning parameters to set the level
of allowed simplification.
NOTE: All Simplifier
algorithms operate on simple
polygons without holes and assume the input already confirms to this constraint.
All the algorithms in this package have O(n log n) complexity and are intended for use realtime, but selection of the tuning parameters will be the challenge. Generally, they should be chosen based on the input polygon to simplify. For example, imagine we have two polygons we want to simplify, A and B. Polygon A's vertices hover around the 1.02.0 units while Polygon B's vertices hover around the 100200 units. These might be the same polygon, but scaled, but would require different tuning parameters. The recommendation is to first scale the polygon down to a known range, then apply the simplification.
The VertexClusterReduction
algorithm is primarily for preprocessing
but can be used by itself. It's used, by default, in both the Visvalingam
and DouglasPeucker
classes.
Each algorithm has a different method for simplifying the input polygon and will therefore produce different results. It's also not guaranteed that the algorithms will produce a valid output in the case of poorly chosen tuning parameters  always check the output before sending to the next step (which is typically a convex decomposition process).
If the input is null, null is returned. If the input contains null elements, they are removed before
simplification. If the input is less than 4 vertices, no simplification is done and the input is returned
with exception of VertexClusterReduction
. If the tuning parameters, as
mentioned above, are not appropriate, the output can contain 0, 1, or 2 vertices  i.e. not a valid
simple polygon.
 Since:
 4.2.0
 Version:
 4.2.0
 Author:
 William Bittle

Interface Summary Interface Description Simplifier Represents a simple polygon (without holes) simplification algorithm. 
Class Summary Class Description AbstractSimplifier Abstract simplifier providing some shared logic for all simplifiers.DouglasPeucker Simple polygon (without holes) simplifier that reduces the number of vertices by removing points that are less than epsilon distance away from a guide line.VertexClusterReduction Simple polygon (without holes) simplifier that reduces the number of vertices by inspecting the distance between adjacent vertices.Visvalingam Simple polygon (without holes) simplifier that reduces the number of vertices by inspecting the area created by adjacent vertices.