Interface Path
- All Superinterfaces:
Iterable<PathPosition>
-
Method Summary
Modifier and TypeMethodDescription@NonNull PathPosition
getEnd()
Returns the target position of the path@NonNull PathPosition
getStart()
Returns the start position of the pathinterpolate
(double resolution) Interpolates the positions of this Path to a new Path with the given resolution.Joins this Path with the given Path.int
length()
The length of the Path compiled from the number of positions@NonNull Path
mutatePositions
(ParameterizedSupplier<PathPosition> mutator) Mutates each of the positions in the path with the given consumersimplify
(double epsilon) Simplifies the path by removing intermediate positions based on the given epsilon value.trim
(int length) Trims this Path to the given length.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
length
int length()The length of the Path compiled from the number of positions- Returns:
- the length of the path
-
interpolate
Interpolates the positions of this Path to a new Path with the given resolution.The resulting path will have additional positions inserted between consecutive positions in the original path such that no two consecutive positions are more than `resolution` blocks apart. The interpolated positions are computed using linear interpolation, which means that the resulting path will have a smooth curve that passes through each of the original positions.
- Parameters:
resolution
- The desired distance between consecutive positions in the resulting path, in blocks. A lower value will result in a higher resolution and a smoother curve, but will also increase the number of positions in the resulting path and possibly reduce performance.- Returns:
- a newly created Path with interpolated positions.
-
simplify
Simplifies the path by removing intermediate positions based on the given epsilon value. The start and end positions are always included in the simplified path.- Parameters:
epsilon
- the epsilon value representing the fraction of positions to keep (should be in the range greater than 0.0 to 1.0, inclusive)- Returns:
- a simplified path containing a subset of positions from the original path
- Throws:
IllegalArgumentException
- if epsilon is not in the range greater than 0.0 to 1.0, inclusive
-
join
Joins this Path with the given Path.- Parameters:
path
- which will be appended at the end.- Returns:
Path
the new Path
-
trim
Trims this Path to the given length.- Parameters:
length
- the length to which the Path will be trimmed.- Returns:
Path
the new Path
-
mutatePositions
Mutates each of the positions in the path with the given consumer- Parameters:
mutator
- theParameterizedSupplier
to mutate the positions with- Returns:
Path
the new Path
-
getStart
Returns the start position of the path- Returns:
PathPosition
The position of the start
-
getEnd
Returns the target position of the path- Returns:
PathPosition
The position of the target
-