Class Spherical

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

public class Spherical extends Object
A class representing a 3D spherical coordinate system.
  • Constructor Details

    • Spherical

      public Spherical(double rho, Rotation3d angle)
      Create a new Spherical with a radius of 0 and an angle of 0 (theta and phi).
      Parameters:
      rho - The radius.
      angle - The angles in radians.
    • Spherical

      public Spherical(double rho, Rotation2d theta, Rotation2d phi)
      Create a new Spherical with the given radius and angles in radians.
      Parameters:
      rho - The radius.
      theta - The angle of theta (the ground plane angle), [0, 2\pi).
      phi - The angle of phi (the vertical plane angle), [0, \pi).
  • Method Details

    • getRho

      public double getRho()
      Returns the value of rho.
      Returns:
      The value of rho.
    • setRho

      public void setRho(double rho)
      Sets the value of rho.
      Parameters:
      rho - The new value of rho.
    • getAngle

      public Rotation3d getAngle()
      Gets the angle of the Spherical.
      Returns:
      The angle of the Spherical.
    • setAngle

      public void setAngle(Rotation3d angle)
      Sets the angle of the Spherical.
      Parameters:
      angle - The new angle of the Spherical.
    • rotateBy

      public Spherical rotateBy(Rotation3d other)
      Returns a new Spherical that's this rotated by the given Rotation3d.
      Parameters:
      other - The Rotation3d to rotate the Spherical by.
      Returns:
      The new Spherical that's this rotated by the given Rotation3d.
    • normal

      public Spherical normal()
      Returns the normal of the Spherical.
      Returns:
      The normal of the Spherical.
    • inverse

      public Spherical inverse()
      Returns the inverse of the Spherical.
      Returns:
      The inverse of the Spherical.
    • cosTheta

      public double cosTheta()
      Returns the cosine of the theta angle.
      Returns:
      The cosine of the theta angle.
    • sinTheta

      public double sinTheta()
      Returns the sine of the theta angle.
      Returns:
      The sine of the theta angle.
    • cosPhi

      public double cosPhi()
      Returns the cosine of the phi angle.
      Returns:
      The cosine of the phi angle.
    • sinPhi

      public double sinPhi()
      Returns the sine of the phi angle.
      Returns:
      The sine of the phi angle.
    • getTheta

      public double getTheta()
      Returns the theta angle in radians.
      Returns:
      The theta angle in radians.
    • getPhi

      public double getPhi()
      Returns the phi angle in radians.
      Returns:
      The phi angle in radians.
    • toVector

      public Vector3d toVector()
      Converts the Spherical to a Vector3d.
      Returns:
      The Vector3d representation of the Spherical.
    • toVector2d

      public Vector2d toVector2d()
      Flattens and converts the Spherical to a Vector2d.
      Returns:
      The Vector2d representation of the Spherical.