Class PathPosition
java.lang.Object
de.bsommerfeld.pathetic.api.wrapper.PathPosition
- All Implemented Interfaces:
Cloneable
Represents a position. This class encapsulates the coordinates (x, y, z) of a point in the
pathfinding environment and provides methods for manipulating and comparing positions.
-
Constructor Summary
ConstructorsConstructorDescriptionPathPosition(double x, double y, double z) Constructs aPathPositionwith the specified coordinates. -
Method Summary
Modifier and TypeMethodDescriptionadd(double x, double y, double z) Creates a newPathPositionby adding the given values to the coordinates of this position.add(PathVector vector) Creates a newPathPositionby adding the components of the given vector to the coordinates of this position.clone()doubledistance(PathPosition otherPosition) Calculates the Euclidean distance between this position and another position.doubledistanceSquared(PathPosition otherPosition) Calculates the squared distance between this position and another position.booleanfloor()Creates a newPathPositionwith the coordinates floored to the nearest integer values.doubledoubledoubleintReturns the x-coordinate of the block this position is located in.intReturns the y-coordinate of the block this position is located in.intReturns the z-coordinate of the block this position is located in.doublegetX()Returns the x-coordinate of this position.doublegetY()Returns the y-coordinate of this position.doublegetZ()Returns the z-coordinate of this position.inthashCode()interpolate(PathPosition other, double progress) Deprecated.marked for removalbooleanisInSameBlock(PathPosition otherPosition) Deprecated.useequals(Object)doublemanhattanDistance(PathPosition otherPosition) Deprecated.marked for removalmid()Creates a newPathPositionwith the coordinates set to the center of the block they are in.midPoint(PathPosition end) Calculates the midpoint between this position and another position.doubleoctileDistance(PathPosition otherPosition) Deprecated.marked for removalsetX(double x) Creates a newPathPositionwith the same coordinates as this one, but with the x-coordinate set to the given value.setY(double y) Creates a newPathPositionwith the same coordinates as this one, but with the y-coordinate set to the given value.setZ(double z) Creates a newPathPositionwith the same coordinates as this one, but with the z-coordinate set to the given value.subtract(double x, double y, double z) Creates a newPathPositionby subtracting the given values from the coordinates of this position.subtract(PathVector vector) Creates a newPathPositionby subtracting the components of the given vector from the coordinates of this position.toString()toVector()Creates a newPathVectorfrom the coordinates of this position.
-
Constructor Details
-
PathPosition
public PathPosition(double x, double y, double z) Constructs aPathPositionwith the specified coordinates.- Parameters:
x- The x-coordinate of the position.y- The y-coordinate of the position.z- The z-coordinate of the position.
-
-
Method Details
-
interpolate
Deprecated.marked for removalInterpolates between this position and another position based on a given progress value.- Parameters:
other- The other position to interpolate towards.progress- The interpolation progress, typically between 0.0 (this position) and 1.0 (other position).- Returns:
- A new
PathPositionrepresenting the interpolated point.
-
isInSameBlock
Deprecated.useequals(Object)Checks if this position and another position are within the same block in the environment.- Parameters:
otherPosition- The other position to compare with.- Returns:
trueif both positions share the same block coordinates (floored x, y, z values),falseotherwise.
-
manhattanDistance
Deprecated.marked for removalCalculates the Manhattan distance between this position and another position. Manhattan distance is the sum of the absolute differences of their coordinates.- Parameters:
otherPosition- The other position to calculate the distance to.- Returns:
- The Manhattan distance between the two positions.
-
octileDistance
Deprecated.marked for removalCalculates the Octile distance between this position and another position. Octile distance is a more accurate approximation of diagonal distance in a grid-based environment compared to Manhattan distance.- Parameters:
otherPosition- The other position to calculate the distance to.- Returns:
- The Octile distance between the two positions.
-
distanceSquared
Calculates the squared distance between this position and another position.- Parameters:
otherPosition- The other position to calculate the distance to.- Returns:
- The squared distance between the two positions.
-
distance
Calculates the Euclidean distance between this position and another position.- Parameters:
otherPosition- The other position to calculate the distance to.- Returns:
- The Euclidean distance between the two positions.
-
setX
Creates a newPathPositionwith the same coordinates as this one, but with the x-coordinate set to the given value.- Parameters:
x- The new x-coordinate.- Returns:
- A new
PathPositionwith the updated x-coordinate.
-
setY
Creates a newPathPositionwith the same coordinates as this one, but with the y-coordinate set to the given value.- Parameters:
y- The new y-coordinate.- Returns:
- A new
PathPositionwith the updated y-coordinate.
-
setZ
Creates a newPathPositionwith the same coordinates as this one, but with the z-coordinate set to the given value.- Parameters:
z- The new z-coordinate.- Returns:
- A new
PathPositionwith the updated z-coordinate.
-
getCenteredX
public double getCenteredX()- Returns:
- the centered X coordinate (flooredX + 0.5)
-
getCenteredY
public double getCenteredY()- Returns:
- the centered Y coordinate (flooredY + 0.5)
-
getCenteredZ
public double getCenteredZ()- Returns:
- the centered Z coordinate (flooredZ + 0.5)
-
getFlooredX
public int getFlooredX()Returns the x-coordinate of the block this position is located in. This is equivalent to flooring the x-coordinate.- Returns:
- The floored x-coordinate.
-
getFlooredY
public int getFlooredY()Returns the y-coordinate of the block this position is located in. This is equivalent to flooring the y-coordinate.- Returns:
- The floored y-coordinate.
-
getFlooredZ
public int getFlooredZ()Returns the z-coordinate of the block this position is located in. This is equivalent to flooring the z-coordinate.- Returns:
- The floored z-coordinate.
-
add
Creates a newPathPositionby adding the given values to the coordinates of this position.- Parameters:
x- The value to add to the x-coordinate.y- The value to add to the y-coordinate.z- The value to add to the z-coordinate.- Returns:
- A new
PathPositionwith the added values.
-
add
Creates a newPathPositionby adding the components of the given vector to the coordinates of this position.- Parameters:
vector- The vector to add.- Returns:
- A new
PathPositionwith the added vector components.
-
subtract
Creates a newPathPositionby subtracting the given values from the coordinates of this position.- Parameters:
x- The value to subtract from the x-coordinate.y- The value to subtract from the y-coordinate.z- The value to subtract from the z-coordinate.- Returns:
- A new
PathPositionwith the subtracted values.
-
subtract
Creates a newPathPositionby subtracting the components of the given vector from the coordinates of this position.- Parameters:
vector- The vector to subtract.- Returns:
- A new
PathPositionwith the subtracted vector components.
-
toVector
Creates a newPathVectorfrom the coordinates of this position.- Returns:
- A new
PathVectorrepresenting this position's coordinates.
-
floor
Creates a newPathPositionwith the coordinates floored to the nearest integer values.- Returns:
- A new
PathPositionwith floored coordinates.
-
mid
Creates a newPathPositionwith the coordinates set to the center of the block they are in.- Returns:
- A new
PathPositionat the center of the block.
-
midPoint
Calculates the midpoint between this position and another position.- Parameters:
end- The other position to calculate the midpoint with.- Returns:
- A new
PathPositionrepresenting the midpoint.
-
clone
-
equals
-
hashCode
public int hashCode() -
getX
public double getX()Returns the x-coordinate of this position.- Returns:
- The x-coordinate.
-
getY
public double getY()Returns the y-coordinate of this position.- Returns:
- The y-coordinate.
-
getZ
public double getZ()Returns the z-coordinate of this position.- Returns:
- The z-coordinate.
-
toString
-