Class Angle

Object
Angle
All Implemented Interfaces:
Serializable, Comparable<Angle>
Direct Known Subclasses:
Latitude, Longitude

public class Angle extends Object implements Comparable<Angle>, Serializable
An angle in degrees. An angle is the amount of rotation needed to bring one line or plane into coincidence with another, generally measured in degrees, sexagesimal degrees or grads.

This class is registered with ClassChanger, which means it can be converted to and from Double.

Since:
2.0
Author:
Martin Desruisseaux (PMO, IRD)
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Angle(double theta)
    Contructs a new angle with the specified value.
    Angle(String string)
    Constructs a newly allocated Angle object that represents the angle value represented by the string.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Compares two Angle objects numerically.
    double
    Returns the angle value in degrees.
    boolean
    equals(Object object)
    Compares the specified object with this angle for equality.
    int
    Returns a hash code for this Angle object.
    double
    Returns the angle value in radians.
    Returns a string representation of this Angle object.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Angle

      public Angle(double theta)
      Contructs a new angle with the specified value.
      Parameters:
      theta - Angle in degrees.
    • Angle

      public Angle(String string) throws NumberFormatException
      Constructs a newly allocated Angle object that represents the angle value represented by the string. The string should represents an angle in either fractional degrees (e.g. 45.5°) or degrees with minutes and seconds (e.g. 45°30').
      Parameters:
      string - A string to be converted to an Angle.
      Throws:
      NumberFormatException - if the string does not contain a parsable angle.
  • Method Details

    • degrees

      public double degrees()
      Returns the angle value in degrees.
    • radians

      public double radians()
      Returns the angle value in radians.
    • hashCode

      public int hashCode()
      Returns a hash code for this Angle object.
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object object)
      Compares the specified object with this angle for equality.
      Overrides:
      equals in class Object
    • compareTo

      public int compareTo(Angle that)
      Compares two Angle objects numerically. The comparaison is done as if by the Double.compare(double,double) method.
      Specified by:
      compareTo in interface Comparable<Angle>
    • toString

      public String toString()
      Returns a string representation of this Angle object.
      Overrides:
      toString in class Object