jsky.coords
Class ImageCoords

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

public class ImageCoords
extends java.lang.Object
implements Coordinates, java.io.Serializable

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

See Also:
Serialized Form

Field Summary
protected  double x
          The X coordinate
protected  double y
          The Y coordinate
 
Constructor Summary
ImageCoords()
          Default constructor: initialize null coordinates.
ImageCoords(double x, double y)
          Initialize from x and y.
ImageCoords(java.lang.Double x, java.lang.Double y)
          Initialize from x and y.
ImageCoords(java.lang.String x, java.lang.String y)
           
 
Method Summary
 ImageCoords[] box(double radius)
          Given a radius, return an array {pos1, pos2} with the 2 endpoints that form a box with center at "this" position.
 double[] center(ImageCoords pos1, ImageCoords pos2)
          Given the endpoints of a box (pos1, pos2), return an array containing the center pos, as well as the width, height, and radius of the box.
 double dist(Coordinates pos)
          Return the distance between this position and the given one.
static double dist(double x0, double y0, double x1, double y1)
          Return the distance between the two points.
 double dist(ImageCoords pos)
          Return the distance between this position and the given one.
 java.lang.String getCoordinateSystemName()
          Returns the name of the coordinate system as a string.
 double getX()
          return the X value
 double getY()
          return the Y value
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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

x

protected double x
The X coordinate


y

protected double y
The Y coordinate

Constructor Detail

ImageCoords

public ImageCoords()
Default constructor: initialize null coordinates.


ImageCoords

public ImageCoords(double x,
                   double y)
Initialize from x and y.

Parameters:
x - The X coordinate
y - The Y coordinate

ImageCoords

public ImageCoords(java.lang.Double x,
                   java.lang.Double y)
Initialize from x and y.

Parameters:
x - The X coordinate
y - The Y coordinate

ImageCoords

public ImageCoords(java.lang.String x,
                   java.lang.String y)
Method Detail

getX

public double getX()
return the X value

Specified by:
getX in interface Coordinates

getY

public double getY()
return the Y value

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
Overrides:
toString in class java.lang.Object

dist

public static double dist(double x0,
                          double y0,
                          double x1,
                          double y1)
Return the distance between the two points.

Parameters:
x0 - The X coordinate of the first point
y0 - The Y coordinate of the first point
x1 - The X coordinate of the second point
y1 - The Y coordinate of the second point
Returns:
The distance between the two points.

dist

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

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

dist

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

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

box

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

Parameters:
radius - The radius.
Returns:
Array of 2 ImageCoords objects that are the endpoints of a box with the given radius and centered at "this" position.

center

public double[] center(ImageCoords pos1,
                       ImageCoords pos2)
Given the endpoints of a box (pos1, pos2), return an array containing the center pos, as well as the width, height, and radius of the box.

Parameters:
pos1 - The first endpoint of the box.
pos2 - The second endpoint of the box.
Returns:
An array of 5 doubles: {x, y, width, height, radius} where (x, y) gives the center position, width and height are the size of the box, and radius is the distance from the center to a corner.

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