Package me.wobblyyyy.pathfinder.geometry
Class Angle
java.lang.Object
me.wobblyyyy.pathfinder.geometry.Angle
public class Angle
extends java.lang.Object
A representation of an angle. Angles are defined as... well, angles. I'd
hope you know what an angle is before trying to program a robot capable of
dynamic and reactive autonomous navigation. Anyways, angles can be expressed
in either radians or degrees. The purpose of this class is to make sure that
angles are expressed in the correct form - either radians or degrees -
when they should be in that form.
- Since:
- 0.3.0
- Author:
- Colin Robertson
-
Field Summary
Fields Modifier and Type Field Description private double
angleDegrees
The angle, notated in degrees.private double
angleRadians
The angle, notated in radians. -
Constructor Summary
Constructors Constructor Description Angle(double angleDegrees)
Create a new angle based off a measurement in degrees. -
Method Summary
Modifier and Type Method Description double
cos()
Get the angle's cosine.double
cot()
Get the angle's cotangent.double
csc()
Get the angle's cosecant.Angle
divide(Angle angle)
Divide the current angle by the input angle.static Angle
divide(Angle angle1, Angle angle2)
Divide angle1 by angle2.static Angle
fromDegrees(double degrees)
Create a new angle from a measurement in degrees.static Angle
fromRadians(double radians)
Create a new angle from a measurement in radians.double
getDegrees()
Get the angle in degrees.double
getRadians()
Get the angle in radians.Angle
minus(Angle angle)
Subtract the input angle from the current angle.static Angle
minus(Angle angle1, Angle angle2)
Subtract angle2 from angle1.Angle
plus(Angle angle)
Add the input angle to the current angle.static Angle
plus(Angle angle1, Angle angle2)
Add two angles together.double
sec()
Get the angle's secant.double
sin()
Get the angle's sine.double
tan()
Get the angle's tangent.Angle
times(Angle angle)
Multiply the current angle by the input angle.static Angle
times(Angle angle1, Angle angle2)
Multiply angle1 and angle2 together.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
angleDegrees
private final double angleDegreesThe angle, notated in degrees. -
angleRadians
private final double angleRadiansThe angle, notated in radians.
-
-
Constructor Details
-
Angle
public Angle(double angleDegrees)Create a new angle based off a measurement in degrees.- Parameters:
angleDegrees
- the angle, represented in degrees.- See Also:
fromDegrees(double)
,fromRadians(double)
-
-
Method Details
-
fromDegrees
Create a new angle from a measurement in degrees.- Parameters:
degrees
- the degree measurement of the angle.- Returns:
- a new angle based on the desired measurement.
- See Also:
Angle(double)
,fromRadians(double)
-
fromRadians
Create a new angle from a measurement in radians.- Parameters:
radians
- the degree measurement of the angle.- Returns:
- a new angle based on the desired measurement.
- See Also:
Angle(double)
,fromDegrees(double)
-
getDegrees
public double getDegrees()Get the angle in degrees.- Returns:
- the angle in degrees.
-
getRadians
public double getRadians()Get the angle in radians.- Returns:
- the angle in radians.
-
cos
public double cos()Get the angle's cosine.- Returns:
- the angle's cosine.
-
sin
public double sin()Get the angle's sine.- Returns:
- the angle's sine.
-
tan
public double tan()Get the angle's tangent.- Returns:
- the angle's tangent.
-
sec
public double sec()Get the angle's secant.- Returns:
- the angle's secant.
-
csc
public double csc()Get the angle's cosecant.- Returns:
- the angle's cosecant.
-
cot
public double cot()Get the angle's cotangent.- Returns:
- the angle's cotangent.
-
plus
Add the input angle to the current angle.- Parameters:
angle
- the angle to add.- Returns:
- a new angle based on the current and the input angle.
-
minus
Subtract the input angle from the current angle.- Parameters:
angle
- the angle to subtract.- Returns:
- a new angle based on the current and the input angle.
-
times
Multiply the current angle by the input angle.- Parameters:
angle
- the angle to multiply by.- Returns:
- a new angle based on the current and the input angle.
-
divide
Divide the current angle by the input angle.- Parameters:
angle
- the angle to divide by.- Returns:
- a new angle based on the current and the input angle.
-
plus
Add two angles together.- Parameters:
angle1
- one of the two angles to add.angle2
- one of the two angles to add.- Returns:
- the sum of the two angles.
-
minus
Subtract angle2 from angle1.- Parameters:
angle1
- one of the two angles to subtract.angle2
- one of the two angles to subtract.- Returns:
- the difference of the two angles.
-
times
Multiply angle1 and angle2 together.- Parameters:
angle1
- one of the two angles to multiply.angle2
- one of the two angles to multiply.- Returns:
- the angles multiplied together.
-
divide
Divide angle1 by angle2.- Parameters:
angle1
- one of the two angles to divide.angle2
- one of the two angles to divide.- Returns:
- the quotient of the two angles.
-