Class Angle

java.lang.Object
com.vividsolutions.jump.geom.Angle

public class Angle extends Object
Utility functions for working with angles.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static int
    General constant representing clockwise orientation
    static int
    General constant representing counterclockwise orientation
    static int
    General constant representing no orientation
    static final double
     
    static final double
     
    static final double
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    angle(org.locationtech.jts.geom.Coordinate p)
    Returns the angle of the vector from (0,) to p.
    static double
    angle(org.locationtech.jts.geom.Coordinate p0, org.locationtech.jts.geom.Coordinate p1)
    Returns the angle of the vector from p0 to p1.
    static double
    angleBetween(org.locationtech.jts.geom.Coordinate tail, org.locationtech.jts.geom.Coordinate tip1, org.locationtech.jts.geom.Coordinate tip2)
    Returns the angle between two vectors.
    static double
    diff(double a1, double a2)
    Returns the angle between two vectors.
    static int
    getTurn(double a1, double a2)
    Returns whether an angle must turn clockwise or counterclockwise to overlap another angle.
    static double
    interiorAngle(org.locationtech.jts.geom.Coordinate p0, org.locationtech.jts.geom.Coordinate p1, org.locationtech.jts.geom.Coordinate p2)
    Computes the interior angle between two segments of a ring.
    static double
    normalize(double angle)
    Computes the normalized value of an angle, which is the equivalent angle lying between -Pi and Pi.
    static double
    toDegrees(double radians)
    Converts from radians to degrees.
    static double
    toRadians(double angleDegrees)
    Converts from degrees to radians.

    Methods inherited from class Object

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

    • PI_TIMES_2

      public static final double PI_TIMES_2
      See Also:
    • PI_OVER_2

      public static final double PI_OVER_2
      See Also:
    • PI_OVER_4

      public static final double PI_OVER_4
      See Also:
    • COUNTERCLOCKWISE

      public static int COUNTERCLOCKWISE
      General constant representing counterclockwise orientation
    • CLOCKWISE

      public static int CLOCKWISE
      General constant representing clockwise orientation
    • NONE

      public static int NONE
      General constant representing no orientation
  • Constructor Details

    • Angle

      public Angle()
  • Method Details

    • toDegrees

      public static double toDegrees(double radians)
      Converts from radians to degrees.
      Parameters:
      radians - an angle in radians
      Returns:
      the angle in degrees
    • angle

      public static double angle(org.locationtech.jts.geom.Coordinate p0, org.locationtech.jts.geom.Coordinate p1)
      Returns the angle of the vector from p0 to p1. The angle will be between -Pi and Pi.
      Parameters:
      p0 - first coordinate
      p1 - second coordinate
      Returns:
      the angle (in radians) that p0-p1 makes with the positive x-axis.
    • angle

      public static double angle(org.locationtech.jts.geom.Coordinate p)
      Returns the angle of the vector from (0,) to p. The angle will be between -Pi and Pi.
      Parameters:
      p - coordinate of a point p
      Returns:
      the angle (in radians) that p makes with the positive x-axis.
    • toRadians

      public static double toRadians(double angleDegrees)
      Converts from degrees to radians.
      Parameters:
      angleDegrees - an angle in degrees
      Returns:
      the angle in radians
    • angleBetween

      public static double angleBetween(org.locationtech.jts.geom.Coordinate tail, org.locationtech.jts.geom.Coordinate tip1, org.locationtech.jts.geom.Coordinate tip2)
      Returns the angle between two vectors. Will be between 0 and Pi.
      Parameters:
      tail - the tail of each vector
      tip1 - the tip of one vector
      tip2 - the tip of the other vector
      Returns:
      the angle between tail-tip1 and tail-tip2
    • interiorAngle

      public static double interiorAngle(org.locationtech.jts.geom.Coordinate p0, org.locationtech.jts.geom.Coordinate p1, org.locationtech.jts.geom.Coordinate p2)
      Computes the interior angle between two segments of a ring. The ring is assumed to be oriented in a clockwise direction.
      Parameters:
      p0 - a point of the ring
      p1 - the next point of the ring
      p2 - the next point of the ring
      Returns:
      the interior angle based at p1
    • getTurn

      public static int getTurn(double a1, double a2)
      Returns whether an angle must turn clockwise or counterclockwise to overlap another angle.
      Parameters:
      a1 - an angle in radians
      a2 - an angle in radians
      Returns:
      whether a1 must turn CLOCKWISE, COUNTERCLOCKWISE or NONE to overlap a2.
    • normalize

      public static double normalize(double angle)
      Computes the normalized value of an angle, which is the equivalent angle lying between -Pi and Pi.
      Parameters:
      angle - the angle to compute the normalized value of
      Returns:
      the normalized value of the angle
    • diff

      public static double diff(double a1, double a2)
      Returns the angle between two vectors.
      Parameters:
      a1 - the angle of one vector, between -Pi and Pi
      a2 - the angle of the other vector, between -Pi and Pi
      Returns:
      the angle (in radians) between the two vectors, between 0 and Pi