Package me.autobot.lib.math.coordinates
Class Spherical
java.lang.Object
me.autobot.lib.math.coordinates.Spherical
A class representing a 3D spherical coordinate system.
-
Constructor Summary
ConstructorsConstructorDescriptionSpherical
(double rho, Rotation2d theta, Rotation2d phi) Create a new Spherical with the given radius and angles in radians.Spherical
(double rho, Rotation3d angle) Create a new Spherical with a radius of 0 and an angle of 0 (theta and phi). -
Method Summary
Modifier and TypeMethodDescriptiondouble
cosPhi()
Returns the cosine of the phi angle.double
cosTheta()
Returns the cosine of the theta angle.getAngle()
Gets the angle of the Spherical.double
getPhi()
Returns the phi angle in radians.double
getRho()
Returns the value of rho.double
getTheta()
Returns the theta angle in radians.inverse()
Returns the inverse of the Spherical.normal()
Returns the normal of the Spherical.rotateBy
(Rotation3d other) Returns a new Spherical that's this rotated by the given Rotation3d.void
setAngle
(Rotation3d angle) Sets the angle of the Spherical.void
setRho
(double rho) Sets the value of rho.double
sinPhi()
Returns the sine of the phi angle.double
sinTheta()
Returns the sine of the theta angle.toVector()
Converts the Spherical to a Vector3d.Flattens and converts the Spherical to a Vector2d.
-
Constructor Details
-
Spherical
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
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
Gets the angle of the Spherical.- Returns:
- The angle of the Spherical.
-
setAngle
Sets the angle of the Spherical.- Parameters:
angle
- The new angle of the Spherical.
-
rotateBy
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
Returns the normal of the Spherical.- Returns:
- The normal of the 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
Converts the Spherical to a Vector3d.- Returns:
- The Vector3d representation of the Spherical.
-
toVector2d
Flattens and converts the Spherical to a Vector2d.- Returns:
- The Vector2d representation of the Spherical.
-