ecologylab.xml.library.geom
Class Vector2d

java.lang.Object
  extended by ecologylab.generic.Debug
      extended by ecologylab.xml.ElementState
          extended by ecologylab.xml.library.geom.SpatialVector
              extended by ecologylab.xml.library.geom.Vector2d
All Implemented Interfaces:
FieldTypes, XMLTranslationExceptionTypes, java.lang.Cloneable

public class Vector2d
extends SpatialVector
implements java.lang.Cloneable

Author:
Zachary O. Toups (toupsz@cs.tamu.edu)

Nested Class Summary
 
Nested classes/interfaces inherited from class ecologylab.xml.ElementState
ElementState.DeclarationStyle, ElementState.xml_attribute, ElementState.xml_bind_from, ElementState.xml_bind_to, ElementState.xml_class, ElementState.xml_classes, ElementState.xml_collection, ElementState.xml_format, ElementState.xml_leaf, ElementState.xml_map, ElementState.xml_nested, ElementState.xml_nowrap, ElementState.xml_other_tags, ElementState.xml_scope, ElementState.xml_tag, ElementState.xml_text
 
Field Summary
 
Fields inherited from class ecologylab.xml.ElementState
CDATA, NORMAL, UTF16, UTF16_LE, UTF8
 
Fields inherited from interface ecologylab.xml.FieldTypes
ATTRIBUTE, AWFUL_OLD_NESTED_ELEMENT, BAD_FIELD, COLLECTION_ELEMENT, COLLECTION_SCALAR, IGNORED_ATTRIBUTE, IGNORED_ELEMENT, LEAF, MAP_ELEMENT, MAP_SCALAR, NAME_SPACE_ATTRIBUTE, NAME_SPACE_LEAF_NODE, NAME_SPACE_MASK, NAME_SPACE_NESTED_ELEMENT, NAMESPACE_IGNORED_ELEMENT, NAMESPACE_TRIAL_ELEMENT, NESTED_ELEMENT, PSEUDO_FIELD_DESCRIPTOR, ROOT, TEXT_ELEMENT, TEXT_NODE_VALUE, UNSET_TYPE, WRAPPER, XMLNS_ATTRIBUTE, XMLNS_IGNORED
 
Fields inherited from interface ecologylab.xml.XMLTranslationExceptionTypes
FILE_NOT_FOUND, IO_EXCEPTION, NULL_PURL, UNKNOWN
 
Constructor Summary
Vector2d()
           
Vector2d(double x, double y)
           
Vector2d(Vector2d otherVect)
           
 
Method Summary
 void add(Vector2d v)
           
static Vector2d add(Vector2d v1, Vector2d v2)
          Adds two vectors together and returns a new Vector2d object representing the sum.
 Vector2d clone()
           
static double dot(Vector2d v1, Vector2d v2)
          Determines the dot product of two vector objects.
 double getX()
           
 double getY()
           
 void mult(double scalar)
           
 double norm()
           
 void rotate(double angle)
          Rotates this vector around the origin by the specified angle in degrees.
 void rotateTo(double angle)
          Rotates this vector so that it is aligned to the specified angle in radians.
static Vector2d scalarMultiply(Vector2d vector, double scalar)
          Multiplies a vector by a scalar value and returns a new Vector2d representing the result.
 void set(double x, double y)
           
 void set(Vector2d pos)
           
 void setNorm(double mag)
          Adjusts the magnitude of this vector to match mag.
 void setX(double x)
           
 void setY(double y)
           
static Vector2d sub(SpatialVector v1, SpatialVector v2)
          Subtracts v2 from v1 and returns a new Vector2d representing the result.
 void sub(Vector2d v)
           
 java.awt.geom.Point2D toPoint()
           
 double toRadians()
          Converts the vector into a radian angle.
 java.lang.String toString()
           
 void unitize()
           
 Vector2d unitVector()
           
 void zero()
           
 
Methods inherited from class ecologylab.xml.ElementState
buildDOM, buildDOM, buildDOM, buildDOM, buildDOM, buildDOMFromXMLCharSequence, buildDOMFromXMLString, checkAnnotation, classDescriptor, createParentDirs, getChildFieldAccessors, getElementStateById, getFieldDescriptors, getNestedNameSpace, getTextNodeString, hasScalarTextField, lookupNestedNameSpace, parent, recycle, setDeclarationStyle, setParent, setUseDOMForTranslateTo, translateFromXML, translateFromXML, translateFromXML, translateFromXML, translateFromXML, translateFromXMLCharSequence, translateFromXMLDOM, translateFromXMLDOM, translateFromXMLDOM, translateFromXMLDOM, translateFromXMLDOM, translateFromXMLDOM, translateFromXMLDOMCharSequence, translateFromXMLDOMCharSequence, translateFromXMLRootNode, translateFromXMLSAX, translateFromXMLSAX, translateFromXMLSAX, translateFromXMLSAX, translateFromXMLSAX, translateToDOM, translateToXML, translateToXML, translateToXML, translateToXML, writePrettyXML, writePrettyXML, writePrettyXML
 
Methods inherited from class ecologylab.generic.Debug
classSimpleName, closeLoggingFile, debug, debug, debug, debug, debugA, debugA, debugA, debugI, debugI, debugI, error, error, getClassName, getClassName, getInteractive, getPackageName, getPackageName, getPackageName, initialize, level, level, level, logToFile, print, print, println, println, println, println, println, println, printlnA, printlnA, printlnA, printlnI, printlnI, printlnI, printlnI, setLoggingFile, show, show, superString, toggleInteractive, toString, warning, warning, weird, weird
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Vector2d

public Vector2d()

Vector2d

public Vector2d(double x,
                double y)

Vector2d

public Vector2d(Vector2d otherVect)
Method Detail

add

public static Vector2d add(Vector2d v1,
                           Vector2d v2)
Adds two vectors together and returns a new Vector2d object representing the sum.

Parameters:
v1 -
v2 -
Returns:

scalarMultiply

public static Vector2d scalarMultiply(Vector2d vector,
                                      double scalar)
Multiplies a vector by a scalar value and returns a new Vector2d representing the result.

Parameters:
vector -
scalar -
Returns:

dot

public static double dot(Vector2d v1,
                         Vector2d v2)
Determines the dot product of two vector objects.

Parameters:
v1 -
v2 -
Returns:

sub

public static Vector2d sub(SpatialVector v1,
                           SpatialVector v2)
Subtracts v2 from v1 and returns a new Vector2d representing the result.

Parameters:
v1 -
v2 -
Returns:

add

public void add(Vector2d v)

norm

public double norm()

mult

public void mult(double scalar)

rotate

public void rotate(double angle)
Rotates this vector around the origin by the specified angle in degrees.

Parameters:
angle - - in radians

rotateTo

public void rotateTo(double angle)
Rotates this vector so that it is aligned to the specified angle in radians.

Parameters:
angle - - in radians

sub

public void sub(Vector2d v)

toRadians

public double toRadians()
Converts the vector into a radian angle. If the result would be NaN, returns 0.

Returns:

unitVector

public Vector2d unitVector()

unitize

public void unitize()

clone

public Vector2d clone()
Overrides:
clone in class java.lang.Object
See Also:
Object.clone()

set

public void set(Vector2d pos)

toPoint

public java.awt.geom.Point2D toPoint()
Specified by:
toPoint in class SpatialVector

toString

public java.lang.String toString()
Overrides:
toString in class Debug
See Also:
Debug.toString()

setNorm

public void setNorm(double mag)
Adjusts the magnitude of this vector to match mag.

Parameters:
mag -

zero

public void zero()

set

public void set(double x,
                double y)

setX

public void setX(double x)
Parameters:
y - the y to set

setY

public void setY(double y)
Parameters:
y - the y to set

getX

public double getX()
Specified by:
getX in class SpatialVector
Returns:
the x

getY

public double getY()
Specified by:
getY in class SpatialVector
Returns:
the y