com.motorola.iden.micro3d
Class Vector3D

java.lang.Object
  |
  +--com.motorola.iden.micro3d.Vector3D

public class Vector3D
extends java.lang.Object

The Vector3D class is a container for a 3D integer vector. An object of type Vector3D contains three integer values that specify the X, Y, and Z-coordinates. For each of the coordinates the valid range is -32768 to 32767. Values that are smaller than -32768 will be automatically adjusted to -32768 (Vector3D.MIN_VALUE). Similarly, values greater than 32767 will be automatically adjusted to 32767 (Vector3D.MAX_VALUE).


MOTOROLA and the Stylized M Logo are registered trademarks of Motorola, Inc. Reg. U.S. Pat. & Tm. Off.
© COPYRIGHT 2003-2004 MOTOROLA, Inc. All Rights Reserved.


Field Summary
static int MAX_VALUE
          The maximum value for x, y, and z that can be stored in the Vector3D.
static int MIN_VALUE
          The minimum value for x, y, and z that can be stored in the Vector3D.
 
Constructor Summary
Vector3D()
          Creates a Vector3D object with x, y, and z values set to 0.
Vector3D(int x, int y, int z)
          Creates a Vector3D object with the specified x, y, and z values.
 
Method Summary
 int getX()
          Returns the x value of this Vector3D object.
 int getY()
          Returns the y value of this Vector3D object.
 int getZ()
          Returns the z value of this Vector3D object.
 int innerProduct(Vector3D multiplier)
          Returns the inner, or dot, product of this Vector3D with the specified Vector3D.
 void normalize()
          Normalizes this Vector3D object.
static Vector3D normalize(Vector3D vector)
          Normalizes the specified Vector3D object.
 void outerProduct(Vector3D multiplier)
          Calculates the outer, or cross, product of this Vector3D with the specified Vector3D.
static Vector3D outerProduct(Vector3D multiplicand, Vector3D multiplier)
          Calculates the outer, or cross, product of the specified Vector3D objects.
 void set(int x, int y, int z)
          Sets the x, y, and z values of this Vector3D object.
 void setX(int x)
          Sets the x value of this Vector3D object.
 void setY(int y)
          Sets the y value of this Vector3D object.
 void setZ(int z)
          Sets the z value of this Vector3D object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MIN_VALUE

public static final int MIN_VALUE
The minimum value for x, y, and z that can be stored in the Vector3D. The minumum value is -32768.

MAX_VALUE

public static final int MAX_VALUE
The maximum value for x, y, and z that can be stored in the Vector3D. The maximum value is 32767.
Constructor Detail

Vector3D

public Vector3D()
Creates a Vector3D object with x, y, and z values set to 0.

Vector3D

public Vector3D(int x,
                int y,
                int z)
Creates a Vector3D object with the specified x, y, and z values.

Values within the vector must be within the range -32768 and 32767. If any of the specified values are less than -32768 they will be automatically adjusted to -32768 (Vector3D.MIN_VALUE). Similarly, any values greater than 32767 will be automatically adjusted to 32767 ( Vector3D.MAX_VALUE).

Parameters:
x - the value for the x component of this vector.
y - the value for the y component of this vector.
z - the value for the z component of this vector.
See Also:
MIN_VALUE, MAX_VALUE
Method Detail

getX

public int getX()
Returns the x value of this Vector3D object.

Returns:
the value for the x component of this vector.

setX

public void setX(int x)
Sets the x value of this Vector3D object.

The specified value must be within the range -32768 and 32767. If any of the specified values are less than -32768 they will be automatically adjusted to -32768 (Vector3D.MIN_VALUE). Similarly, any values greater than 32767 will be automatically adjusted to 32767 ( Vector3D.MAX_VALUE).

Parameters:
x - the value for the x component of this vector.
See Also:
MIN_VALUE, MAX_VALUE

getY

public int getY()
Returns the y value of this Vector3D object.

Returns:
the value for the y component of this vector.

setY

public void setY(int y)
Sets the y value of this Vector3D object.

The specified value must be within the range -32768 and 32767. If any of the specified values are less than -32768 they will be automatically adjusted to -32768 (Vector3D.MIN_VALUE). Similarly, any values greater than 32767 will be automatically adjusted to 32767 ( Vector3D.MAX_VALUE).

Parameters:
y - the value for the y component of this vector.
See Also:
MIN_VALUE, MAX_VALUE

getZ

public int getZ()
Returns the z value of this Vector3D object.

Returns:
the value for the z component of this vector.

setZ

public void setZ(int z)
Sets the z value of this Vector3D object.

The specified value must be within the range -32768 and 32767. If any of the specified values are less than -32768 they will be automatically adjusted to -32768 (Vector3D.MIN_VALUE). Similarly, any values greater than 32767 will be automatically adjusted to 32767 ( Vector3D.MAX_VALUE).

Parameters:
z - the value for the z component of this vector.
See Also:
MIN_VALUE, MAX_VALUE

set

public void set(int x,
                int y,
                int z)
Sets the x, y, and z values of this Vector3D object.

The specified values must be within the range -32768 and 32767. If any of the specified values are less than -32768 they will be automatically adjusted to -32768 (Vector3D.MIN_VALUE). Similarly, any values greater than 32767 will be automatically adjusted to 32767 ( Vector3D.MAX_VALUE).

Parameters:
x - the value for the x component of this vector.
y - the value for the y component of this vector.
z - the value for the z component of this vector.
See Also:
MIN_VALUE, MAX_VALUE

normalize

public void normalize()
Normalizes this Vector3D object. This method does not do anything if this vector is a zero vector. A zero vector is a vector of length 0, and thus has all components equal to zero.


normalize

public static Vector3D normalize(Vector3D vector)
                          throws java.lang.NullPointerException,
                                 java.lang.IllegalArgumentException
Normalizes the specified Vector3D object. This method returns a new Vector3D object which contains the normalized vector. If a zero vector is specified, this method throws IllegalArgumentException. A zero vector is a vector of length 0, and thus has all components equal to zero.

Returns:
a new Vector3D containing the normalized Vector3D specified.
Throws:
java.lang.NullPointerException - if the specified vector is null.
java.lang.IllegalArgumentException - if the specified vector is a zero vector.

outerProduct

public void outerProduct(Vector3D multiplier)
                  throws java.lang.NullPointerException
Calculates the outer, or cross, product of this Vector3D with the specified Vector3D. The result is stored in the object the method was called on.

Parameters:
multiplier - the Vector3D serving as the multiplier.
Throws:
java.lang.NullPointerException - if the specified multiplier is null.

outerProduct

public static Vector3D outerProduct(Vector3D multiplicand,
                                    Vector3D multiplier)
                             throws java.lang.NullPointerException
Calculates the outer, or cross, product of the specified Vector3D objects. The result is returned as a new Vector3D object.

Parameters:
multiplicand - the Vector3D serving as the multiplicand.
multiplier - the Vector3D serving as the multiplier.
Returns:
a new Vector3D containing the outer product.
Throws:
java.lang.NullPointerException - if either of the specified parameters are null.

innerProduct

public int innerProduct(Vector3D multiplier)
                 throws java.lang.NullPointerException
Returns the inner, or dot, product of this Vector3D with the specified Vector3D.

Parameters:
multiplier - the Vector3D serving as the multiplier.
Returns:
the calculated inner product.
Throws:
java.lang.NullPointerException - if the multiplier is null.