Class Angles

java.lang.Object
org.jhotdraw8.geom.Angles

public class Angles extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    angle(double x1, double y1, double x2, double y2)
    Gets the angle of the specified line.
    static double
    anglesSignedSpan(double from, double to)
    Signed shortest distance between two angles.
    static double
    angleSubtract(double from, double to)
    Signed difference of two angles.
    static double
    anglesUnsignedSpan(double from, double to)
    Unsigned shortest distance between two angles.
    static double
    atan2(double dy, double dx)
    Computes atan2 if dy and dx are large enough.
    static double
    atan2Ellipse(double cx, double cy, double rx, double ry, double x, double y)
     
    static double
    cosDegrees(double aDeg)
    Returns the trigonometric cosine of an angle in degrees.
    static int
    direction(double x1, double y1, double x2, double y2)
    Returns the direction OUT_TOP, OUT_BOTTOM, OUT_LEFT, OUT_RIGHT from one point to another one.
    perp(double x, double y)
    Gets the perpendicular vector to the given vector.
    static double
    sinDegrees(double aDeg)
    Returns the trigonometric sine of an angle in degrees.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Angles

      public Angles()
  • Method Details

    • angle

      public static double angle(double x1, double y1, double x2, double y2)
      Gets the angle of the specified line.
      Parameters:
      x1 - the x-coordinate of point 1 on the line
      y1 - the y-coordinate of point 1 on the line
      x2 - the x-coordinate of point 2 on the line
      y2 - the y-coordinate of point 2 on the line
      Returns:
      the angle in radians
    • atan2

      public static double atan2(double dy, double dx)
      Computes atan2 if dy and dx are large enough.

      Math.atan2 can go into an infinite loop if dy and dx are almost zero.

      Parameters:
      dy - the dy
      dx - the dx
      Returns:
      atan2 of dy, dx or 0.
    • angleSubtract

      public static double angleSubtract(double from, double to)
      Signed difference of two angles.
      Parameters:
      from - angle 0
      to - angle 1
      Returns:
      -PI <= diff <= PI.
    • anglesSignedSpan

      public static double anglesSignedSpan(double from, double to)
      Signed shortest distance between two angles.
      Parameters:
      from - angle 0
      to - angle 1
      Returns:
      -PI <= diff <= PI.
    • anglesUnsignedSpan

      public static double anglesUnsignedSpan(double from, double to)
      Unsigned shortest distance between two angles.
      Parameters:
      from - angle 0
      to - angle 1
      Returns:
      0 <= diff <= PI.
    • direction

      public static int direction(double x1, double y1, double x2, double y2)
      Returns the direction OUT_TOP, OUT_BOTTOM, OUT_LEFT, OUT_RIGHT from one point to another one.
      Parameters:
      x1 - the x coordinate of point 1
      y1 - the y coordinate of point 1
      x2 - the x coordinate of point 2
      y2 - the y coordinate of point 2
      Returns:
      the direction
    • perp

      public static Point2D.Double perp(double x, double y)
      Gets the perpendicular vector to the given vector.
      Parameters:
      x - the x value of the vector
      y - the x value of the vector
      Returns:
      the perpendicular vector
    • atan2Ellipse

      public static double atan2Ellipse(double cx, double cy, double rx, double ry, double x, double y)
    • sinDegrees

      public static double sinDegrees(double aDeg)
      Returns the trigonometric sine of an angle in degrees.

      References:

      Values of Trigonometric ratios for 0, 30, 45, 60 and 90 degrees
      mathinstructor.net
      Parameters:
      aDeg - an angle in degrees
      Returns:
      the sine of the argument
    • cosDegrees

      public static double cosDegrees(double aDeg)
      Returns the trigonometric cosine of an angle in degrees.

      References:

      Values of Trigonometric ratios for 0, 30, 45, 60 and 90 degrees
      mathinstructor.net
      Parameters:
      aDeg - an angle in degrees
      Returns:
      the cosine of the argument