|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.fhpotsdam.unfolding.utils.GeneralizationUtils
public class GeneralizationUtils
Provides utility functions to simplify points, paths, and polygons.
Constructor Summary | |
---|---|
GeneralizationUtils()
|
Method Summary | |
---|---|
protected static float[] |
computeMovingAverage(float[] values,
int np)
Calculates the np-point moving average for some values. |
static java.util.List<processing.core.PVector> |
computeMovingAverage(java.util.List<processing.core.PVector> vertices,
int np)
Calculates the moving average of vertices. |
protected static float |
getSquareDistance(processing.core.PVector p1,
processing.core.PVector p2)
Square distance between 2 points. |
protected static float |
getSquareSegmentDistance(processing.core.PVector p,
processing.core.PVector p1,
processing.core.PVector p2)
Square distance from a point to a segment. |
static java.util.List<processing.core.PVector> |
simplify(java.util.List<processing.core.PVector> points,
float tolerance,
boolean highestQuality)
Simplifies points by using Douglas-Peucker algorithm. |
protected static java.util.List<processing.core.PVector> |
simplifyDouglasPeucker(java.util.List<processing.core.PVector> points,
float sqTolerance)
Simplification using optimized Douglas-Peucker algorithm with recursion elimination. |
protected static java.util.List<processing.core.PVector> |
simplifyRadialDistance(java.util.List<processing.core.PVector> points,
float sqTolerance)
Distance-based simplification. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public GeneralizationUtils()
Method Detail |
---|
public static java.util.List<processing.core.PVector> computeMovingAverage(java.util.List<processing.core.PVector> vertices, int np)
Opposite to simplify(List, float, boolean)
this keeps the same amount of vertices, so does not improve
performance, but creates smoother paths. You might want to combine both methods.
vertices
- The vertices to smoothen.np
- The number of points to average over.
protected static float[] computeMovingAverage(float[] values, int np)
np
- number of points to average over.
public static java.util.List<processing.core.PVector> simplify(java.util.List<processing.core.PVector> points, float tolerance, boolean highestQuality)
Location
s due to the tolerance value.
Opposite to computeMovingAverage(List, int)
this reduces the amount of vertices, and thus improves
performance, but may result in still too complex paths. You might want to combine both methods.
Based on Simplify.js by Vladimir Agafonkin. Ported to Java and modified for Unfolding by Till Nagel.
points
- A list of vertices.tolerance
- The amount of simplification (in the same metric as the points).highestQuality
- Whether to exclude distance-based preprocessing step which leads to highest quality simplification but
runs ~10-20 times slower.
protected static float getSquareDistance(processing.core.PVector p1, processing.core.PVector p2)
protected static float getSquareSegmentDistance(processing.core.PVector p, processing.core.PVector p1, processing.core.PVector p2)
protected static java.util.List<processing.core.PVector> simplifyRadialDistance(java.util.List<processing.core.PVector> points, float sqTolerance)
points
- List of vertices.sqTolerance
- The square tolerance value.
protected static java.util.List<processing.core.PVector> simplifyDouglasPeucker(java.util.List<processing.core.PVector> points, float sqTolerance)
points
- List of vertices.sqTolerance
- The square tolerance value.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |