Package arc.math.geom
Class Bresenham2
java.lang.Object
arc.math.geom.Bresenham2
Returns a list of points at integer coordinates for a line on a 2D grid, using the Bresenham algorithm.
Instances of this class own the returned array of points and the points themselves to avoid garbage struct as much as possible. Calling any of the methods will result in the reuse of the previously returned array and vectors.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionline
(int startX, int startY, int endX, int endY) Returns a list ofPoint2
instances along the given line, at integer coordinates.static void
Iterates through a list ofPoint2
instances along the given line, at integer coordinates.Returns a list ofPoint2
instances along the given line, at integer coordinates.Returns a list ofPoint2
instances along the given line, at integer coordinates.lineNoDiagonal
(int startX, int startY, int endX, int endY, Pool<Point2> pool, Seq<Point2> output) Returns a list ofPoint2
instances along the given line at integer coordinates, with no diagonals.
-
Constructor Details
-
Bresenham2
public Bresenham2()
-
-
Method Details
-
line
Iterates through a list ofPoint2
instances along the given line, at integer coordinates.- Parameters:
startX
- the start x coordinate of the linestartY
- the start y coordinate of the lineendX
- the end x coordinate of the lineendY
- the end y coordinate of the line
-
line
Returns a list ofPoint2
instances along the given line, at integer coordinates.- Parameters:
start
- the start of the lineend
- the end of the line- Returns:
- the list of points on the line at integer coordinates
-
line
Returns a list ofPoint2
instances along the given line, at integer coordinates.- Parameters:
startX
- the start x coordinate of the linestartY
- the start y coordinate of the lineendX
- the end x coordinate of the lineendY
- the end y coordinate of the line- Returns:
- the list of points on the line at integer coordinates
-
line
public Seq<Point2> line(int startX, int startY, int endX, int endY, Pool<Point2> pool, Seq<Point2> output) Returns a list ofPoint2
instances along the given line, at integer coordinates.- Parameters:
startX
- the start x coordinate of the linestartY
- the start y coordinate of the lineendX
- the end x coordinate of the lineendY
- the end y coordinate of the linepool
- the pool from which Point2 instances are fetchedoutput
- the output array, will be cleared in this method- Returns:
- the list of points on the line at integer coordinates
-
lineNoDiagonal
public Seq<Point2> lineNoDiagonal(int startX, int startY, int endX, int endY, Pool<Point2> pool, Seq<Point2> output) Returns a list ofPoint2
instances along the given line at integer coordinates, with no diagonals.- Parameters:
startX
- the start x coordinate of the linestartY
- the start y coordinate of the lineendX
- the end x coordinate of the lineendY
- the end y coordinate of the linepool
- the pool from which Point2 instances are fetchedoutput
- the output array, will be cleared in this method- Returns:
- the list of points on the line at integer coordinates
-