Class PathVector

java.lang.Object
de.metaphoriker.pathetic.api.wrapper.PathVector
All Implemented Interfaces:
Cloneable

public class PathVector extends Object implements Cloneable
Represents a 3D vector within a pathfinding context. This class encapsulates the x, y, and z components of a vector and provides methods for vector operations such as addition, subtraction, dot product, cross product, and normalization.
  • Constructor Summary

    Constructors
    Constructor
    Description
    PathVector(double x, double y, double z)
    Constructs a PathVector with the specified x, y, and z components.
  • Method Summary

    Modifier and Type
    Method
    Description
    add(PathVector otherVector)
    Creates a new PathVector by adding another vector to this vector.
    protected boolean
     
     
    static double
    Computes the distance between a point and a line segment.
    double
    distance(PathVector otherVector)
    Calculates the Euclidean distance between this vector and another vector.
    divide(double value)
    Creates a new PathVector by dividing this vector by a scalar value.
    double
    dot(PathVector otherVector)
    Calculates the dot product of this vector and another vector.
    boolean
     
    Calculates the cross product of this vector and another vector.
    double
    Returns the x-component of this vector.
    double
    Returns the y-component of this vector.
    double
    Returns the z-component of this vector.
    int
     
    double
    Calculates the length (magnitude) of this vector.
    multiply(double value)
    Creates a new PathVector by multiplying this vector by a scalar value.
    Creates a new PathVector by normalizing this vector.
    setX(double x)
    Creates a new PathVector with the same y and z components as this vector, but with the x-component set to the given value.
    setY(double y)
    Creates a new PathVector with the same x and z components as this vector, but with the y-component set to the given value.
    setZ(double z)
    Creates a new PathVector with the same x and y components as this vector, but with the z-component set to the given value.
    subtract(PathVector otherVector)
    Creates a new PathVector by subtracting another vector from this vector.

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PathVector

      public PathVector(double x, double y, double z)
      Constructs a PathVector with the specified x, y, and z components.
      Parameters:
      x - The x-component of the vector.
      y - The y-component of the vector.
      z - The z-component of the vector.
  • Method Details

    • computeDistance

      public static double computeDistance(PathVector A, PathVector B, PathVector C)
      Computes the distance between a point and a line segment.
      Parameters:
      A - The point represented as a PathVector.
      B - The first endpoint of the line segment represented as a PathVector.
      C - The second endpoint of the line segment represented as a PathVector.
      Returns:
      The distance between the point A and the line segment BC.
    • dot

      public double dot(PathVector otherVector)
      Calculates the dot product of this vector and another vector.
      Parameters:
      otherVector - The other vector to calculate the dot product with.
      Returns:
      The dot product of the two vectors.
    • length

      public double length()
      Calculates the length (magnitude) of this vector.
      Returns:
      The length of the vector.
    • distance

      public double distance(PathVector otherVector)
      Calculates the Euclidean distance between this vector and another vector.
      Parameters:
      otherVector - The other vector to calculate the distance to.
      Returns:
      The distance between the two vectors.
    • setX

      public PathVector setX(double x)
      Creates a new PathVector with the same y and z components as this vector, but with the x-component set to the given value.
      Parameters:
      x - The new x-component.
      Returns:
      A new PathVector with the updated x-component.
    • setY

      public PathVector setY(double y)
      Creates a new PathVector with the same x and z components as this vector, but with the y-component set to the given value.
      Parameters:
      y - The new y-component.
      Returns:
      A new PathVector with the updated y-component.
    • setZ

      public PathVector setZ(double z)
      Creates a new PathVector with the same x and y components as this vector, but with the z-component set to the given value.
      Parameters:
      z - The new z-component.
      Returns:
      A new PathVector with the updated z-component.
    • subtract

      public PathVector subtract(PathVector otherVector)
      Creates a new PathVector by subtracting another vector from this vector.
      Parameters:
      otherVector - The vector to subtract from this vector.
      Returns:
      A new PathVector representing the difference.
    • multiply

      public PathVector multiply(double value)
      Creates a new PathVector by multiplying this vector by a scalar value.
      Parameters:
      value - The scalar value to multiply by.
      Returns:
      A new PathVector representing the scaled vector.
    • normalize

      public PathVector normalize()
      Creates a new PathVector by normalizing this vector. Normalization divides each component of the vector by its magnitude, resulting in a unit vector (length of 1).
      Returns:
      A new PathVector representing the normalized vector.
    • divide

      public PathVector divide(double value)
      Creates a new PathVector by dividing this vector by a scalar value.
      Parameters:
      value - The scalar value to divide by.
      Returns:
      A new PathVector representing the divided vector.
    • add

      public PathVector add(PathVector otherVector)
      Creates a new PathVector by adding another vector to this vector.
      Parameters:
      otherVector - The vector to add to this vector.
      Returns:
      A new PathVector representing the sum.
    • getCrossProduct

      public PathVector getCrossProduct(PathVector o)
      Calculates the cross product of this vector and another vector.
      Parameters:
      o - The other vector to calculate the cross product with.
      Returns:
      A new PathVector representing the cross product.
    • clone

      public PathVector clone()
      Overrides:
      clone in class Object
    • getX

      public double getX()
      Returns the x-component of this vector.
      Returns:
      The x-component.
    • getY

      public double getY()
      Returns the y-component of this vector.
      Returns:
      The y-component.
    • getZ

      public double getZ()
      Returns the z-component of this vector.
      Returns:
      The z-component.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object