org.starhope.appius.geometry
Class Coord2D

java.lang.Object
  extended by org.starhope.appius.geometry.Tuple2D<Coord2D>
      extended by org.starhope.appius.geometry.Coord2D
All Implemented Interfaces:
Serializable, CastsToJSON

public final class Coord2D
extends Tuple2D<Coord2D>

WRITEME: Document this type.

Author:
ewinkelman
See Also:
Serialized Form

Field Summary
private static long serialVersionUID
          Java serialisation unique ID
 
Fields inherited from class org.starhope.appius.geometry.Tuple2D
x, y
 
Constructor Summary
Coord2D(Coord2D c)
          Creates a coordinate pair from an existing coordinate pair
Coord2D(double x0, double y0)
          Create a coordinate pair from an x and y value
Coord2D(org.json.JSONObject jso)
          Create a Coord2D from a JSON object
 
Method Summary
 double distance(Coord2D coord2d)
          Gets the distance from this coordinate to the given one
 double distance(double x0, double y0)
          Gets the distance from this coordinate to the given one
protected  Coord2D newInstance(double x0, double y0)
          Creates a new instance of the coordinate pair for use by the abstract generic parent class to get around downcasting problems
static Coord2D parseCoord2D(String string)
          understands (x,y) or x,y forms
static List<Coord2D> parseCoord2D(String[] parts)
           
 Coord3D toCoord3D()
           
 Coord2D translate(double dX, double dY)
          Moves the point by the given delta x and y
 
Methods inherited from class org.starhope.appius.geometry.Tuple2D
add, add, clone, divide, equals, getX, getY, hashCode, multiply, subtract, subtract, toJSON, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Java serialisation unique ID

See Also:
Constant Field Values
Constructor Detail

Coord2D

public Coord2D(Coord2D c)
Creates a coordinate pair from an existing coordinate pair

Parameters:
c - other coördinates

Coord2D

public Coord2D(double x0,
               double y0)
Create a coordinate pair from an x and y value

Parameters:
x0 - x ordinate
y0 - y abscissa

Coord2D

public Coord2D(org.json.JSONObject jso)
        throws org.json.JSONException
Create a Coord2D from a JSON object

Parameters:
jso - an object with "x" and "y" values
Throws:
org.json.JSONException - on malformed input
Method Detail

parseCoord2D

public static Coord2D parseCoord2D(String string)
understands (x,y) or x,y forms

Parameters:
string - WRITEME
Returns:
coördinates

parseCoord2D

public static List<Coord2D> parseCoord2D(String[] parts)
Parameters:
parts - list of coördinates as a string
Returns:
list of coördinates

distance

public double distance(Coord2D coord2d)
Gets the distance from this coordinate to the given one

Parameters:
coord2d - Target coordinate
Returns:
Distance to target coordinate

distance

public double distance(double x0,
                       double y0)
Gets the distance from this coordinate to the given one

Parameters:
x0 - x
y0 - y
Returns:
distance

newInstance

protected Coord2D newInstance(double x0,
                              double y0)
Creates a new instance of the coordinate pair for use by the abstract generic parent class to get around downcasting problems

Specified by:
newInstance in class Tuple2D<Coord2D>
Parameters:
x0 - x
y0 - y
Returns:
(x,y)
See Also:
Tuple2D.newInstance(double, double)

toCoord3D

public Coord3D toCoord3D()
Returns:
(x,y,0)

translate

public Coord2D translate(double dX,
                         double dY)
Moves the point by the given delta x and y

Parameters:
dX - Δx
dY - Δy
Returns:
new coördinates