jsky.coords
Class WorldCoords

java.lang.Object
  extended by jsky.coords.WorldCoords
All Implemented Interfaces:
java.io.Serializable, Coordinates, WorldCoordinates

public class WorldCoords
extends java.lang.Object
implements WorldCoordinates, java.io.Serializable

Class representing world coordinates (right-ascension, declination, stored as J2000 internally).

See Also:
Serialized Form

Field Summary
protected  DMS dec
          The DEC coordinate
protected  HMS ra
          The RA coordinate
 
Constructor Summary
WorldCoords()
          Default constructor: initialize null coordinates.
WorldCoords(double ra, double dec)
          Initialize from ra and dec (in degrees J2000).
WorldCoords(java.lang.Double ra, java.lang.Double dec)
          Initialize from ra and dec (in degrees J2000).
WorldCoords(double ra, double dec, double equinox)
          Initialize from ra and dec (in degrees).
WorldCoords(java.lang.Double ra, java.lang.Double dec, double equinox)
          Initialize from ra and dec (in degrees).
WorldCoords(double rh, int rm, double rs, double dd, int dm, double ds)
          Initialize from RA hours, minutes, seconds and and DEC degress, minutes, seconds in J2000.
WorldCoords(double rh, int rm, double rs, double dd, int dm, double ds, double equinox)
          Initialize from RA hours, minutes, seconds and and DEC degress, minutes, seconds.
WorldCoords(HMS ra, DMS dec)
          Initialize from ra (hours) and dec (degrees) in J2000.
WorldCoords(HMS ra, DMS dec, double equinox)
          Initialize from ra (hours) and dec (degrees).
WorldCoords(java.awt.geom.Point2D.Double p)
          Initialize from an ra, dec point (in degrees J2000).
WorldCoords(java.awt.geom.Point2D.Double p, double equinox)
          Initialize from an ra, dec point in the given equinox.
WorldCoords(java.lang.String ra, java.lang.String dec)
          Parse RA and DEC in string format (assume J2000).
WorldCoords(java.lang.String ra, java.lang.String dec, boolean hflag)
          Parse RA and DEC in string format (assume J2000).
WorldCoords(java.lang.String ra, java.lang.String dec, double equinox)
          Parse RA and DEC in string format.
WorldCoords(java.lang.String ra, java.lang.String dec, double equinox, boolean hflag)
          Parse RA and DEC in string format.
 
Method Summary
 WorldCoordinates[] box(double radius)
          Given a radius in arcmin, return an array {pos1, pos2} with the 2 endpoints that form a box with center at "this" position.
 double[] center(WorldCoordinates pos1, WorldCoordinates pos2)
          Given the endpoints of a box (pos1, pos2), return an array containing the center ra, dec in degrees, as well as the width, height, and radius of the box in arcmin.
static double[] dispos(double dra0, double decd0, double dra, double decd)
          Computes distance and position angle solving a spherical triangle (no approximations).
 double[] dispos(WorldCoordinates pos)
          return the distance between this position and the given one in arcmin and also set the position angle
 double dist(Coordinates pos)
          Return the distance between this position and the given one in arcmin.
static double dist(double ra0, double dec0, double ra1, double dec1)
          static member to get the distance between 2 points in arcmin
 double dist(WorldCoords pos)
          Return the distance between this position and the given one in arcmin.
 java.lang.String[] format()
          Format RA and DEC in h:m:s [+-]d:m:s format in J2000 and return them as a 2 element String array.
 java.lang.String[] format(double equinox)
          Format RA and DEC in h:m:s [+-]d:m:s format in the given equinox and return them as a 2 element String array.
 java.lang.String getCoordinateSystemName()
          Returns the name of the coordinate system as a string.
 DMS getDec()
          return the DEC value
 double getDecDeg()
          return the DEC value in deg
 HMS getRA()
          return the RA value
 double[] getRaDec(double equinox)
          Return RA and DEC in degrees as an array of 2 doubles {ra, dec} in the given equinox.
 double getRaDeg()
          return the RA value in deg
 double getX()
          return the X (ra) coordinate in deg
 double getY()
          return the Y *dec) coordinate in deg
static void main(java.lang.String[] args)
          Test cases
 java.lang.String toString()
          Return the coordinates as a string in h:m:s [+-]d:m:s format
static double wcsdist(double x1, double y1, double x2, double y2)
          Compute the distance in degrees between the two given coordinates.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ra

protected HMS ra
The RA coordinate


dec

protected DMS dec
The DEC coordinate

Constructor Detail

WorldCoords

public WorldCoords()
Default constructor: initialize null coordinates.


WorldCoords

public WorldCoords(HMS ra,
                   DMS dec,
                   double equinox)
Initialize from ra (hours) and dec (degrees).

Parameters:
ra - The RA value in hours
dec - The DEC value in degrees
equinox - The equinox of the input coordinates.

WorldCoords

public WorldCoords(HMS ra,
                   DMS dec)
Initialize from ra (hours) and dec (degrees) in J2000.

Parameters:
ra - The RA value in hours
dec - The DEC value in degrees

WorldCoords

public WorldCoords(double ra,
                   double dec,
                   double equinox)
Initialize from ra and dec (in degrees).

Parameters:
ra - The RA value in degrees
dec - The DEC value in degrees
equinox - The equinox of the input coordinates.

WorldCoords

public WorldCoords(java.lang.Double ra,
                   java.lang.Double dec,
                   double equinox)
Initialize from ra and dec (in degrees).

Parameters:
ra - The RA value in degrees
dec - The DEC value in degrees
equinox - The equinox of the input coordinates.

WorldCoords

public WorldCoords(double ra,
                   double dec)
Initialize from ra and dec (in degrees J2000).

Parameters:
ra - The RA value in degrees
dec - The DEC value in degrees

WorldCoords

public WorldCoords(java.awt.geom.Point2D.Double p,
                   double equinox)
Initialize from an ra, dec point in the given equinox.

Parameters:
p - The RA,Dec point in degrees

WorldCoords

public WorldCoords(java.awt.geom.Point2D.Double p)
Initialize from an ra, dec point (in degrees J2000).

Parameters:
p - The RA,Dec point in degrees

WorldCoords

public WorldCoords(java.lang.Double ra,
                   java.lang.Double dec)
Initialize from ra and dec (in degrees J2000).

Parameters:
ra - The RA value in degrees
dec - The DEC value in degrees

WorldCoords

public WorldCoords(double rh,
                   int rm,
                   double rs,
                   double dd,
                   int dm,
                   double ds,
                   double equinox)
Initialize from RA hours, minutes, seconds and and DEC degress, minutes, seconds.

Parameters:
rh - RA hours
rm - RA minutes
rs - RA seconds
dd - DEC degrees
dm - DEC minutes
ds - DEC seconds
equinox - The equinox of the input coordinates.

WorldCoords

public WorldCoords(double rh,
                   int rm,
                   double rs,
                   double dd,
                   int dm,
                   double ds)
Initialize from RA hours, minutes, seconds and and DEC degress, minutes, seconds in J2000.

Parameters:
rh - RA hours
rm - RA minutes
rs - RA seconds
dd - DEC degrees
dm - DEC minutes
ds - DEC seconds

WorldCoords

public WorldCoords(java.lang.String ra,
                   java.lang.String dec,
                   double equinox)
Parse RA and DEC in string format.

Parameters:
ra - The RA value in the form "hh mm ss.s", "hh:mm:ss.s", or just "hh.hhh".
dec - The DEC value in the form "[+/-]dd mm ss.s", "[+/-]dd:mm:ss.s" or just "[+/-]dd.ddd".
equinox - The equinox of the input coordinates.

WorldCoords

public WorldCoords(java.lang.String ra,
                   java.lang.String dec,
                   double equinox,
                   boolean hflag)
Parse RA and DEC in string format.

Parameters:
ra - The RA value in the form "hh mm ss.s", "hh:mm:ss.s", or just "hh.hhh".
dec - The DEC value in the form "[+/-]dd mm ss.s", "[+/-]dd:mm:ss.s" or just "[+/-]dd.ddd".
equinox - The equinox of the input coordinates.
hflag - if true, always assume ra is in hours, otherwise, assume deg if ra is a decimal value.

WorldCoords

public WorldCoords(java.lang.String ra,
                   java.lang.String dec)
Parse RA and DEC in string format (assume J2000).

Parameters:
ra - The RA value in the form "hh mm ss.s", "hh:mm:ss.s", or just "hh.hhh".
dec - The DEC value in the form "[+/-]dd mm ss.s", "[+/-]dd:mm:ss.s" or just "[+/-]dd.ddd".

WorldCoords

public WorldCoords(java.lang.String ra,
                   java.lang.String dec,
                   boolean hflag)
Parse RA and DEC in string format (assume J2000).

Parameters:
ra - The RA value in the form "hh mm ss.s", "hh:mm:ss.s", or just "hh.hhh".
dec - The DEC value in the form "[+/-]dd mm ss.s", "[+/-]dd:mm:ss.s" or just "[+/-]dd.ddd".
hflag - if true, always assume ra is in hours, otherwise, assume deg if ra is a decimal value.
Method Detail

getRA

public HMS getRA()
return the RA value

Specified by:
getRA in interface WorldCoordinates

getDec

public DMS getDec()
return the DEC value

Specified by:
getDec in interface WorldCoordinates

getRaDeg

public double getRaDeg()
return the RA value in deg

Specified by:
getRaDeg in interface WorldCoordinates

getDecDeg

public double getDecDeg()
return the DEC value in deg

Specified by:
getDecDeg in interface WorldCoordinates

getX

public double getX()
return the X (ra) coordinate in deg

Specified by:
getX in interface Coordinates

getY

public double getY()
return the Y *dec) coordinate in deg

Specified by:
getY in interface Coordinates

toString

public java.lang.String toString()
Return the coordinates as a string in h:m:s [+-]d:m:s format

Specified by:
toString in interface Coordinates
Specified by:
toString in interface WorldCoordinates
Overrides:
toString in class java.lang.Object

format

public java.lang.String[] format(double equinox)
Format RA and DEC in h:m:s [+-]d:m:s format in the given equinox and return them as a 2 element String array.

Specified by:
format in interface WorldCoordinates

format

public java.lang.String[] format()
Format RA and DEC in h:m:s [+-]d:m:s format in J2000 and return them as a 2 element String array.

Specified by:
format in interface WorldCoordinates

getRaDec

public double[] getRaDec(double equinox)
Return RA and DEC in degrees as an array of 2 doubles {ra, dec} in the given equinox.

Specified by:
getRaDec in interface WorldCoordinates

dispos

public static double[] dispos(double dra0,
                              double decd0,
                              double dra,
                              double decd)
Computes distance and position angle solving a spherical triangle (no approximations). The arguments are the coordinates in decimal degrees and the result is an array containing the 2 values.

Parameters:
dra0 - center RA
decd0 - center DEC
dra - point RA
decd - point DEC
Returns:
An array of 2 doubles ar[2], where ar[0] is the distance in arcmin and ar[1] is the position angle phi in degrees (East of North). (Based on the C version from A. P. Martinez.)

dispos

public double[] dispos(WorldCoordinates pos)
return the distance between this position and the given one in arcmin and also set the position angle

Specified by:
dispos in interface WorldCoordinates
Parameters:
pos - The other point.
Returns:
An array of 2 doubles ar[2], where ar[0] is the distance in arcmin and ar[1] is the position angle in degrees (East of North).

wcsdist

public static double wcsdist(double x1,
                             double y1,
                             double x2,
                             double y2)
Compute the distance in degrees between the two given coordinates. (Based on the C version in D. Mink's wcssubs package.)


dist

public double dist(WorldCoords pos)
Return the distance between this position and the given one in arcmin.

Parameters:
pos - The other point.
Returns:
The distance to the given point in arcmin.

dist

public double dist(Coordinates pos)
Return the distance between this position and the given one in arcmin.

Specified by:
dist in interface Coordinates
Parameters:
pos - The other point.
Returns:
The distance to the given point in arcmin.

dist

public static double dist(double ra0,
                          double dec0,
                          double ra1,
                          double dec1)
static member to get the distance between 2 points in arcmin

Parameters:
ra0 - The first RA value
dec0 - The first DEC value
ra1 - The second RA value
dec1 - The second DEC value
Returns:
The distance in arcmin.

box

public WorldCoordinates[] box(double radius)
Given a radius in arcmin, return an array {pos1, pos2} with the 2 endpoints that form a box with center at "this" position.

Specified by:
box in interface WorldCoordinates
Parameters:
radius - The radius in arcmin.
Returns:
Array of 2 WorldCoords objects that are the endpoints of a box with the given radius and centered at "this" position.

center

public double[] center(WorldCoordinates pos1,
                       WorldCoordinates pos2)
Given the endpoints of a box (pos1, pos2), return an array containing the center ra, dec in degrees, as well as the width, height, and radius of the box in arcmin.

Specified by:
center in interface WorldCoordinates
Parameters:
pos1 - The first endpoint of the box.
pos2 - The second endpoint of the box.
Returns:
An array of 5 doubles: {ra, dec, width, height, radius} where (ra, dec) gives the center position in deg, width and height are the size of the box in arcmin, and radius is the distance from the center to a corner in arcmin.

getCoordinateSystemName

public java.lang.String getCoordinateSystemName()
Returns the name of the coordinate system as a string.

Specified by:
getCoordinateSystemName in interface Coordinates

main

public static void main(java.lang.String[] args)
Test cases