jadex.application.space.envsupport.math
Class Vector3Double

java.lang.Object
  extended by jadex.application.space.envsupport.math.Vector3Double
All Implemented Interfaces:
IVector3, Cloneable

public class Vector3Double
extends Object
implements IVector3, Cloneable

Implementation of a cartesian 3-vector using double components.


Field Summary
static IVector3 ZERO
          Zero vector.
 
Constructor Summary
Vector3Double()
          Creates a new Vector2Double with the value (0,0).
Vector3Double(double scalar)
          Creates a new Vector2 using the scalar to assign the value (scalar,scalar).
Vector3Double(double x, double y, double z)
          Creates a new Vector2 with the given value.
Vector3Double(IVector3 vector)
          Creates a new Vector3 with the same value as the input vector.
 
Method Summary
 IVector3 add(double scalar)
          Adds a scalar to each component of this vector.
 IVector3 add(IVector1 scalar)
          Adds a scalar to each component of this vector.
 IVector3 add(IVector3 vector)
          Adds another vector to this vector, adding individual components.
 IVector3 assign(IVector3 vector)
          Assigns this vector the values of another vector.
 Object clone()
          Generates a deep clone of the vector.
 IVector3 copy()
          Makes a copy of the vector without using the complex clone interface.
 IVector3 divide(IVector3 vector)
          Performs a division on the vector.
 boolean equals(IVector3 vector)
          Compares the vector to another vector.
 boolean equals(Object obj)
          Compares the vector to an object
 IVector2 getDirection()
          Returns the direction (theta) of the vector.
 IVector1 getDistance(IVector3 vector)
          Returns the distance to another vector.
 IVector1 getLength()
          Returns the length (magnitude) of the vector.
static IVector3 getVector3(Double a, Double b, Double c)
          Get a vector for two doubles.
 IVector1 getX()
          Returns the x-component of the vector.
 BigDecimal getXAsBigDecimal()
          Returns the x-component of the vector as BigDecimal.
 double getXAsDouble()
          Returns the x-component of the vector as double.
 float getXAsFloat()
          Returns the x-component of the vector as float.
 int getXAsInteger()
          Returns the x-component of the vector as integer.
 long getXAsLong()
          Returns the x-component of the vector as long.
 IVector1 getY()
          Returns the y-component of the vector.
 BigDecimal getYAsBigDecimal()
          Returns the component of the vector as BigDecima;.
 double getYAsDouble()
          Returns the component of the vector as double.
 float getYAsFloat()
          Returns the component of the vector as float.
 int getYAsInteger()
          Returns the component of the vector as integer.
 long getYAsLong()
          Returns the component of the vector as float.
 IVector1 getZ()
          Returns the z-component of the vector.
 BigDecimal getZAsBigDecimal()
          Returns the component of the vector as BigDecima;.
 double getZAsDouble()
          Returns the component of the vector as double.
 float getZAsFloat()
          Returns the component of the vector as float.
 int getZAsInteger()
          Returns the component of the vector as integer.
 long getZAsLong()
          Returns the component of the vector as float.
 int hashCode()
          Compute the hash code.
 IVector3 mod(IVector3 modulus)
          Applies a modulo vector.
 IVector3 multiply(double scalar)
          Performs a scalar multiplication (scaling) on the vector.
 IVector3 multiply(IVector1 scalar)
          Performs a scalar multiplication (scaling) on the vector.
 IVector3 multiply(IVector3 vector)
          Performs a multiplication on the vector.
 IVector3 negate()
          Negates the vector by negating its components.
 IVector3 negateX()
          Negates the x-component.
 IVector3 negateY()
          Negates the y-component.
 IVector3 negateZ()
          Negates the z-component.
 IVector3 normalize()
          Converts the vector to a unit vector (normalization)
 IVector3 randomX(IVector1 lower, IVector1 upper)
          Sets the x-component to a random value in the interval [lower,upper]
 IVector3 randomY(IVector1 lower, IVector1 upper)
          Sets the y-component to a random value in the interval [lower,upper]
 IVector3 randomZ(IVector1 lower, IVector1 upper)
          Sets the z-component to a random value in the interval [lower,upper]
 void setX(IVector1 x)
           
 void setY(IVector1 y)
           
 void setZ(IVector1 z)
           
 IVector3 subtract(double scalar)
          Subtracts a scalar to each component of this vector.
 IVector3 subtract(IVector1 scalar)
          Subtracts a scalar to each component of this vector.
 IVector3 subtract(IVector3 vector)
          Subtracts another vector to this vector, subtracting individual components.
 String toString()
           
 IVector3 zero()
          Sets all vector components to zero.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ZERO

public static final IVector3 ZERO
Zero vector.

Constructor Detail

Vector3Double

public Vector3Double()
Creates a new Vector2Double with the value (0,0).


Vector3Double

public Vector3Double(IVector3 vector)
Creates a new Vector3 with the same value as the input vector.


Vector3Double

public Vector3Double(double scalar)
Creates a new Vector2 using the scalar to assign the value (scalar,scalar).


Vector3Double

public Vector3Double(double x,
                     double y,
                     double z)
Creates a new Vector2 with the given value.

Method Detail

assign

public IVector3 assign(IVector3 vector)
Assigns this vector the values of another vector.

Specified by:
assign in interface IVector3
Parameters:
vector - the other vector
Returns:
a reference to the called vector (NOT a copy)

add

public IVector3 add(double scalar)
Description copied from interface: IVector3
Adds a scalar to each component of this vector.

Specified by:
add in interface IVector3
Parameters:
scalar - scalar value as double
Returns:
a reference to the called vector (NOT a copy)

add

public IVector3 add(IVector1 scalar)
Description copied from interface: IVector3
Adds a scalar to each component of this vector.

Specified by:
add in interface IVector3
Parameters:
scalar - scalar value
Returns:
a reference to the called vector (NOT a copy)

add

public IVector3 add(IVector3 vector)
Description copied from interface: IVector3
Adds another vector to this vector, adding individual components.

Specified by:
add in interface IVector3
Parameters:
vector - the vector to add to this vector
Returns:
a reference to the called vector (NOT a copy)

subtract

public IVector3 subtract(double scalar)
Description copied from interface: IVector3
Subtracts a scalar to each component of this vector.

Specified by:
subtract in interface IVector3
Parameters:
scalar - scalar value as double
Returns:
a reference to the called vector (NOT a copy)

subtract

public IVector3 subtract(IVector1 scalar)
Description copied from interface: IVector3
Subtracts a scalar to each component of this vector.

Specified by:
subtract in interface IVector3
Parameters:
scalar - scalar value
Returns:
a reference to the called vector (NOT a copy)

subtract

public IVector3 subtract(IVector3 vector)
Description copied from interface: IVector3
Subtracts another vector to this vector, subtracting individual components.

Specified by:
subtract in interface IVector3
Parameters:
vector - the vector to subtract from this vector
Returns:
a reference to the called vector (NOT a copy)

mod

public IVector3 mod(IVector3 modulus)
Description copied from interface: IVector3
Applies a modulo vector. The modulus will be added first so that values in the interval (-modulus, 0) will wrap over into the positive range.

Specified by:
mod in interface IVector3
Parameters:
modulus - modulus
Returns:
a reference to the called vector (NOT a copy)

multiply

public IVector3 multiply(double scalar)
Description copied from interface: IVector3
Performs a scalar multiplication (scaling) on the vector.

Specified by:
multiply in interface IVector3
Parameters:
scalar - the scale factor double
Returns:
a reference to the called vector (NOT a copy)

multiply

public IVector3 multiply(IVector1 scalar)
Description copied from interface: IVector3
Performs a scalar multiplication (scaling) on the vector.

Specified by:
multiply in interface IVector3
Parameters:
scalar - the scale factor
Returns:
a reference to the called vector (NOT a copy)

multiply

public IVector3 multiply(IVector3 vector)
Description copied from interface: IVector3
Performs a multiplication on the vector.

Specified by:
multiply in interface IVector3
Parameters:
vector - vector
Returns:
a reference to the called vector (NOT a copy)

divide

public IVector3 divide(IVector3 vector)
Performs a division on the vector.

Specified by:
divide in interface IVector3
Parameters:
vector - vector
Returns:
a reference to the called vector (NOT a copy)

zero

public IVector3 zero()
Description copied from interface: IVector3
Sets all vector components to zero.

Specified by:
zero in interface IVector3
Returns:
a reference to the called vector (NOT a copy)

negateX

public IVector3 negateX()
Description copied from interface: IVector3
Negates the x-component.

Specified by:
negateX in interface IVector3
Returns:
a reference to the called vector (NOT a copy)

negateY

public IVector3 negateY()
Description copied from interface: IVector3
Negates the y-component.

Specified by:
negateY in interface IVector3
Returns:
a reference to the called vector (NOT a copy)

negateZ

public IVector3 negateZ()
Description copied from interface: IVector3
Negates the z-component.

Specified by:
negateZ in interface IVector3
Returns:
a reference to the called vector (NOT a copy)

negate

public IVector3 negate()
Description copied from interface: IVector3
Negates the vector by negating its components.

Specified by:
negate in interface IVector3
Returns:
a reference to the called vector (NOT a copy)

randomX

public IVector3 randomX(IVector1 lower,
                        IVector1 upper)
Description copied from interface: IVector3
Sets the x-component to a random value in the interval [lower,upper]

Specified by:
randomX in interface IVector3
Returns:
a reference to the called vector (NOT a copy)

randomY

public IVector3 randomY(IVector1 lower,
                        IVector1 upper)
Description copied from interface: IVector3
Sets the y-component to a random value in the interval [lower,upper]

Specified by:
randomY in interface IVector3
Returns:
a reference to the called vector (NOT a copy)

randomZ

public IVector3 randomZ(IVector1 lower,
                        IVector1 upper)
Description copied from interface: IVector3
Sets the z-component to a random value in the interval [lower,upper]

Specified by:
randomZ in interface IVector3
Returns:
a reference to the called vector (NOT a copy)

normalize

public IVector3 normalize()
Description copied from interface: IVector3
Converts the vector to a unit vector (normalization)

Specified by:
normalize in interface IVector3

getLength

public IVector1 getLength()
Description copied from interface: IVector3
Returns the length (magnitude) of the vector.

Specified by:
getLength in interface IVector3
Returns:
vector length

getDirection

public IVector2 getDirection()
Description copied from interface: IVector3
Returns the direction (theta) of the vector.

Specified by:
getDirection in interface IVector3
Returns:
vector direction

getDistance

public IVector1 getDistance(IVector3 vector)
Description copied from interface: IVector3
Returns the distance to another vector.

Specified by:
getDistance in interface IVector3
Parameters:
vector - other vector
Returns:
distance

getX

public IVector1 getX()
Description copied from interface: IVector3
Returns the x-component of the vector.

Specified by:
getX in interface IVector3
Returns:
x-component

getY

public IVector1 getY()
Description copied from interface: IVector3
Returns the y-component of the vector.

Specified by:
getY in interface IVector3
Returns:
y-component

getZ

public IVector1 getZ()
Description copied from interface: IVector3
Returns the z-component of the vector.

Specified by:
getZ in interface IVector3
Returns:
z-component

setX

public void setX(IVector1 x)

setY

public void setY(IVector1 y)

setZ

public void setZ(IVector1 z)

getXAsInteger

public int getXAsInteger()
Returns the x-component of the vector as integer.

Specified by:
getXAsInteger in interface IVector3
Returns:
x-component as integer

getYAsInteger

public int getYAsInteger()
Returns the component of the vector as integer.

Specified by:
getYAsInteger in interface IVector3
Returns:
y-component as float

getZAsInteger

public int getZAsInteger()
Returns the component of the vector as integer.

Specified by:
getZAsInteger in interface IVector3
Returns:
y-component as float

getXAsLong

public long getXAsLong()
Returns the x-component of the vector as long.

Specified by:
getXAsLong in interface IVector3
Returns:
x-component as long

getYAsLong

public long getYAsLong()
Returns the component of the vector as float.

Specified by:
getYAsLong in interface IVector3
Returns:
y-component as float

getZAsLong

public long getZAsLong()
Returns the component of the vector as float.

Specified by:
getZAsLong in interface IVector3
Returns:
y-component as float

getXAsFloat

public float getXAsFloat()
Description copied from interface: IVector3
Returns the x-component of the vector as float.

Specified by:
getXAsFloat in interface IVector3
Returns:
x-component as float

getYAsFloat

public float getYAsFloat()
Description copied from interface: IVector3
Returns the component of the vector as float.

Specified by:
getYAsFloat in interface IVector3
Returns:
y-component as float

getZAsFloat

public float getZAsFloat()
Description copied from interface: IVector3
Returns the component of the vector as float.

Specified by:
getZAsFloat in interface IVector3
Returns:
z-component as float

getXAsDouble

public double getXAsDouble()
Description copied from interface: IVector3
Returns the x-component of the vector as double.

Specified by:
getXAsDouble in interface IVector3
Returns:
x-component as double

getYAsDouble

public double getYAsDouble()
Description copied from interface: IVector3
Returns the component of the vector as double.

Specified by:
getYAsDouble in interface IVector3
Returns:
y-component as double

getZAsDouble

public double getZAsDouble()
Description copied from interface: IVector3
Returns the component of the vector as double.

Specified by:
getZAsDouble in interface IVector3
Returns:
z-component as double

getXAsBigDecimal

public BigDecimal getXAsBigDecimal()
Description copied from interface: IVector3
Returns the x-component of the vector as BigDecimal.

Specified by:
getXAsBigDecimal in interface IVector3
Returns:
x-component as BigDecimal

getYAsBigDecimal

public BigDecimal getYAsBigDecimal()
Description copied from interface: IVector3
Returns the component of the vector as BigDecima;.

Specified by:
getYAsBigDecimal in interface IVector3
Returns:
y-component as BigDecimal

getZAsBigDecimal

public BigDecimal getZAsBigDecimal()
Description copied from interface: IVector3
Returns the component of the vector as BigDecima;.

Specified by:
getZAsBigDecimal in interface IVector3
Returns:
y-component as BigDecimal

copy

public IVector3 copy()
Description copied from interface: IVector3
Makes a copy of the vector without using the complex clone interface.

Specified by:
copy in interface IVector3
Returns:
copy of the vector

clone

public Object clone()
             throws CloneNotSupportedException
Description copied from interface: IVector3
Generates a deep clone of the vector.

Specified by:
clone in interface IVector3
Overrides:
clone in class Object
Returns:
clone of this vector
Throws:
CloneNotSupportedException

equals

public boolean equals(Object obj)
Description copied from interface: IVector3
Compares the vector to an object

Specified by:
equals in interface IVector3
Overrides:
equals in class Object
Parameters:
obj - the object
Returns:
always returns false unless the object is an IVector3, in which case it is equivalent to equals(IVector vector)

equals

public boolean equals(IVector3 vector)
Description copied from interface: IVector3
Compares the vector to another vector. The vectors are equal if the components are equal.

Specified by:
equals in interface IVector3
Parameters:
vector - the other vector
Returns:
true if the vectors are equal

hashCode

public int hashCode()
Compute the hash code.

Overrides:
hashCode in class Object
Returns:
The hash code.

toString

public String toString()
Overrides:
toString in class Object

getVector3

public static IVector3 getVector3(Double a,
                                  Double b,
                                  Double c)
Get a vector for two doubles.

Parameters:
a - The first value.
b - The second value.
Returns:
The vector (null if at least one of args is null).


Copyright © 2010. All Rights Reserved.