ecologylab.xml.library.geom
Class Vector2d
java.lang.Object
ecologylab.generic.Debug
ecologylab.xml.ElementState
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)
|
Field Summary |
protected double |
x
|
protected double |
y
|
| 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 |
| 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 |
x
protected double x
y
protected double y
Vector2d
public Vector2d()
Vector2d
public Vector2d(double x,
double y)
Vector2d
public Vector2d(Vector2d otherVect)
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