public class Snapper2D extends Snapper
Modifier and Type | Field and Description |
---|---|
private Point2D[] |
grid |
private double[] |
gridDiffs |
private double[] |
gridSums |
distanceFunction, lineDistanceFunction
Constructor and Description |
---|
Snapper2D(AbstractMetric distanceFunction,
DistanceFunctionType lineDistanceFunction,
int xSize,
int ySize) |
Modifier and Type | Method and Description |
---|---|
Point2D[] |
createGrid(int xSize,
int ySize) |
Point2D[] |
getNeighbouringUnits(Point2D p)
Finds the four units around the given point.
|
Point2D[] |
snap(Point2D[] line)
Returns a snapped line of the given line.
|
Point2D[][] |
snap(Point2D[][] lines) |
private Point2D[] |
snapPoint(Point2D startPoint,
Point2D[] line,
int currentPosition,
int direction)
Snaps the next point on the line.
|
private Point2D[] grid
private double[] gridSums
private double[] gridDiffs
public Snapper2D(AbstractMetric distanceFunction, DistanceFunctionType lineDistanceFunction, int xSize, int ySize)
public Point2D[] createGrid(int xSize, int ySize)
private Point2D[] snapPoint(Point2D startPoint, Point2D[] line, int currentPosition, int direction)
startPoint
- the point to start fromline
- the line to snapcurrentPosition
- the current position on the linedirection
- forward (1) or backwards (-1)public Point2D[] snap(Point2D[] line)