Class CoordsDegrees
java.lang.Object
uk.ac.starlink.ttools.func.CoordsDegrees
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 TypeMethodDescriptionstatic StringdegreesToDms(double deg) Converts an angle in degrees to a formatted degrees:minutes:seconds string.static StringdegreesToDms(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 StringdegreesToHms(double deg) Converts an angle in degrees to a formatted hours:minutes:seconds string.static StringdegreesToHms(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 doubledmsToDegrees(double deg, double min, double sec) Converts degrees, minutes, seconds to an angle in degrees.static doubledmsToDegrees(String dms) Converts a formatted degrees:minutes:seconds string to an angle in degrees.static doublehmsToDegrees(double hour, double min, double sec) Converts hours, minutes, seconds to an angle in degrees.static doublehmsToDegrees(String hms) Converts a formatted hours:minutes:seconds string to an angle in degrees.static doublepolarDistanceDegrees(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 doubleposAngDegrees(double ra1, double dec1, double ra2, double dec2) Calculates the position angle between two points on the sky in degrees.static doubleskyDistanceDegrees(double ra1, double dec1, double ra2, double dec2) Calculates the separation (distance around a great circle) of two points on the sky in degrees.
-
Method Details
-
degreesToDms
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
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 degreessecFig- number of decimal places in the seconds field- Returns:
- DMS-format string representing
deg
-
degreesToHms
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
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 degreessecFig- number of decimal places in the seconds field- Returns:
- HMS-format string representing
deg
-
dmsToDegrees
Converts a formatted degrees:minutes:seconds string to an angle in degrees. Delimiters may be colon, space, charactersdm[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- ifdmscan't be parsed as a degrees:minutes:seconds string
-
hmsToDegrees
Converts a formatted hours:minutes:seconds string to an angle in degrees. Delimiters may be colon, space, charactershm[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- ifdmscan'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
degargument, taking care to distinguish between +0 and -0 (their internal representations are different for floating point values). It is illegal for theminorsecarguments to be negative.- Parameters:
deg- degrees part of anglemin- minutes part of anglesec- 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
hourargument, taking care to distinguish between +0 and -0 (their internal representations are different for floating point values).- Parameters:
hour- degrees part of anglemin- minutes part of anglesec- 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 degreesdec1- declination of point 1 in degreesra2- right ascension of point 2 in degreesdec2- 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 degreesdec1- declination of point 1 in degreesra2- right ascension of point 2 in degreesdec2- 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 degreesdec1- declination of point1 in degreesradius1- distance from origin of point1ra2- right ascension of point 2 in degreesdec2- declination of point2 in degreesradius2- distance from origin of point2- Returns:
- the linear distance between point1 and point2;
units are as for
radius1andradius2
-