Class PathUtils
Path objects.
All methods are static, immutable (return new paths), and
use ArrayDeque internally for optimal performance when building sequences.
These operations are not part of core pathfinding but are essential for path refinement, visualization, animation, or coordinate transformation.
- Since:
- 5.3.3
- See Also:
-
PathPathPosition
-
Method Summary
Modifier and TypeMethodDescriptionstatic de.bsommerfeld.pathetic.api.pathing.result.Pathinterpolate(de.bsommerfeld.pathetic.api.pathing.result.Path path, double resolution) Deprecated.Interpolates a path by inserting intermediate positions between each pair of consecutive points.static de.bsommerfeld.pathetic.api.pathing.result.Pathjoin(de.bsommerfeld.pathetic.api.pathing.result.Path first, de.bsommerfeld.pathetic.api.pathing.result.Path second) Deprecated.Concatenates two paths into a single continuous path.static de.bsommerfeld.pathetic.api.pathing.result.PathmutatePositions(de.bsommerfeld.pathetic.api.pathing.result.Path path, de.bsommerfeld.pathetic.api.util.ParameterizedSupplier<de.bsommerfeld.pathetic.api.wrapper.PathPosition> mutator) Deprecated.Applies a transformation function to every position in the path.static de.bsommerfeld.pathetic.api.pathing.result.Pathsimplify(de.bsommerfeld.pathetic.api.pathing.result.Path path, double epsilon) Deprecated.Simplifies a path by retaining only every nth point based on an epsilon value.static de.bsommerfeld.pathetic.api.pathing.result.Pathtrim(de.bsommerfeld.pathetic.api.pathing.result.Path path, int maxLength) Deprecated.Truncates a path to a maximum number of positions.
-
Method Details
-
interpolate
public static de.bsommerfeld.pathetic.api.pathing.result.Path interpolate(de.bsommerfeld.pathetic.api.pathing.result.Path path, double resolution) Deprecated.Interpolates a path by inserting intermediate positions between each pair of consecutive points.For every segment from
starttoend, this method calculates the Euclidean distance and inserts points such that no two consecutive points are farther apart thanresolution.Useful for smooth movement, dense sampling, or visualization.
- Parameters:
path- the original path to interpolateresolution- the maximum allowed distance between any two consecutive points in the result- Returns:
- a new path with interpolated positions
- Throws:
IllegalArgumentException- ifresolution <= 0NullPointerException- ifpathisnull
-
simplify
public static de.bsommerfeld.pathetic.api.pathing.result.Path simplify(de.bsommerfeld.pathetic.api.pathing.result.Path path, double epsilon) Deprecated.Simplifies a path by retaining only every nth point based on an epsilon value.The stride is calculated as
max(1, round(1.0 / epsilon)), meaning:epsilon = 1.0→ keep every pointepsilon = 0.5→ keep every 2nd pointepsilon = 0.1→ keep every 10th point
This is a lightweight downsampling method. For geometric simplification (e.g. Ramer-Douglas-Peucker), use a dedicated algorithm.
- Parameters:
path- the path to simplifyepsilon- a value in (0.0, 1.0] controlling sampling density- Returns:
- a new simplified path
- Throws:
IllegalArgumentException- ifepsilonis not in (0.0, 1.0]
-
join
public static de.bsommerfeld.pathetic.api.pathing.result.Path join(de.bsommerfeld.pathetic.api.pathing.result.Path first, de.bsommerfeld.pathetic.api.pathing.result.Path second) Deprecated.Concatenates two paths into a single continuous path.The end of the first path is connected to the start of the second. If either path is empty, the other is returned.
- Parameters:
first- the first path segmentsecond- the second path segment- Returns:
- a new path combining both
- Throws:
NullPointerException- if either argument isnull
-
trim
public static de.bsommerfeld.pathetic.api.pathing.result.Path trim(de.bsommerfeld.pathetic.api.pathing.result.Path path, int maxLength) Deprecated.Truncates a path to a maximum number of positions.If the path has fewer than
maxLengthpositions, it is returned unchanged. Otherwise, only the firstmaxLengthpositions are kept.- Parameters:
path- the path to trimmaxLength- the maximum number of positions to retain- Returns:
- a new path with at most
maxLengthpositions - Throws:
IllegalArgumentException- ifmaxLength <= 0
-
mutatePositions
public static de.bsommerfeld.pathetic.api.pathing.result.Path mutatePositions(de.bsommerfeld.pathetic.api.pathing.result.Path path, de.bsommerfeld.pathetic.api.util.ParameterizedSupplier<de.bsommerfeld.pathetic.api.wrapper.PathPosition> mutator) Deprecated.Applies a transformation function to every position in the path.This is a functional map operation: each
PathPositionis passed to theParameterizedSupplier, and the returned position is included in the new path.Use cases:
- Coordinate system conversion (world → screen)
- Scaling, rotation, offset
- Adding metadata (e.g. timestamp, color)
- Path animation (e.g. oscillation)
- Parameters:
path- the original pathmutator- a function that transforms one position into another- Returns:
- a new path with transformed positions
- Throws:
NullPointerException- ifmutatorisnull
-