com.mascotcapsule.micro3d.v3
Class Vector3D

java.lang.Object
  extended bycom.mascotcapsule.micro3d.v3.Vector3D

public class Vector3D
extends java.lang.Object

This class handles 3D vectors. The components of the vectors are fixed-point decimal numbers in which 1.0 is equivalent to 4096 units. The vector length is 4096 after normalization using the unit() method. When performing the various calculations, the results when values exceed the range of int and overflow are not defined.


Field Summary
 int x
          x component of the vector
 int y
          y component of the vector
 int z
          z component if the vector
 
Constructor Summary
Vector3D()
          Creates a vector object.
Vector3D(int x, int y, int z)
          Specifies the values of all elements and creates a vector object.
Vector3D(Vector3D v)
          Creates a vector object.
 
Method Summary
 int getX()
          Gets the value of the x component settings.
 int getY()
          Gets the value of the y component settings.
 int getZ()
          Gets the value of the z component settings.
 int innerProduct(Vector3D v)
          Calculates the inner product between this vector and the specified vector.
static int innerProduct(Vector3D v1, Vector3D v2)
          Calculates the inner products of the specified 2 vectors.
 void outerProduct(Vector3D v)
          Calculates the outer product between this vector and the specified vector.
static Vector3D outerProduct(Vector3D v1, Vector3D v2)
          Calculates the outer products of the 2 specified vectors.
 void set(int x, int y, int z)
          Enters values for all elements.
 void set(Vector3D v)
          Copies the content of other vector objects.
 void setX(int x)
          Enters the x component setting.
 void setY(int y)
          Enters the y component setting.
 void setZ(int z)
          Enters the z component setting.
 void unit()
          Normalizes (make a unit quantity) this vector.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

x

public int x
x component of the vector


y

public int y
y component of the vector


z

public int z
z component if the vector

Constructor Detail

Vector3D

public Vector3D()
Creates a vector object. All components are 0.


Vector3D

public Vector3D(Vector3D v)
Creates a vector object. Copies the content of other objects.

Parameters:
v - Other vector objects
Throws:
java.lang.NullPointerException - Whe argument is null.

Vector3D

public Vector3D(int x,
                int y,
                int z)
Specifies the values of all elements and creates a vector object.

Parameters:
x - Value of x component
y - Value of y component
z - Value of z component
Method Detail

unit

public final void unit()
Normalizes (make a unit quantity) this vector. The length of the unit quantity vector is 4096. Nothing happens when the vector length is 0.


getX

public final int getX()
Gets the value of the x component settings.

Returns:
Value of x component

getY

public final int getY()
Gets the value of the y component settings.

Returns:
Value of y component

getZ

public final int getZ()
Gets the value of the z component settings.

Returns:
Value of z component

setX

public final void setX(int x)
Enters the x component setting.

Parameters:
x - Value of x component

setY

public final void setY(int y)
Enters the y component setting.

Parameters:
y - Value of y component

setZ

public final void setZ(int z)
Enters the z component setting.

Parameters:
z - Value of z component

set

public final void set(Vector3D v)
Copies the content of other vector objects.

Parameters:
v - Other vector objects
Throws:
java.lang.NullPointerException - When the argument is null.

set

public final void set(int x,
                      int y,
                      int z)
Enters values for all elements.

Parameters:
x - Value of x component
y - Value of y component
z - Value of z component

innerProduct

public final int innerProduct(Vector3D v)
Calculates the inner product between this vector and the specified vector. The innerProduct(this, v) call and result are the same.

Parameters:
v - Vector object
Returns:
Value of scalar product
Throws:
java.lang.NullPointerException - When argument v is null.

outerProduct

public final void outerProduct(Vector3D v)
Calculates the outer product between this vector and the specified vector. The outerProduct(this, v) call and result are the same. The result will be stored in the vector itself.

Parameters:
v - Vector object
Throws:
java.lang.NullPointerException - When argument v is null.

innerProduct

public static final int innerProduct(Vector3D v1,
                                     Vector3D v2)
Calculates the inner products of the specified 2 vectors.

Parameters:
v1 - Vector object 1
v2 - Vector object 2
Returns:
Value of inner product
Throws:
java.lang.NullPointerException - When argument v1 or v2 is null.

outerProduct

public static final Vector3D outerProduct(Vector3D v1,
                                          Vector3D v2)
Calculates the outer products of the 2 specified vectors.

Parameters:
v1 - Vector object 1
v2 - Vector object 2
Returns:
Outer products (v1 x v2)
Throws:
java.lang.NullPointerException - When argument v1 or v2 is null.