gumbo.graphic.math
Class Vector3

java.lang.Object
  |
  +--gumbo.graphic.math.Tuple3
        |
        +--gumbo.graphic.math.Vector3
All Implemented Interfaces:
Graphic, GraphicGeometry, java.io.Serializable, TransformableGraphic
Direct Known Subclasses:
UnitVector3

public class Vector3
extends Tuple3
implements TransformableGraphic

A 3D spatial element representing a vector, which is used exclusively for spatial direction and magnitude. Not affected by translation transforms.

Version:
$Revision: 1.11 $
Author:
Jon Barrilleaux (jonb@jmbaai.com) of JMB and Associates Inc.
See Also:
Serialized Form

Field Summary
static Vector3 NORMALIZED_ZERO_LENGTH
          Result of normalizing a zero length vector.
 
Constructor Summary
Vector3()
           
Vector3(double[] val)
          Creates an instance using a mutator.
Vector3(double x, double y, double z)
          Creates an instance using a mutator.
Vector3(Tuple3 tuple)
          Creates an instance using a mutator.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 Vector3 getVector3()
          Gets a singleton immutable view of this object with the same identity (hashCode(), equals()) as this object.
protected  Vector3 implGetVector3()
          Master whole state accessor.
 double length()
          Returns the length of this vector.
 double lengthSquared()
          Returns the squared length of this vector.
 Vector3 normalize(Vector3 vect)
          Sets this vector to a normalized (length one) version of a vector.
 void transformGraphic(Matrix4 matrix)
          Transforms this graphic's geometry by pre-multiplying it with the specified transform matrix.
 void transformGraphic(SpaceNode from, SpaceNode to)
          Transforms this graphic's geometry from one local reference space to another in a space tree.
 
Methods inherited from class gumbo.graphic.math.Tuple3
abs, add, add, clamp, clamp, clampMax, clampMax, clampMin, clampMin, clear, clearArray, div, div, get, get, getGraphic, getGraphicLocalSpace, getTuple3, getX, getY, getZ, implGetTuple3, implGetTuple3, implGetTuple3, implInitTuple3, implSetTuple3, implSetTuple3, isEqual, isEqual, isGreaterEqual, isInsideEqual, isLessEqual, isOutside, isZero, isZero, max, max, min, min, mult, mult, neg, noise, random, round, set, set, set, set, setArray, setX, setY, setZ, sub, sub, sum, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface gumbo.graphic.space.GraphicGeometry
getGraphicLocalSpace
 
Methods inherited from interface gumbo.graphic.Graphic
getGraphic
 

Field Detail

NORMALIZED_ZERO_LENGTH

public static final Vector3 NORMALIZED_ZERO_LENGTH
Result of normalizing a zero length vector. Immutable.

Constructor Detail

Vector3

public Vector3()

Vector3

public Vector3(double x,
               double y,
               double z)
Creates an instance using a mutator.


Vector3

public Vector3(double[] val)
Creates an instance using a mutator.


Vector3

public Vector3(Tuple3 tuple)
Creates an instance using a mutator.

Method Detail

getVector3

public Vector3 getVector3()
Gets a singleton immutable view of this object with the same identity (hashCode(), equals()) as this object.

Returns:
The view. Never null.

lengthSquared

public double lengthSquared()
Returns the squared length of this vector.


length

public double length()
Returns the length of this vector.


normalize

public Vector3 normalize(Vector3 vect)
Sets this vector to a normalized (length one) version of a vector. If the vector length is zero this vector will be set to NORMALIZED_ZERO_LENGTH.


transformGraphic

public void transformGraphic(SpaceNode from,
                             SpaceNode to)
Description copied from interface: TransformableGraphic
Transforms this graphic's geometry from one local reference space to another in a space tree. Does not access or update this object's intrinsic reference space (which is returned by getGraphicLocalSpace()). If this graphic is spatially constrained some or all of the transformation may be ignored.

Specified by:
transformGraphic in interface TransformableGraphic
Parameters:
from - The current reference space. Never null.
to - The new reference space. Never null.

transformGraphic

public void transformGraphic(Matrix4 matrix)
Description copied from interface: TransformableGraphic
Transforms this graphic's geometry by pre-multiplying it with the specified transform matrix. As such, transformations are cumulative. If this graphic is spatially constrained some or all of the transformation may be ignored.

Specified by:
transformGraphic in interface TransformableGraphic
Parameters:
matrix - Value of the transform matrix. Never null.

implGetVector3

protected Vector3 implGetVector3()
Master whole state accessor.


equals

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