Package pl.poznan.put.circular
Class Angle
java.lang.Object
pl.poznan.put.circular.Angle
- All Implemented Interfaces:
Comparable<Angle>
- Direct Known Subclasses:
ImmutableAngle
A measurement for which one can distinguish a direction (i.e. [0..360) degrees)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Angle
betweenPoints
(org.apache.commons.math3.geometry.euclidean.threed.Vector3D coordA, org.apache.commons.math3.geometry.euclidean.threed.Vector3D coordB, org.apache.commons.math3.geometry.euclidean.threed.Vector3D coordC) Calculates angle ABC.final int
final double
degrees()
final double
final double
Computes a useful distance in range [0; 2] between two angular values.final boolean
static Angle
fromHourMinuteString
(String hourMinute) Parses a string in format HH.MM as a vector on a circular clock.final boolean
Return strue if this instance is in range [begin; end).final boolean
isValid()
final Angle
multiply
(double v) Multiplies the angular value by a constant.protected Angle
final Angle
orderedSubtract
(Angle other) Returns an ordered difference between angles.abstract double
radians()
final double
final Angle
Subtracts another angular value from this.static double
subtractAsVectors
(double left, double right) Calculates angles' difference using formula acos(dot(left, right)).static double
subtractByAbsolutes
(double left, double right) Calculates angles' difference using formula: pi - |pi - |left - right||.static double
subtractByMinimum
(double left, double right) Calculates angles' difference using formula min(|left - right|, 360 - |left - right|).static Angle
torsionAngle
(org.apache.commons.math3.geometry.euclidean.threed.Vector3D vec1, org.apache.commons.math3.geometry.euclidean.threed.Vector3D vec2, org.apache.commons.math3.geometry.euclidean.threed.Vector3D vec3) Calculates torsion angle given three vectors.static Angle
torsionAngle
(org.apache.commons.math3.geometry.euclidean.threed.Vector3D coordA, org.apache.commons.math3.geometry.euclidean.threed.Vector3D coordB, org.apache.commons.math3.geometry.euclidean.threed.Vector3D coordC, org.apache.commons.math3.geometry.euclidean.threed.Vector3D coordD) Calculates torsion angle given four points.static Angle
torsionAngleByAcos
(org.apache.commons.math3.geometry.euclidean.threed.Vector3D a1, org.apache.commons.math3.geometry.euclidean.threed.Vector3D a2, org.apache.commons.math3.geometry.euclidean.threed.Vector3D a3, org.apache.commons.math3.geometry.euclidean.threed.Vector3D a4) Calculates torsion angle given four points.final String
toString()
-
Constructor Details
-
Angle
public Angle()
-
-
Method Details
-
betweenPoints
public static Angle betweenPoints(org.apache.commons.math3.geometry.euclidean.threed.Vector3D coordA, org.apache.commons.math3.geometry.euclidean.threed.Vector3D coordB, org.apache.commons.math3.geometry.euclidean.threed.Vector3D coordC) Calculates angle ABC.- Parameters:
coordA
- Coordinate of point A.coordB
- Coordinate of point B.coordC
- Coordinate of point C.- Returns:
- An angle between points A, B and C.
-
torsionAngleByAcos
public static Angle torsionAngleByAcos(org.apache.commons.math3.geometry.euclidean.threed.Vector3D a1, org.apache.commons.math3.geometry.euclidean.threed.Vector3D a2, org.apache.commons.math3.geometry.euclidean.threed.Vector3D a3, org.apache.commons.math3.geometry.euclidean.threed.Vector3D a4) Calculates torsion angle given four points. Uses cos^-1 and a check for pseudovector.- Parameters:
a1
- Atom 1.a2
- Atom 2.a3
- Atom 3.a4
- Atom 4.- Returns:
- A torsion angle (rotation around vector B-C).
-
torsionAngle
public static Angle torsionAngle(org.apache.commons.math3.geometry.euclidean.threed.Vector3D coordA, org.apache.commons.math3.geometry.euclidean.threed.Vector3D coordB, org.apache.commons.math3.geometry.euclidean.threed.Vector3D coordC, org.apache.commons.math3.geometry.euclidean.threed.Vector3D coordD) Calculates torsion angle given four points. Uses atan2 method.- Parameters:
coordA
- Coordinate of point A.coordB
- Coordinate of point B.coordC
- Coordinate of point C.coordD
- Coordinate of point D.- Returns:
- A torsion angle (rotation around vector B-C).
-
torsionAngle
public static Angle torsionAngle(org.apache.commons.math3.geometry.euclidean.threed.Vector3D vec1, org.apache.commons.math3.geometry.euclidean.threed.Vector3D vec2, org.apache.commons.math3.geometry.euclidean.threed.Vector3D vec3) Calculates torsion angle given three vectors. Uses atan2 method.- Parameters:
vec1
- The first vector.vec2
- The second vector.vec3
- The third vector.- Returns:
- A torsion angle (rotation around vector vec2).
-
fromHourMinuteString
Parses a string in format HH.MM as a vector on a circular clock. For 'm' minutes after midnight, the vector has value of '360 * m / (24 * 60)'.- Parameters:
hourMinute
- String in format HH.MM.- Returns:
- A vector representation of time on a circular clock.
- Throws:
InvalidVectorFormatException
- If the input string has an invalid format.InvalidCircularValueException
- If the input string is parsed to a value outside the range [0..360)
-
subtractByMinimum
public static double subtractByMinimum(double left, double right) Calculates angles' difference using formula min(|left - right|, 360 - |left - right|).- Parameters:
left
- Minuend in radians.right
- Subtrahend in radians.- Returns:
- The result of minuend - subtrahend in angular space.
-
subtractAsVectors
public static double subtractAsVectors(double left, double right) Calculates angles' difference using formula acos(dot(left, right)).- Parameters:
left
- Minuend in radians.right
- Subtrahend in radians.- Returns:
- The result of minuend - subtrahend in angular space.
-
subtractByAbsolutes
public static double subtractByAbsolutes(double left, double right) Calculates angles' difference using formula: pi - |pi - |left - right||.- Parameters:
left
- Minuend in radians.right
- Subtrahend in radians.- Returns:
- The result of minuend - subtrahend in angular space.
-
radians
@Parameter(order=1) public abstract double radians()- Returns:
- Value in radians in range (-pi; pi].
-
degrees
public final double degrees()- Returns:
- Value in degrees in range (-180; 180].
-
degrees360
public final double degrees360()- Returns:
- Value in degrees in range [0; 360).
-
radians2PI
public final double radians2PI()- Returns:
- Value in radians in range [0; 2pi).
-
isValid
public final boolean isValid()- Returns:
- True if value is not NaN.
-
isBetween
Return strue if this instance is in range [begin; end). For example 45 degrees is between 30 degrees and 60 degrees. Also, 15 degrees is between -30 and 30 degrees.- Parameters:
begin
- Beginning of the range of values.end
- Ending of the range of values.- Returns:
- true if object is between [begin; end)
-
multiply
Multiplies the angular value by a constant.- Parameters:
v
- Multiplier.- Returns:
- Angular value multiplied.
-
subtract
Subtracts another angular value from this.- Parameters:
other
- Another angular value.- Returns:
- Result of this - other in angular space.
-
orderedSubtract
Returns an ordered difference between angles. It describes a rotation from one angle to another one and is therefore in range [-180; 180) degrees.- Parameters:
other
- The other angle which value should be subtracted from this one.- Returns:
- An ordered difference from first to second angle in range [-180; 180) degrees.
-
distance
Computes a useful distance in range [0; 2] between two angular values.- Parameters:
other
- The other angle.- Returns:
- Value in range [0; 2] denoting distance between two angles.
-
compareTo
- Specified by:
compareTo
in interfaceComparable<Angle>
-
equals
-
toString
-
normalize
-