org.starhope.appius.geometry
Class Vector2D

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

public final class Vector2D
extends Tuple2D<Vector2D>

WRITEME: Document this type.

Author:
ewinkelman
See Also:
Serialized Form

Field Summary
private static long serialVersionUID
          WRITEME: Document this brpocock@star-hope.org
 
Fields inherited from class org.starhope.appius.geometry.Tuple2D
x, y
 
Constructor Summary
Vector2D(double x0, double y0)
          Create a coordinate pair from an x and y value
Vector2D(Vector2D v)
          Creates a vector from an existing vector pair
 
Method Summary
 double dot(Vector2D v2d)
          Gets the dot product of the two vectors
 boolean isZero()
           
 double length()
          Gets the length/magnitude of the vector
protected  Vector2D 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
 Vector2D normalize()
          Returns a normalised version of the vector
 Vector2D scale(double magnitude)
          Returns a new vector scaled by the magnitude given
 
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
WRITEME: Document this brpocock@star-hope.org

See Also:
Constant Field Values
Constructor Detail

Vector2D

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

Parameters:
x0 - x
y0 - y

Vector2D

public Vector2D(Vector2D v)
Creates a vector from an existing vector pair

Parameters:
v - WRITEME
Method Detail

dot

public double dot(Vector2D v2d)
Gets the dot product of the two vectors

Parameters:
v2d - WRITEME
Returns:
dot-product

isZero

public boolean isZero()
Returns:
true, if x == y == 0

length

public double length()
Gets the length/magnitude of the vector

Returns:
the length (magnitude) of the vector

newInstance

protected Vector2D 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<Vector2D>
Parameters:
x0 - x
y0 - y
Returns:
(x,y)
See Also:
Tuple2D.newInstance(double, double)

normalize

public Vector2D normalize()
Returns a normalised version of the vector

Returns:
WRITEME

scale

public Vector2D scale(double magnitude)
Returns a new vector scaled by the magnitude given

Parameters:
magnitude - WRITEME
Returns:
WRITEME