org.shlublu.javax.math
Class Vector2D

java.lang.Object
  |
  +--org.shlublu.javax.math.Vector2D
All Implemented Interfaces:
java.lang.Cloneable, Vector

public final class Vector2D
extends java.lang.Object
implements Vector

Creation : 2002/03/23 Class dedicated to implement 2D vector operations

Since:
0.5

Field Summary
 double x
          x coordinate
 double y
          y coordinate
 
Constructor Summary
Vector2D()
          Empty constructor, init to (.0, .0)
Vector2D(double dblX, double dblY)
          Constructor, init to the given arguments
Vector2D(Vector2D v)
          Constructor, init to the given vector
 
Method Summary
 void add(Vector2D v)
          Add the given vector
 java.lang.Object clone()
          Return a Vector2D equals() to this one
 void divide(double d)
          Divide this vector
 boolean equals(java.lang.Object o)
          True if o is not null, from the Vector2D class without beeing from a subclass, and have the same coordinates in the same order than this.
 void equilibrate()
          Equilibrate this vector
 Vector2D getDifference(Vector2D vToSubstract)
          Get the difference vector
 Vector2D getDivided(double d)
          Get the divided vector corresponding to this one
 Vector2D getEquilibrated()
          Return an equilibrated vector corresponding to this
 Vector2D getNormalized()
          Return a normalized vector corresponding to this
 Point2D getPoint()
          Get the Point corresponding to this Vector
 Vector2D getProduct(double d)
          Get the multiplied vector corresponding to this one
 Vector2D getProjected(Vector2D v)
          Get the projection on this of the given vector
 Vector2D getSum(Vector2D vToAdd)
          Get the sum vector
 void multiply(double d)
          Multiply this vector
 double norm()
          Get this vector's norm
 void normalize()
          Normalize this vector
 Vector2D projectOn(Vector2D v)
          Get the projection on the given vector of this
 double scalarProduct(Vector2D v)
          Get the scalar (or dot) product with the given vector
 void substract(Vector2D v)
          Substract the given vector
 java.lang.String toString()
          Get this vector as a string
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

x

public double x
x coordinate

y

public double y
y coordinate
Constructor Detail

Vector2D

public Vector2D()
Empty constructor, init to (.0, .0)

Vector2D

public Vector2D(double dblX,
                double dblY)
Constructor, init to the given arguments

Vector2D

public Vector2D(Vector2D v)
Constructor, init to the given vector
Method Detail

toString

public java.lang.String toString()
Get this vector as a string
Specified by:
toString in interface Vector
Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
True if o is not null, from the Vector2D class without beeing from a subclass, and have the same coordinates in the same order than this.
Specified by:
equals in interface Vector
Overrides:
equals in class java.lang.Object

clone

public java.lang.Object clone()
Return a Vector2D equals() to this one
Specified by:
clone in interface Vector
Overrides:
clone in class java.lang.Object

getPoint

public Point2D getPoint()
Get the Point corresponding to this Vector

norm

public double norm()
Get this vector's norm
Specified by:
norm in interface Vector

normalize

public void normalize()
Normalize this vector
Specified by:
normalize in interface Vector

getNormalized

public Vector2D getNormalized()
Return a normalized vector corresponding to this

equilibrate

public void equilibrate()
Equilibrate this vector
Specified by:
equilibrate in interface Vector

getEquilibrated

public Vector2D getEquilibrated()
Return an equilibrated vector corresponding to this

multiply

public void multiply(double d)
Multiply this vector
Specified by:
multiply in interface Vector

getProduct

public Vector2D getProduct(double d)
Get the multiplied vector corresponding to this one

divide

public void divide(double d)
Divide this vector
Specified by:
divide in interface Vector

getDivided

public Vector2D getDivided(double d)
Get the divided vector corresponding to this one

add

public void add(Vector2D v)
Add the given vector

getSum

public Vector2D getSum(Vector2D vToAdd)
Get the sum vector

substract

public void substract(Vector2D v)
Substract the given vector

getDifference

public Vector2D getDifference(Vector2D vToSubstract)
Get the difference vector

scalarProduct

public double scalarProduct(Vector2D v)
Get the scalar (or dot) product with the given vector

getProjected

public Vector2D getProjected(Vector2D v)
Get the projection on this of the given vector

projectOn

public Vector2D projectOn(Vector2D v)
Get the projection on the given vector of this