quentinc.geom
Class Vector

java.lang.Object
  extended by quentinc.geom.Vector
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class Vector
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

Class for manipulating 3D vectors.

See Also:
Serialized Form

Constructor Summary
Vector()
          Default constructor.
Vector(double x, double y)
          _Create a new vector with given x and y, and z=0
Vector(double x, double y, double z)
          Create a new vector with given components
 
Method Summary
 Vector add(double x, double y, double z)
          Add values to each component
 Vector add(Vector v)
          Add the vector given to this one
 Vector clone()
           
 Vector crossProduct(Vector v)
          Return the cross product of this vector and the one given
 Vector divide(double f)
          Divide the vector by a scalar value
 boolean equals(java.lang.Object o)
           
 double getLength()
          Get the vector's length, as known as norma.
 double getX()
          Get X component
 double getY()
          Get Y component
 double getZ()
          Get Z component
 int hashCode()
           
 Vector linearTransform(Matrix m)
          Multiply this vector with the given 3x3 matrix.
 Vector multiply(double f)
          Multiply the vector by a scalar value
 void normalize()
          Normalize the vector so that it has a length of 1
 double scalarProduct(Vector v)
          Return the scalar product (as known as dot product) of this vector and the one given.
 void set(double x, double y, double z)
          Set all the components in one call
 void setX(double a)
          Set X component
 void setY(double a)
          Set Y component
 void setZ(double a)
          set Z component
 Vector subtract(double x, double y, double z)
          Subtract the given vector to this one
 Vector subtract(Vector v)
          Subtract the given vector to this one
 java.lang.String toString()
          Return a String representation of this vector (i.e. "1;2;3")
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Vector

public Vector()
Default constructor. Create a new vector x=0, y=0, z=0


Vector

public Vector(double x,
              double y)
_Create a new vector with given x and y, and z=0


Vector

public Vector(double x,
              double y,
              double z)
Create a new vector with given components

Method Detail

getX

public double getX()
Get X component


getY

public double getY()
Get Y component


getZ

public double getZ()
Get Z component


setX

public void setX(double a)
Set X component


setY

public void setY(double a)
Set Y component


setZ

public void setZ(double a)
set Z component


getLength

public double getLength()
Get the vector's length, as known as norma. Formula : sqrt(x^2 + y^2 + z^2)


normalize

public void normalize()
Normalize the vector so that it has a length of 1


divide

public Vector divide(double f)
Divide the vector by a scalar value


multiply

public Vector multiply(double f)
Multiply the vector by a scalar value


set

public void set(double x,
                double y,
                double z)
Set all the components in one call


add

public Vector add(double x,
                  double y,
                  double z)
Add values to each component


add

public Vector add(Vector v)
Add the vector given to this one


subtract

public Vector subtract(double x,
                       double y,
                       double z)
Subtract the given vector to this one


subtract

public Vector subtract(Vector v)
Subtract the given vector to this one


scalarProduct

public double scalarProduct(Vector v)
Return the scalar product (as known as dot product) of this vector and the one given.


crossProduct

public Vector crossProduct(Vector v)
Return the cross product of this vector and the one given


linearTransform

public Vector linearTransform(Matrix m)
Multiply this vector with the given 3x3 matrix. Operation as known as linear transformation.


toString

public java.lang.String toString()
Return a String representation of this vector (i.e. "1;2;3")

Overrides:
toString in class java.lang.Object

clone

public Vector clone()
Overrides:
clone in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object