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.Vector2d
All Implemented Interfaces:
OptimizationTypes, XMLTranslationExceptionTypes, java.lang.Cloneable

public class Vector2d
extends ElementState
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.ClassToCollectionMap, ElementState.DeclarationStyle, ElementState.xml_attribute, ElementState.xml_class, ElementState.xml_classes, ElementState.xml_collection, ElementState.xml_leaf, ElementState.xml_map, ElementState.xml_nested, ElementState.xml_tag
 
Field Summary
protected  double x
           
protected  double y
           
 
Fields inherited from class ecologylab.xml.ElementState
CDATA, ESTIMATE_CHARS_PER_FIELD, FLOATING_PRECISION_OFF, MARSHALLING_PARAMS, NORMAL, UTF16, UTF16_LE, UTF8, XML_FILE_HEADER
 
Fields inherited from interface ecologylab.xml.OptimizationTypes
BAD_FIELD, COLLECTION_ELEMENT, COLLECTION_SCALAR, IGNORED_ATTRIBUTE, IGNORED_ELEMENT, LEAF_NODE_VALUE, MAP_ELEMENT, MAP_SCALAR, NAME_SPACE_ATTRIBUTE, NAME_SPACE_LEAF_NODE, NAME_SPACE_MASK, NAME_SPACE_NESTED_ELEMENT, NAMESPACE_IGNORED_ELEMENT, NAMESPACE_TRIAL_ELEMENT, OTHER_NESTED_ELEMENT, REGULAR_ATTRIBUTE, REGULAR_NESTED_ELEMENT, ROOT, UNSET_TYPE, 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 degrees.
static Vector2d scalarMultiply(Vector2d vector, double scalar)
          Multiplies a vector by a scalar value and returns a new Vector2d representing the result.
 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)
           
 void sub(Vector2d v)
           
static Vector2d sub(Vector2d v1, Vector2d v2)
          Subtracts v2 from v1 and returns a new Vector2d representing the result.
 java.awt.geom.Point2D toPoint()
           
 double toRadians()
           
 java.lang.String toString()
           
 void unitize()
           
 Vector2d unitVector()
           
 void zero()
           
 
Methods inherited from class ecologylab.xml.ElementState
addNestedElement, addNestedElement, appendTextNodeString, buildDOM, buildDOM, buildDOM, buildDOM, buildDOM, buildDOMFromXMLCharSequence, buildDOMFromXMLString, checkAnnotation, convertNameStyles, createChildHook, fieldToXMLOptimizations, floatingPrecision, getCollection, getElementStateById, getMap, getNestedNameSpace, getTextNodeString, leafElementFieldNames, lookupNestedNameSpace, optimizations, parent, postTranslationProcessingHook, preTranslationProcessingHook, recycle, setDeclarationStyle, setFieldUsingTypeRegistry, setFloatingPrecision, 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, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

x

protected double x

y

protected double y
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(Vector2d v1,
                           Vector2d 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 degrees.

Parameters:
angle - - in radians

sub

public void sub(Vector2d v)

toRadians

public double toRadians()

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()

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()

setX

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

setY

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

getX

public double getX()
Returns:
the x

getY

public double getY()
Returns:
the y