math.geom2d
Class Angle2D

java.lang.Object
  extended by math.geom2d.Angle2D

public class Angle2D
extends java.lang.Object

This class is only devoted to static computations.

Author:
dlegland

Field Summary
static double M_2PI
          The constant for 2*PI, equivalent to 360 degrees.
static double M_3PI_2
          The constant for 3*PI/2, equivalent to 270 degrees.
static double M_PI
          The constant for PI, equivalent to 180 degrees.
static double M_PI_2
          The constant for PI/2, equivalent to 90 degrees.
static double M_PI_4
          The constant for 3*PI/4, equivalent to 45 degrees.
 
Constructor Summary
Angle2D()
           
 
Method Summary
static double absoluteAngle(double x1, double y1, double x2, double y2, double x3, double y3)
          Returns the absolute angle between the ray formed by (p2, p1) and the ray formed by (p2, p3), where pi = (xi,yi), i=1,2,3.
static double absoluteAngle(Point2D p1, Point2D p2, Point2D p3)
          Returns the absolute angle between the ray formed by (p2, p1) and the ray formed by (p2, p3).
static boolean almostEquals(double angle1, double angle2, double eps)
          Checks whether two angles are equal, with respect to the given error bound.
static double angle(double x1, double y1, double x2, double y2, double x3, double y3)
          Returns the oriented angle between the ray formed by (p2, p1) and the ray formed by (p2, p3), where pi = (xi,yi), i=1,2,3.
static double angle(LinearShape2D obj1, LinearShape2D obj2)
          Returns the oriented angle between two (directed) straight objects.
static double angle(Point2D p1, Point2D p2, Point2D p3)
          Returns the oriented angle between the ray formed by (p2, p1) and the ray formed by (p2, p3).
static double angle(Vector2D vect1, Vector2D vect2)
          Returns the oriented angle between two vectors.
static boolean containsAngle(double startAngle, double endAngle, double angle)
          Tests if an angle belongs to an angular interval, defined by two limit angle, counted Counter-clockwise.
static boolean containsAngle(double startAngle, double endAngle, double angle, boolean direct)
          Tests if an angle belongs to an angular interval, defined by two limit angles, and an orientation flag.
static boolean equals(double angle1, double angle2)
          Checks whether two angles are equal, given a default threshold value.
static double formatAngle(double angle)
          Formats an angle between 0 and 2*PI.
static double horizontalAngle(double x, double y)
          Returns the horizontal angle formed by the line joining the origin and the point with given coordinate.
static double horizontalAngle(double x1, double y1, double x2, double y2)
          Returns the horizontal angle formed by the line joining the two given points.
static double horizontalAngle(LinearShape2D object)
          Returns the horizontal angle formed by the line joining the two given points.
static double horizontalAngle(Point2D point)
          Returns the horizontal angle formed by the line joining the origin and the given point.
static double horizontalAngle(Point2D p1, Point2D p2)
          Returns the horizontal angle formed by the line joining the two given points.
static double horizontalAngle(Vector2D vect)
          Returns the horizontal angle formed by the line joining the origin and the point with given coordinate.
static double pseudoAngle(Point2D p1, Point2D p2)
           Computes the pseudo-angle of a line joining the 2 points.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

M_PI

public static final double M_PI
The constant for PI, equivalent to 180 degrees.

See Also:
Constant Field Values

M_2PI

public static final double M_2PI
The constant for 2*PI, equivalent to 360 degrees.

See Also:
Constant Field Values

M_PI_2

public static final double M_PI_2
The constant for PI/2, equivalent to 90 degrees.

See Also:
Constant Field Values

M_3PI_2

public static final double M_3PI_2
The constant for 3*PI/2, equivalent to 270 degrees.

See Also:
Constant Field Values

M_PI_4

public static final double M_PI_4
The constant for 3*PI/4, equivalent to 45 degrees.

See Also:
Constant Field Values
Constructor Detail

Angle2D

public Angle2D()
Method Detail

formatAngle

public static double formatAngle(double angle)
Formats an angle between 0 and 2*PI.

Parameters:
angle - the angle before formatting
Returns:
the same angle, between 0 and 2*PI.

horizontalAngle

public static double horizontalAngle(Point2D point)
Returns the horizontal angle formed by the line joining the origin and the given point.


horizontalAngle

public static double horizontalAngle(double x,
                                     double y)
Returns the horizontal angle formed by the line joining the origin and the point with given coordinate.


horizontalAngle

public static double horizontalAngle(Vector2D vect)
Returns the horizontal angle formed by the line joining the origin and the point with given coordinate.


horizontalAngle

public static double horizontalAngle(LinearShape2D object)
Returns the horizontal angle formed by the line joining the two given points.


horizontalAngle

public static double horizontalAngle(Point2D p1,
                                     Point2D p2)
Returns the horizontal angle formed by the line joining the two given points.


horizontalAngle

public static double horizontalAngle(double x1,
                                     double y1,
                                     double x2,
                                     double y2)
Returns the horizontal angle formed by the line joining the two given points.


pseudoAngle

public static double pseudoAngle(Point2D p1,
                                 Point2D p2)

Computes the pseudo-angle of a line joining the 2 points. The pseudo-angle has same ordering property has natural angle, but is expected to be computed faster. The result is given between 0 and 360.

Parameters:
p1 - the initial point
p2 - the final point
Returns:
the pseudo angle of line joining p1 to p2

angle

public static double angle(LinearShape2D obj1,
                           LinearShape2D obj2)
Returns the oriented angle between two (directed) straight objects. Result is given in radians, between 0 and 2*PI.


angle

public static double angle(Vector2D vect1,
                           Vector2D vect2)
Returns the oriented angle between two vectors. Result is given in radians, between 0 and 2*PI.


angle

public static double angle(Point2D p1,
                           Point2D p2,
                           Point2D p3)
Returns the oriented angle between the ray formed by (p2, p1) and the ray formed by (p2, p3). Result is given in radians, between 0 and 2*PI.


angle

public static double angle(double x1,
                           double y1,
                           double x2,
                           double y2,
                           double x3,
                           double y3)
Returns the oriented angle between the ray formed by (p2, p1) and the ray formed by (p2, p3), where pi = (xi,yi), i=1,2,3. Result is given in radians, between 0 and 2*PI.


absoluteAngle

public static double absoluteAngle(Point2D p1,
                                   Point2D p2,
                                   Point2D p3)
Returns the absolute angle between the ray formed by (p2, p1) and the ray formed by (p2, p3). Result is given in radians, between 0 and PI.


absoluteAngle

public static double absoluteAngle(double x1,
                                   double y1,
                                   double x2,
                                   double y2,
                                   double x3,
                                   double y3)
Returns the absolute angle between the ray formed by (p2, p1) and the ray formed by (p2, p3), where pi = (xi,yi), i=1,2,3. Result is given in radians, between 0 and PI.


almostEquals

public static boolean almostEquals(double angle1,
                                   double angle2,
                                   double eps)
Checks whether two angles are equal, with respect to the given error bound.

Parameters:
angle1 - first angle to compare
angle2 - second angle to compare
eps - the threshold value for comparison
Returns:
true if the two angle are equal modulo 2*PI

equals

public static boolean equals(double angle1,
                             double angle2)
Checks whether two angles are equal, given a default threshold value.

Parameters:
angle1 - first angle to compare
angle2 - second angle to compare
Returns:
true if the two angle are equal modulo 2*PI

containsAngle

public static boolean containsAngle(double startAngle,
                                    double endAngle,
                                    double angle)
Tests if an angle belongs to an angular interval, defined by two limit angle, counted Counter-clockwise.

Parameters:
startAngle - the beginning of the angular domain
endAngle - the end of the angular domain
angle - the angle to test
Returns:
true if angle is between the 2 limits

containsAngle

public static boolean containsAngle(double startAngle,
                                    double endAngle,
                                    double angle,
                                    boolean direct)
Tests if an angle belongs to an angular interval, defined by two limit angles, and an orientation flag.

Parameters:
startAngle - the beginning of the angular domain
endAngle - the end of the angular domain
angle - the angle to test
direct - is true if angular domain is oriented Counter clockwise, and false if angular domain is oriented clockwise.
Returns:
true if angle is between the 2 limits