Package com.irurueta.geometry
Class Utils
java.lang.Object
com.irurueta.geometry.Utils
Helper class containing commonly used methods related to geometry.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleAmount to add/subtract to an angle in degrees to make a half turn.static final doubleAmount to add/subtract to an angle in radians to make a half turn. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic doubleconvertToDegrees(double radians) Converts provided value from radians to degrees.static doubleconvertToRadians(double degrees) Converts provided value from degrees to radians.private static doublenormalizeAngle(double angle, double halfTurn) Normalizes an angle between the range -pi...pi (or -180...180) by adding or subtracting the required amount of turns.static doublenormalizeAngleDegrees(double angle) Normalizes an angle between the range -180...180 by adding or subtracting the required amount of turns.static doublenormalizeAngleRadians(double angle) Normalizes an angle between the range -pi...pi by adding or subtracting the required amount of turns.
-
Field Details
-
HALF_TURN_DEGREES
public static final double HALF_TURN_DEGREESAmount to add/subtract to an angle in degrees to make a half turn.- See Also:
-
HALF_TURN_RADIANS
public static final double HALF_TURN_RADIANSAmount to add/subtract to an angle in radians to make a half turn.- See Also:
-
-
Constructor Details
-
Utils
private Utils()Constructor. Prevents instantiation.
-
-
Method Details
-
convertToDegrees
public static double convertToDegrees(double radians) Converts provided value from radians to degrees.- Parameters:
radians- Angle in radians.- Returns:
- Converted angle in degrees.
-
convertToRadians
public static double convertToRadians(double degrees) Converts provided value from degrees to radians.- Parameters:
degrees- Angle in degrees.- Returns:
- Converted angle in radians.
-
normalizeAngleDegrees
public static double normalizeAngleDegrees(double angle) Normalizes an angle between the range -180...180 by adding or subtracting the required amount of turns.- Parameters:
angle- angle to be normalized expressed in degrees.- Returns:
- the same angle but normalized.
-
normalizeAngleRadians
public static double normalizeAngleRadians(double angle) Normalizes an angle between the range -pi...pi by adding or subtracting the required amount of turns.- Parameters:
angle- angle to be normalized expressed in degrees.- Returns:
- the same angle but normalized.
-
normalizeAngle
private static double normalizeAngle(double angle, double halfTurn) Normalizes an angle between the range -pi...pi (or -180...180) by adding or subtracting the required amount of turns. This method can work with angles expressed either on degrees or radians depending on the units used for the definition of a half turn.- Parameters:
angle- angle to be normalized.halfTurn- the definition of a half turn (either in degrees or radians).- Returns:
- the same angle but normalized.
-