Class Vector3d

java.lang.Object
me.autobot.lib.math.coordinates.Vector3d

public class Vector3d extends Object
A class representing a 3D vector.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Vector3d(double x, double y, double z)
    Creates a new 3D vector object.
  • Method Summary

    Modifier and Type
    Method
    Description
    add(Vector3d other)
    Adds another vector to this vector (and returns a new vector).
    double
    angle(Vector3d other)
    Gets the angle between this vector and another vector.
    cross(Vector3d other)
    Cross product of this vector and another vector (and returns a new vector).
    double
    dot(Vector3d other)
    Dot product of this vector and another vector.
    double
    Gets the x component of the vector.
    double
    Gets the y component of the vector.
    double
    Gets the z component of the vector.
    double
    Returns the magnitude of the vector.
    Returns a new vector that is the normalized version of this vector.
    rotateBy(Rotation3d rotation)
    Returns a new vector that's this rotated by the given Rotation3d.
    scale(double scalar)
    Scales the vector by a scalar (and returns a new vector).
    void
    setX(double x)
    Sets the x component of the vector.
    void
    setY(double y)
    Sets the y component of the vector.
    void
    setZ(double z)
    Sets the z component of the vector.
    Subtracts another vector from this vector (and returns a new vector).
    Converts the vector to a polar vector.
    Converts the vector to a spherical vector.
    Returns a string representation of the vector.
    Converts the vector to a 2D vector (x, y).
    Converts the vector to a 2D vector (x, z).
    Converts the vector to a 2D vector (y, z).
    static Vector3d
    Creates a 3D zero vector

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Vector3d

      public Vector3d(double x, double y, double z)
      Creates a new 3D vector object.
      Parameters:
      x - The x component of the vector.
      y - The y component of the vector.
      z - The z component of the vector.
  • Method Details

    • zero

      public static Vector3d zero()
      Creates a 3D zero vector
      Returns:
      The zero vector
    • getX

      public double getX()
      Gets the x component of the vector.
      Returns:
      The x component of the vector.
    • setX

      public void setX(double x)
      Sets the x component of the vector.
      Parameters:
      x - The new x component of the vector.
    • getY

      public double getY()
      Gets the y component of the vector.
      Returns:
      The y component of the vector.
    • setY

      public void setY(double y)
      Sets the y component of the vector.
      Parameters:
      y - The new y component of the vector.
    • getZ

      public double getZ()
      Gets the z component of the vector.
      Returns:
      The z component of the vector.
    • setZ

      public void setZ(double z)
      Sets the z component of the vector.
      Parameters:
      z - The new z component of the vector.
    • add

      public Vector3d add(Vector3d other)
      Adds another vector to this vector (and returns a new vector).
      Parameters:
      other - The other vector to add to this vector.
      Returns:
      The new vector that is the sum of this vector and the other vector.
    • subtract

      public Vector3d subtract(Vector3d other)
      Subtracts another vector from this vector (and returns a new vector).
      Parameters:
      other - The other vector to subtract from this vector.
      Returns:
      The new vector that is the difference of this vector and the other vector.
    • scale

      public Vector3d scale(double scalar)
      Scales the vector by a scalar (and returns a new vector).
      Parameters:
      scalar - The scalar to scale the vector by.
      Returns:
      The new vector that is the scaled version of this vector.
    • dot

      public double dot(Vector3d other)
      Dot product of this vector and another vector.
      Parameters:
      other - The other vector to dot this vector with.
      Returns:
      The dot product of this vector and the other vector.
    • cross

      public Vector3d cross(Vector3d other)
      Cross product of this vector and another vector (and returns a new vector).
      Parameters:
      other - The other vector to cross this vector with.
      Returns:
      The new vector that is the cross product of this vector and the other vector.
    • magnitude

      public double magnitude()
      Returns the magnitude of the vector.
      Returns:
      The magnitude of the vector.
    • normalize

      public Vector3d normalize()
      Returns a new vector that is the normalized version of this vector.
      Returns:
      The normalized version of this vector.
    • angle

      public double angle(Vector3d other)
      Gets the angle between this vector and another vector.
      Parameters:
      other - The other vector to get the angle between.
      Returns:
      The angle between this vector and the other vector.
    • rotateBy

      public Vector3d rotateBy(Rotation3d rotation)
      Returns a new vector that's this rotated by the given Rotation3d.
      Parameters:
      rotation - The Rotation3d to rotate the vector by.
      Returns:
      The new vector that's this rotated by the given Rotation3d.
    • toPolar

      public Polar toPolar()
      Converts the vector to a polar vector.
      Returns:
      The polar vector representation of this vector.
    • toSpherical

      public Spherical toSpherical()
      Converts the vector to a spherical vector.
      Returns:
      The spherical vector representation of this vector.
    • toXY

      public Vector2d toXY()
      Converts the vector to a 2D vector (x, y).
      Returns:
      The 2D vector representation of this vector.
    • toXZ

      public Vector2d toXZ()
      Converts the vector to a 2D vector (x, z).
      Returns:
      The 2D vector representation of this vector.
    • toYZ

      public Vector2d toYZ()
      Converts the vector to a 2D vector (y, z).
      Returns:
      The 2D vector representation of this vector.
    • toString

      public String toString()
      Returns a string representation of the vector.
      Overrides:
      toString in class Object
      Returns:
      The string representation of the vector.