fr.cnes.sirius.patrius.utils
Class AngleTools

java.lang.Object
  extended by fr.cnes.sirius.patrius.utils.AngleTools

public final class AngleTools
extends Object

This class provides static methods for angles :

- angles computation,

- comparison,

- arithmetic and trigonometric operations.

Since:
1.0
Version:
$Id: AngleTools.java 16555 2016-09-01 14:19:29Z bignon $
Author:
Julie Anton, Thomas Trapier
Use sample :

- In order to compute the angle between two vectors :

double angle = AngleTools.getAngleBewteen2Vector3D(vector1, vector2);

- To compute the angle 2PI modulo in the given interval : (can throw a MathIllegalArgumentException)

double res = AngleTools.angleInInterval(angle, angleInterval);

- To compare two angles in a given interval : (can throw a MathIllegalArgumentException)

boolean isEqual = AngleTools.equal(angle1, angle2, angleInterval);

- To compute the complementary angle in a given interval : (can throw a MathIllegalArgumentException)

double res = AngleTools.complementaryAngle(angle, angleInterval);

See DV-MATHS_60, 70, 80, 90, 100 .
Concurrency :
unconditionally thread-safe

Method Summary
static double angleInInterval(double angle, AngleInterval interval)
          Computes the angle in the given interval modulo 2pi.
static double complementaryAngle(double angle, AngleInterval interval)
          Computes the complementary (PI/2 - angle) of the input angle, and then tries to express it in the input interval.
static boolean equal(double alpha, double beta, AngleInterval interval)
          Tests the equality of two angles after expressing them in the same interval.
static double getAngleBewteen2Vector3D(Vector3D vector1, Vector3D vector2)
          Computes the angle between 2 vectors 3D.
static double getAngleFromCosineAndSine(double cos, double sin)
          Computes an angle from the sine and the cosine
static double getOrientedAngleBetween2Vector2D(Vector2D vector1, Vector2D vector2)
          Computes the oriented angle between 2 vectors 2D.
static double getOrientedAngleBewteen2Vector3D(Vector3D vector1, Vector3D vector2, Vector3D vector3)
          Computes the oriented angle between 2 vectors 3D.
static boolean greaterOrEqual(double alpha, double beta, AngleInterval interval)
          Tests if one angle is greater or equal to another after expressing them in the same interval.
static boolean greaterStrict(double alpha, double beta, AngleInterval interval)
          Tests if one angle is strictly greater than another after expressing them in the same interval.
static boolean lowerOrEqual(double alpha, double beta, AngleInterval interval)
          Tests if one angle is lower or equal to another after expressing them in the same interval.
static boolean lowerStrict(double alpha, double beta, AngleInterval interval)
          Tests if one angle is strictly lower than another after expressing them in the same interval.
static double oppositeAngle(double angle, AngleInterval interval)
          Computes the opposite of the input angle, and then tries to express it in the input interval.
static double supplementaryAngle(double angle, AngleInterval interval)
          Computes the supplementary (PI - angle) of the input angle, and then tries to express it in the input interval.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getAngleBewteen2Vector3D

public static double getAngleBewteen2Vector3D(Vector3D vector1,
                                              Vector3D vector2)
Computes the angle between 2 vectors 3D. To do so, we use the method angle(Vector3D, Vector3D) of Vector3D .

Parameters:
vector1 - the first vector
vector2 - the second vector
Returns:
double angle = the positive value of the angle between the two vectors, the angle is defined between 0 and PI. See DV-MATHS_100
Since:
1.0
See Also:
Vector3D.angle(Vector3D, Vector3D)
Preconditions :
either the first vector or the second one should have non zero norm.

getOrientedAngleBetween2Vector2D

public static double getOrientedAngleBetween2Vector2D(Vector2D vector1,
                                                      Vector2D vector2)
Computes the oriented angle between 2 vectors 2D.

Parameters:
vector1 - the first vector
vector2 - the second vector
Returns:
double angle = the value of the oriented angle between the two vectors, the angle is defined between -2 PI and 2 PI. See DV-MATHS_100 .
Throws:
MathIllegalArgumentException - if at least one norm is zero
MathIllegalArgumentException - if at least one norm is infinity
Since:
1.0
Preconditions :
either the first vector or the second one should have finite coordinate values and non zero norm.

getOrientedAngleBewteen2Vector3D

public static double getOrientedAngleBewteen2Vector3D(Vector3D vector1,
                                                      Vector3D vector2,
                                                      Vector3D vector3)
Computes the oriented angle between 2 vectors 3D.

Parameters:
vector1 - the first vector
vector2 - the second vector
vector3 - the third vector which defines the orientation
Returns:
double angle = the value of the oriented angle between the two vectors, the angle is defined between -PI and PI. See DV-MATHS_100 .
Throws:
IllegalArgumentException - if the cross product is wrong
Since:
1.0
Preconditions :
either the first vector or the second one or the third one should have non zero norm. The third vector should be perpendicular to the plane formed by the formers.

getAngleFromCosineAndSine

public static double getAngleFromCosineAndSine(double cos,
                                               double sin)
Computes an angle from the sine and the cosine

Parameters:
cos - : the cosine of the angle we want to know the value
sin - : the sine of the angle we want to know the value
Returns:
double angle = the angle given by sine and cosine between -PI and PI See DV-MATHS_100 .
Since:
1.0
Preconditions :
the sine and the cosine should be of the same angle ie cosĀ²+sinĀ² is lower than 1.

angleInInterval

public static double angleInInterval(double angle,
                                     AngleInterval interval)
Computes the angle in the given interval modulo 2pi.

Parameters:
angle - angle to be expressed inside the given interval
interval - interval of expression
Returns:
the angle expressed in the interval
Throws:
MathIllegalArgumentException - the angle is'nt in the interval modulo 2PI
Since:
1.0
Preconditions :
the interval can represent the given angle ([0, pi[ doesn't contain -pi/2 modulo 2pi)

equal

public static boolean equal(double alpha,
                            double beta,
                            AngleInterval interval)
Tests the equality of two angles after expressing them in the same interval.

Parameters:
alpha - one angle
beta - one angle
interval - the interval to express the angles
Returns:
boolean : true if equal
Throws:
MathIllegalArgumentException - if one angle is'nt in the interval, modulo 2PI
Since:
1.0
Preconditions :
both angles must be in the given interval modulo 2PI

lowerOrEqual

public static boolean lowerOrEqual(double alpha,
                                   double beta,
                                   AngleInterval interval)
Tests if one angle is lower or equal to another after expressing them in the same interval.

Parameters:
alpha - one angle
beta - one angle
interval - the interval to express the angles
Returns:
boolean : true if lower or equal
Throws:
MathIllegalArgumentException - if one angle is'nt in the interval, modulo 2PI
Since:
1.0
Preconditions :
both angles must be in the given interval modulo 2PI

lowerStrict

public static boolean lowerStrict(double alpha,
                                  double beta,
                                  AngleInterval interval)
Tests if one angle is strictly lower than another after expressing them in the same interval.

Parameters:
alpha - : one angle
beta - : one angle
interval - the interval to express the angles
Returns:
boolean : true if lower
Throws:
MathIllegalArgumentException - if one angle is'nt in the interval, modulo 2PI
Since:
1.0
Preconditions :
both angles must be in the given interval modulo 2PI

greaterOrEqual

public static boolean greaterOrEqual(double alpha,
                                     double beta,
                                     AngleInterval interval)
Tests if one angle is greater or equal to another after expressing them in the same interval.

Parameters:
alpha - : one angle
beta - : one angle
interval - the interval to express the angles
Returns:
boolean : true is greater or equal
Throws:
MathIllegalArgumentException - if one angle is'nt in the interval, modulo 2PI
Since:
1.0
Preconditions :
both angles must be in the given interval modulo 2PI

greaterStrict

public static boolean greaterStrict(double alpha,
                                    double beta,
                                    AngleInterval interval)
Tests if one angle is strictly greater than another after expressing them in the same interval.

Parameters:
alpha - : one angle
beta - : one angle
interval - the interval to express the angles
Returns:
boolean : true is greater
Throws:
MathIllegalArgumentException - if one angle is'nt in the interval, modulo 2PI
Since:
1.0
Preconditions :
both angles must be in the given interval modulo 2PI

supplementaryAngle

public static double supplementaryAngle(double angle,
                                        AngleInterval interval)
Computes the supplementary (PI - angle) of the input angle, and then tries to express it in the input interval.

Parameters:
angle - the angle to get the supplementary
interval - the interval to express the result
Returns:
double : supplementary angle
Throws:
MathIllegalArgumentException - if the resulting angle is'nt in the interval, modulo 2PI See DV-MATHS_80 .
Since:
1.0

complementaryAngle

public static double complementaryAngle(double angle,
                                        AngleInterval interval)
Computes the complementary (PI/2 - angle) of the input angle, and then tries to express it in the input interval.

Parameters:
angle - the angle to get the complementary
interval - the interval to express the result
Returns:
double : complementary angle
Throws:
MathIllegalArgumentException - if the resulting angle is'nt in the interval, modulo 2PI See DV-MATHS_80 .
Since:
1.0

oppositeAngle

public static double oppositeAngle(double angle,
                                   AngleInterval interval)
Computes the opposite of the input angle, and then tries to express it in the input interval.

Parameters:
angle - the angle to get the complementary
interval - the interval to express the result
Returns:
double : opposite angle
Throws:
MathIllegalArgumentException - if the resulting angle is'nt in the interval, modulo 2PI See DV-MATHS_80 .
Since:
1.0


Copyright © 2016 CNES. All Rights Reserved.