Class UtilAngle
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic double
atanSafe
(double y, double x) static float
atanSafe
(float y, float x) static double
average
(double a, double b) Computes the average of the two angles.static float
average
(float a, float b) Computes the average of the two angles.static double
bound
(double ang) Returns an angle which is equivalent to the one provided, but between (inclusive) -π and π.static float
bound
(float ang) Returns an angle which is equivalent to the one provided, but between (inclusive) -π and π.static double
boundHalf
(double angle) Bounds the angle between -π/2 and π/2static float
boundHalf
(float angle) Bounds the angle between -π/2 and π/2static double
degree
(double angleRad) Converts degrees into radiansstatic float
degree
(float angleRad) Converts degrees into radiansstatic double
degreeToRadian
(double angleDegree) static float
degreeToRadian
(float angleDegree) static double
dist
(double angA, double angB) Returns the number of radians two angles are apart.static float
dist
(float angA, float angB) Returns the number of radians two angles are apart.static double
dist_u
(double angA, double angB) Returns the number of radians two angles are apart.static float
dist_u
(float angA, float angB) Returns the number of radians two angles are apart.static double
distanceCCW
(double angA, double angB) Angular distance in radians to go from angA to angB in counter clock-wise direction.static float
distanceCCW
(float angA, float angB) Angular distance in radians to go from angA to angB in counter clock-wise direction.static double
distanceCCW_u
(double angA, double angB) Angular distance in radians to go from angA to angB in counter clock-wise direction.static float
distanceCCW_u
(float angA, float angB) Angular distance in radians to go from angA to angB in counter clock-wise direction.static double
distanceCW
(double angA, double angB) Angular distance in radians to go from angA to angB in clock-wise direction.static float
distanceCW
(float angA, float angB) Angular distance in radians to go from angA to angB in clock-wise direction.static double
distanceCW_u
(double angA, double angB) Angular distance in radians to go from angA to angB in clock-wise direction.static float
distanceCW_u
(float angA, float angB) Angular distance in radians to go from angA to angB in clock-wise direction.static double
distHalf
(double angA, double angB) Angular distance between two half circle angles.static double
domain2PI
(double angle) Converts an angle from -pi to pi into 0 to 2*pi domainstatic boolean
isHalfDomain
(double ang) Checks to see if it is between -π/2 and π/2.static boolean
isStandardDomain
(double ang) Checks to see if it is between -π and π.static double
minus
(double angA, double angB) Returns the difference between two angles and bounds the result between -pi and pi:
result = angA - angB
and takes in account boundary conditions.static float
minus
(float angA, float angB) Returns the difference between two angles and bounds the result between -pi and pi:
result = angA - angB
and takes in account boundary conditions.static double
radian
(double angleDegree) Converts radians into degreesstatic float
radian
(float angleDegree) Converts radians into degreesstatic double
radianToDegree
(double angleRad) static float
radianToDegree
(float angleRad) static double
reflectZeroToOne
(double value) Ensures a reflective bound so that the numbers from 0 to 1, where 0 is inclusive and 1 is inclusive.static float
reflectZeroToOne
(float value) Ensures a reflective bound so that the numbers from 0 to 1, where 0 is inclusive and 1 is inclusive.static double
toHalfCircle
(double angle) Converts an angle which is (-pi to pi) into a half circle angle (-pi/2 to pi/2).static float
toHalfCircle
(float angle) Converts an angle which is (-pi to pi) into a half circle angle (0 to pi).static double
wrapZeroToOne
(double value) Ensures a wrapping circular bound so that the numbers from 0 to 1, where 0 is inclusive and 1 is exclusive.static float
wrapZeroToOne
(float value) Ensures a wrapping circular bound so that the numbers from 0 to 1, where 0 is inclusive and 1 is exclusive.
-
Constructor Details
-
UtilAngle
public UtilAngle()
-
-
Method Details
-
radianToDegree
public static double radianToDegree(double angleRad) -
degreeToRadian
public static double degreeToRadian(double angleDegree) -
radianToDegree
public static float radianToDegree(float angleRad) -
degreeToRadian
public static float degreeToRadian(float angleDegree) -
radian
public static double radian(double angleDegree) Converts radians into degrees- Parameters:
angleDegree
- angle in degrees- Returns:
- angle in radians
-
degree
public static double degree(double angleRad) Converts degrees into radians- Parameters:
angleRad
- angle in radians- Returns:
- angle in degrees
-
radian
public static float radian(float angleDegree) Converts radians into degrees- Parameters:
angleDegree
- angle in degrees- Returns:
- angle in radians
-
degree
public static float degree(float angleRad) Converts degrees into radians- Parameters:
angleRad
- angle in radians- Returns:
- angle in degrees
-
atanSafe
public static double atanSafe(double y, double x) -
atanSafe
public static float atanSafe(float y, float x) -
average
public static double average(double a, double b) Computes the average of the two angles. This only works well and is a well defined problem when the two angles are close. It operates by determining of the angles are closer in CW or CCW directions. The distance in that direction is found then 1/2 the distance is added to one of them and returned.- Parameters:
a
- Angle in radians.b
- Angle in radians.- Returns:
- Average angle of the two. a + delta.
-
average
public static float average(float a, float b) Computes the average of the two angles. This only works well and is a well defined problem when the two angles are close. It operates by determining of the angles are closer in CW or CCW directions. The distance in that direction is found then 1/2 the distance is added to one of them and returned.- Parameters:
a
- Angle in radians.b
- Angle in radians.- Returns:
- Average angle of the two. a + delta.
-
toHalfCircle
public static double toHalfCircle(double angle) Converts an angle which is (-pi to pi) into a half circle angle (-pi/2 to pi/2).- Parameters:
angle
- Angle between -pi and pi.- Returns:
- -pi/2 to pi/2
-
toHalfCircle
public static float toHalfCircle(float angle) Converts an angle which is (-pi to pi) into a half circle angle (0 to pi).- Parameters:
angle
- Angle between -pi and pi.- Returns:
- 0 to pi
-
isStandardDomain
public static boolean isStandardDomain(double ang) Checks to see if it is between -π and π.- Parameters:
ang
- Angle being tested- Returns:
- true if it is between -π and π
-
isHalfDomain
public static boolean isHalfDomain(double ang) Checks to see if it is between -π/2 and π/2.- Parameters:
ang
- Angle being tested- Returns:
- true if it is between -π/2 and π/2;
-
bound
public static double bound(double ang) Returns an angle which is equivalent to the one provided, but between (inclusive) -π and π. -
bound
public static float bound(float ang) Returns an angle which is equivalent to the one provided, but between (inclusive) -π and π. -
boundHalf
public static double boundHalf(double angle) Bounds the angle between -π/2 and π/2- Parameters:
angle
- angle in radians- Returns:
- bounded angle
-
boundHalf
public static float boundHalf(float angle) Bounds the angle between -π/2 and π/2- Parameters:
angle
- angle in radians- Returns:
- bounded angle
-
distanceCCW
public static double distanceCCW(double angA, double angB) Angular distance in radians to go from angA to angB in counter clock-wise direction. The resulting angle will be from 0 to 2π.- Parameters:
angA
- First angle. -pi to pi Radians.angB
- Second angle -pi to pi Radians.- Returns:
- An angle from 0 to 2 π
-
distanceCCW_u
public static double distanceCCW_u(double angA, double angB) Angular distance in radians to go from angA to angB in counter clock-wise direction. The resulting angle will be from 0 to 2π. Input is unbounded- Parameters:
angA
- First angle. Radians.angB
- Second angle Radians.- Returns:
- An angle from 0 to 2 π
-
distanceCCW
public static float distanceCCW(float angA, float angB) Angular distance in radians to go from angA to angB in counter clock-wise direction. The resulting angle will be from 0 to 2π.- Parameters:
angA
- First angle. -pi to pi Radians.angB
- Second angle -pi to pi Radians.- Returns:
- An angle from 0 to 2 π
-
distanceCCW_u
public static float distanceCCW_u(float angA, float angB) Angular distance in radians to go from angA to angB in counter clock-wise direction. The resulting angle will be from 0 to 2π. Input is unbounded- Parameters:
angA
- First angle. Radians.angB
- Second angle Radians.- Returns:
- An angle from 0 to 2 π
-
distanceCW
public static double distanceCW(double angA, double angB) Angular distance in radians to go from angA to angB in clock-wise direction. The resulting angle will be from 0 to 2π.- Parameters:
angA
- First angle. -pi to pi Radians.angB
- Second angle -pi to pi Radians.- Returns:
- An angle from 0 to 2 π
-
distanceCW_u
public static double distanceCW_u(double angA, double angB) Angular distance in radians to go from angA to angB in clock-wise direction. The resulting angle will be from 0 to 2π. Input is unbounded.- Parameters:
angA
- First angle. Radians.angB
- Second angle. Radians.- Returns:
- An angle from 0 to 2 π
-
distanceCW
public static float distanceCW(float angA, float angB) Angular distance in radians to go from angA to angB in clock-wise direction. The resulting angle will be from 0 to 2π.- Parameters:
angA
- First angle. -pi to piangB
- Second angle -pi to pi- Returns:
- An angle from 0 to 2 π
-
distanceCW_u
public static float distanceCW_u(float angA, float angB) Angular distance in radians to go from angA to angB in clock-wise direction. The resulting angle will be from 0 to 2π. Input is unbounded.- Parameters:
angA
- First angle. Radians.angB
- Second angle. Radians.- Returns:
- An angle from 0 to 2 π
-
minus
public static double minus(double angA, double angB) Returns the difference between two angles and bounds the result between -pi and pi:
result = angA - angB
and takes in account boundary conditions.- Parameters:
angA
- first angle. Must be between -pi and pi.angB
- second angle. Must be between -pi and pi.- Returns:
- an angle between -pi and pi
-
minus
public static float minus(float angA, float angB) Returns the difference between two angles and bounds the result between -pi and pi:
result = angA - angB
and takes in account boundary conditions.- Parameters:
angA
- first angle. Must be between -pi and pi.angB
- second angle. Must be between -pi and pi.- Returns:
- an angle between -pi and pi
-
dist
public static double dist(double angA, double angB) Returns the number of radians two angles are apart. This is equivalent to Math.abs(UtilAngle.minus(angA,angB)).
- Parameters:
angA
- first angle. Must be between -pi and pi.angB
- second angle. Must be between -pi and pi.- Returns:
- an angle between 0 and pi
-
dist_u
public static double dist_u(double angA, double angB) Returns the number of radians two angles are apart. This is equivalent to Math.abs(UtilAngle.minus(angA,angB)). Unbounded input.
- Parameters:
angA
- first angle. Radians.angB
- second angle. Radians.- Returns:
- an angle between 0 and pi
-
dist
public static float dist(float angA, float angB) Returns the number of radians two angles are apart. This is equivalent to Math.abs(UtilAngle.minus(angA,angB)).
- Parameters:
angA
- first angle. Must be between -pi and pi.angB
- second angle. Must be between -pi and pi.- Returns:
- an angle between 0 and pi
-
dist_u
public static float dist_u(float angA, float angB) Returns the number of radians two angles are apart. This is equivalent to Math.abs(UtilAngle.minus(angA,angB)). Unbounded input.
- Parameters:
angA
- first angle. Radians.angB
- second angle. Radians.- Returns:
- an angle between 0 and pi
-
distHalf
public static double distHalf(double angA, double angB) Angular distance between two half circle angles.- Parameters:
angA
- Angle between -pi/2 and pi/2.angB
- Angle between -pi/2 and pi/2.- Returns:
- Acute angle between the two input angles.
-
domain2PI
public static double domain2PI(double angle) Converts an angle from -pi to pi into 0 to 2*pi domain- Parameters:
angle
- angle from -pi to pi radians- Returns:
- angle from 0 to 2*pi radians
-
wrapZeroToOne
public static double wrapZeroToOne(double value) Ensures a wrapping circular bound so that the numbers from 0 to 1, where 0 is inclusive and 1 is exclusive.Examples: 1.5 = 0.5 -0.25 = 0.75 0 = 0 1 = 0 0.999 = 0.999 2 = 0 -1 = 0
- Returns:
- A value from 0 to 1. [0,1)
-
wrapZeroToOne
public static float wrapZeroToOne(float value) Ensures a wrapping circular bound so that the numbers from 0 to 1, where 0 is inclusive and 1 is exclusive.Examples: 1.5 = 0.5 -0.25 = 0.75 0 = 0 1 = 0 0.999 = 0.999 2 = 0 -1 = 0
- Returns:
- A value from 0 to 1. [0,1)
-
reflectZeroToOne
public static double reflectZeroToOne(double value) Ensures a reflective bound so that the numbers from 0 to 1, where 0 is inclusive and 1 is inclusive.Examples: 1.5 = 0.5 -0.25 = 0.25 -0.75 = 0.75 0 = 0 1 = 1 0.999 = 0.999 2 = 0 -1 = 1
- Returns:
- A value from 0 to 1. [0,1]
-
reflectZeroToOne
public static float reflectZeroToOne(float value) Ensures a reflective bound so that the numbers from 0 to 1, where 0 is inclusive and 1 is inclusive.Examples: 1.5 = 0.5 -0.25 = 0.25 -0.75 = 0.75 0 = 0 1 = 1 0.999 = 0.999 2 = 0 -1 = 1
- Returns:
- A value from 0 to 1. [0,1]
-