Class CoordsDegrees

java.lang.Object
uk.ac.starlink.ttools.func.CoordsDegrees

public class CoordsDegrees extends Object
Functions for angle transformations and manipulations, with angles generally in degrees. In particular, methods for translating between degrees and HH:MM:SS.S or DDD:MM:SS.S type sexagesimal representations are provided.
Since:
11 Oct 2011
Author:
Mark Taylor
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    degreesToDms(double deg)
    Converts an angle in degrees to a formatted degrees:minutes:seconds string.
    static String
    degreesToDms(double deg, int secFig)
    Converts an angle in degrees to a formatted degrees:minutes:seconds string with a given number of decimal places in the seconds field.
    static String
    degreesToHms(double deg)
    Converts an angle in degrees to a formatted hours:minutes:seconds string.
    static String
    degreesToHms(double deg, int secFig)
    Converts an angle in degrees to a formatted hours:minutes:seconds string with a given number of decimal places in the seconds field.
    static double
    dmsToDegrees(double deg, double min, double sec)
    Converts degrees, minutes, seconds to an angle in degrees.
    static double
    Converts a formatted degrees:minutes:seconds string to an angle in degrees.
    static double
    hmsToDegrees(double hour, double min, double sec)
    Converts hours, minutes, seconds to an angle in degrees.
    static double
    Converts a formatted hours:minutes:seconds string to an angle in degrees.
    static double
    polarDistanceDegrees(double ra1, double dec1, double radius1, double ra2, double dec2, double radius2)
    Calculates the distance in three dimensional space between two points specified in spherical polar coordinates.
    static double
    posAngDegrees(double ra1, double dec1, double ra2, double dec2)
    Calculates the position angle between two points on the sky in degrees.
    static double
    skyDistanceDegrees(double ra1, double dec1, double ra2, double dec2)
    Calculates the separation (distance around a great circle) of two points on the sky in degrees.

    Methods inherited from class java.lang.Object

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

    • degreesToDms

      public static String degreesToDms(double deg)
      Converts an angle in degrees to a formatted degrees:minutes:seconds string. No fractional part of the seconds field is given.
      Parameters:
      deg - angle in degrees
      Returns:
      DMS-format string representing deg
    • degreesToDms

      public static String degreesToDms(double deg, int secFig)
      Converts an angle in degrees to a formatted degrees:minutes:seconds string with a given number of decimal places in the seconds field.
      Parameters:
      deg - angle in degrees
      secFig - number of decimal places in the seconds field
      Returns:
      DMS-format string representing deg
    • degreesToHms

      public static String degreesToHms(double deg)
      Converts an angle in degrees to a formatted hours:minutes:seconds string. No fractional part of the seconds field is given.
      Parameters:
      deg - angle in degrees
      Returns:
      HMS-format string representing deg
    • degreesToHms

      public static String degreesToHms(double deg, int secFig)
      Converts an angle in degrees to a formatted hours:minutes:seconds string with a given number of decimal places in the seconds field.
      Parameters:
      deg - angle in degrees
      secFig - number of decimal places in the seconds field
      Returns:
      HMS-format string representing deg
    • dmsToDegrees

      public static double dmsToDegrees(String dms)
      Converts a formatted degrees:minutes:seconds string to an angle in degrees. Delimiters may be colon, space, characters dm[s], or some others. Additional spaces and leading +/- are permitted. The :seconds part is optional.
      Parameters:
      dms - formatted DMS string
      Returns:
      angle in degrees specified by dms
      Throws:
      NumberFormatException - if dms can't be parsed as a degrees:minutes:seconds string
    • hmsToDegrees

      public static double hmsToDegrees(String hms)
      Converts a formatted hours:minutes:seconds string to an angle in degrees. Delimiters may be colon, space, characters hm[s], or some others. Additional spaces and leading +/- are permitted. The :seconds part is optional.
      Parameters:
      hms - formatted HMS string
      Returns:
      angle in degrees specified by hms
      Throws:
      NumberFormatException - if dms can't be parsed as an hours:minutes:seconds string
    • dmsToDegrees

      public static double dmsToDegrees(double deg, double min, double sec)
      Converts degrees, minutes, seconds to an angle in degrees.

      In conversions of this type, one has to be careful to get the sign right in converting angles which are between 0 and -1 degrees. This routine uses the sign bit of the deg argument, taking care to distinguish between +0 and -0 (their internal representations are different for floating point values). It is illegal for the min or sec arguments to be negative.

      Parameters:
      deg - degrees part of angle
      min - minutes part of angle
      sec - seconds part of angle
      Returns:
      specified angle in degrees
      Throws:
      IllegalArgumentException - if an argument after the first non-zero one is negative
    • hmsToDegrees

      public static double hmsToDegrees(double hour, double min, double sec)
      Converts hours, minutes, seconds to an angle in degrees.

      In conversions of this type, one has to be careful to get the sign right in converting angles which are between 0 and -1 hours. This routine uses the sign bit of the hour argument, taking care to distinguish between +0 and -0 (their internal representations are different for floating point values).

      Parameters:
      hour - degrees part of angle
      min - minutes part of angle
      sec - seconds part of angle
      Returns:
      specified angle in degrees
      Throws:
      IllegalArgumentException - if an argument after the first non-zero one is negative
    • skyDistanceDegrees

      public static double skyDistanceDegrees(double ra1, double dec1, double ra2, double dec2)
      Calculates the separation (distance around a great circle) of two points on the sky in degrees.
      Parameters:
      ra1 - right ascension of point 1 in degrees
      dec1 - declination of point 1 in degrees
      ra2 - right ascension of point 2 in degrees
      dec2 - declination of point 2 in degrees
      Returns:
      angular distance between point 1 and point 2 in degrees
    • posAngDegrees

      public static double posAngDegrees(double ra1, double dec1, double ra2, double dec2)
      Calculates the position angle between two points on the sky in degrees. The result is in the range +/-180. If point 2 is due east of point 1, the result is +90. Zero is returned if the points are coincident.
      Parameters:
      ra1 - right ascension of point 1 in degrees
      dec1 - declination of point 1 in degrees
      ra2 - right ascension of point 2 in degrees
      dec2 - declination of point 2 in degrees
      Returns:
      bearing in degrees of point 2 from point 1.
    • polarDistanceDegrees

      public static double polarDistanceDegrees(double ra1, double dec1, double radius1, double ra2, double dec2, double radius2)
      Calculates the distance in three dimensional space between two points specified in spherical polar coordinates.
      Parameters:
      ra1 - right ascension of point 1 in degrees
      dec1 - declination of point1 in degrees
      radius1 - distance from origin of point1
      ra2 - right ascension of point 2 in degrees
      dec2 - declination of point2 in degrees
      radius2 - distance from origin of point2
      Returns:
      the linear distance between point1 and point2; units are as for radius1 and radius2