org.vizzini.game
Class VectorPosition

java.lang.Object
  extended by org.vizzini.game.VectorPosition
All Implemented Interfaces:
Serializable, Cloneable, IPosition

public class VectorPosition
extends Object
implements IPosition

Provides a vector implementation of IPosition.

Since:
v0.3
Version:
v0.3
Author:
Jeffrey M. Thompson
See Also:
Serialized Form

Field Summary
static VectorPosition X_AXIS
          X axis.
static VectorPosition Y_AXIS
          Y axis.
static VectorPosition Z_AXIS
          Z axis.
static VectorPosition ZERO
          Zero vector.
 
Constructor Summary
VectorPosition(double x, double y, double z)
          Construct this object with the given parameters.
VectorPosition(Vector vector)
          Construct this object with the given parameters.
 
Method Summary
 IPosition add(IPosition position)
          Add the given position to this.
 Object clone()
          Return a clone of this instance.
 boolean equals(Object object)
          Return true if this vector equals the given object.
 boolean equals(Object object, double delta)
          Return true if this vector equals the given object.
 double getMagnitude()
          Return the magnitude of this vector.
 Vector getVector()
           
 double getX()
          Return the X component.
 double getY()
          Return the Y component.
 double getZ()
          Return the Z component.
 int hashCode()
          Return a hash code.
 VectorPosition multiply(double m)
          Return a new vector multiplied by the given scalar.
 IPosition subtract(IPosition position)
          Subtract the given position from this.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ZERO

public static final VectorPosition ZERO
Zero vector.


X_AXIS

public static final VectorPosition X_AXIS
X axis.


Y_AXIS

public static final VectorPosition Y_AXIS
Y axis.


Z_AXIS

public static final VectorPosition Z_AXIS
Z axis.

Constructor Detail

VectorPosition

public VectorPosition(Vector vector)
Construct this object with the given parameters.

Since:
v0.3

VectorPosition

public VectorPosition(double x,
                      double y,
                      double z)
Construct this object with the given parameters.

Since:
v0.3
Method Detail

add

public IPosition add(IPosition position)
Add the given position to this.

Specified by:
add in interface IPosition
Parameters:
position - The position to add.
Returns:
A new position object which is this plus the given position.
Since:
v0.3

clone

public Object clone()
Return a clone of this instance.

Specified by:
clone in interface IPosition
Overrides:
clone in class Object
Since:
v0.3

equals

public boolean equals(Object object)
Return true if this vector equals the given object.

Overrides:
equals in class Object
Parameters:
object - Object to compare.
Since:
v0.3

equals

public boolean equals(Object object,
                      double delta)
Return true if this vector equals the given object.

Parameters:
object - Object to compare.
delta - Allowable difference in coordinates.
Since:
v0.3

getMagnitude

public double getMagnitude()
Return the magnitude of this vector.

Since:
v0.3

getVector

public Vector getVector()
Returns:
Return vector.
Since:
v0.3

getX

public double getX()
Return the X component.

Since:
v0.3

getY

public double getY()
Return the Y component.

Since:
v0.3

getZ

public double getZ()
Return the Z component.

Since:
v0.3

hashCode

public int hashCode()
Return a hash code.

Overrides:
hashCode in class Object
Since:
v0.3

multiply

public VectorPosition multiply(double m)
Return a new vector multiplied by the given scalar.

Since:
v0.3

subtract

public IPosition subtract(IPosition position)
Subtract the given position from this.

Specified by:
subtract in interface IPosition
Parameters:
position - The position to subtract.
Returns:
A new position object which is this minus the given position.
Since:
v0.3


Copyright 2007 Vizzini.org. All Rights Reserved. 2007.12.25.03.00.02