jautil.geometry
Class Vector3f

java.lang.Object
  extended by jautil.geometry.Vector3f

public class Vector3f
extends java.lang.Object

A 3-dimensional cartesian vector with float coordinates, including a variety of standard operations.


Constructor Summary
Vector3f()
          Constructs this Vector3f with zeros.
Vector3f(float[] ff)
          Constructs this Vector3f from the given array.
Vector3f(float a, float b, float c)
          Constructs this Vector3f from the given arguments.
Vector3f(JAInputStream jins)
          Constructs this Vector3f from the given stream.
Vector3f(Vector3f v)
          Constructs this Vector3f from the given arguments.
 
Method Summary
 Vector3f crossProd(Vector3f v)
          Returns the vector product of this Vector3f with the given one.
 Vector3f divScalar(float f)
          Returns a new Vector3f obtained by dividing this one by the given scalar.
 Vector3f divScalarEq(float f)
          Returns this Vector3f after dividing it by a given scalar.
 float dotProd(Vector3f v)
          Returns the inner product of this Vector3f with the given one.
 void incrX(float ix)
          Increments the x-component of this vector.
 void incrY(float iy)
          Increments the y-component of this vector.
 void incrZ(float iz)
          Increments the z-component of this vector.
 float length()
          Returns the length of this Vector3f.
 Vector3f minus(Vector3f v)
          Returns a new Vector3f obtained by subtracting the given one from this one.
 Vector3f minusEq(Vector3f v)
          Subtracts the given Vector3f from this one (and returns this one).
 Vector3f multScalar(float f)
          Returns a new Vector3f obtained by multiplying this one by the given scalar.
 Vector3f multScalarEq(float f)
          Returns this Vector3f after multiplying it by a given scalar.
 Vector3f negate()
          Returns a new Vector3f obtained by negating this one.
 Vector3f negateEq()
          Returns this Vector3f after negating it.
 Vector3f plus(float[] vf)
          Returns a new Vector3f obtained by adding the given value array to this vector.
 Vector3f plus(Vector3f v)
          Returns a new Vector3f obtained by adding the given one to this one.
 Vector3f plusEq(float[] vf)
          Adds the vector defined by the given values to this one (and returns this one).
 Vector3f plusEq(float xx, float yy, float zz)
          Adds the vector defined by the given values to this one (and returns this one).
 Vector3f plusEq(Vector3f v)
          Adds the given Vector3f to this one (and returns this one).
 float projectionOn(Vector3f v)
          Returns the projection of this Vector3f on the given Vector3f, v.
 void save(JAOutputStream jouts)
          Writes this Vector3f to the given stream.
 float select(int i)
          Returns the value of the field selected by i (zero-based).
 void set(float[] v)
          Sets this Vector3f's state from the given arguments.
 void set(float[] v, int i)
          Sets this Vector3f's state from the given array, starting at the given position.
 void set(float a, float b, float c)
          Sets this Vector3f's state from the given arguments.
 void set(Vector3f v)
          Sets this Vector3f's state from the given one.
 void setX(float x)
          Sets the x-component of this vector.
 void setY(float y)
          Sets the y-component of this vector.
 void setZ(float z)
          Sets the z-component of this vector.
 void setZero()
          Sets this Vector3f to zero.
 float squaredLength()
          Returns the square of the length of this Vector3f.
 float[] toFloats()
          Returns a new array of floats containing the (x,y,z) component values for this Vector.
 void toFloats(float[] ff)
          Copy the components of this Vector3f to the given array.
 Vector3f unitCrossProd(Vector3f v)
          Returns the vector product of this Vector3f with the given one, scaled to unit length.
 float unitize()
          Scale this Vector3f to be a unit vector, with a standard tolerance value (1.0e-06).
 float unitize(float tolerance)
          Scales this Vector3f to be a unit vector, provided its length exceeds the given tolerance, and returns the length.
 float x()
          Returns the x-component of this vector.
 float y()
          Returns the y-component of this vector.
 float z()
          Returns the z-component of this vector.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Vector3f

public Vector3f()
Constructs this Vector3f with zeros.


Vector3f

public Vector3f(float a,
                float b,
                float c)
Constructs this Vector3f from the given arguments.


Vector3f

public Vector3f(float[] ff)
Constructs this Vector3f from the given array.


Vector3f

public Vector3f(Vector3f v)
Constructs this Vector3f from the given arguments.


Vector3f

public Vector3f(JAInputStream jins)
         throws java.io.IOException
Constructs this Vector3f from the given stream.

Throws:
java.io.IOException
Method Detail

toFloats

public float[] toFloats()
Returns a new array of floats containing the (x,y,z) component values for this Vector.


toFloats

public void toFloats(float[] ff)
Copy the components of this Vector3f to the given array.


setZero

public void setZero()
Sets this Vector3f to zero.


set

public void set(float a,
                float b,
                float c)
Sets this Vector3f's state from the given arguments.


x

public float x()
Returns the x-component of this vector.


y

public float y()
Returns the y-component of this vector.


z

public float z()
Returns the z-component of this vector.


setX

public void setX(float x)
Sets the x-component of this vector.


setY

public void setY(float y)
Sets the y-component of this vector.


setZ

public void setZ(float z)
Sets the z-component of this vector.


incrX

public void incrX(float ix)
Increments the x-component of this vector.


incrY

public void incrY(float iy)
Increments the y-component of this vector.


incrZ

public void incrZ(float iz)
Increments the z-component of this vector.


set

public void set(Vector3f v)
Sets this Vector3f's state from the given one.


set

public void set(float[] v)
Sets this Vector3f's state from the given arguments.


set

public void set(float[] v,
                int i)
Sets this Vector3f's state from the given array, starting at the given position.


save

public void save(JAOutputStream jouts)
          throws java.io.IOException
Writes this Vector3f to the given stream.

Throws:
java.io.IOException

select

public float select(int i)
Returns the value of the field selected by i (zero-based).


plus

public Vector3f plus(Vector3f v)
Returns a new Vector3f obtained by adding the given one to this one.


plus

public Vector3f plus(float[] vf)
Returns a new Vector3f obtained by adding the given value array to this vector.


minus

public Vector3f minus(Vector3f v)
Returns a new Vector3f obtained by subtracting the given one from this one.


multScalar

public Vector3f multScalar(float f)
Returns a new Vector3f obtained by multiplying this one by the given scalar.


divScalar

public Vector3f divScalar(float f)
Returns a new Vector3f obtained by dividing this one by the given scalar.


negate

public Vector3f negate()
Returns a new Vector3f obtained by negating this one.


plusEq

public Vector3f plusEq(Vector3f v)
Adds the given Vector3f to this one (and returns this one).


plusEq

public Vector3f plusEq(float[] vf)
Adds the vector defined by the given values to this one (and returns this one).


plusEq

public Vector3f plusEq(float xx,
                       float yy,
                       float zz)
Adds the vector defined by the given values to this one (and returns this one).


minusEq

public Vector3f minusEq(Vector3f v)
Subtracts the given Vector3f from this one (and returns this one).


multScalarEq

public Vector3f multScalarEq(float f)
Returns this Vector3f after multiplying it by a given scalar.


divScalarEq

public Vector3f divScalarEq(float f)
Returns this Vector3f after dividing it by a given scalar.


negateEq

public Vector3f negateEq()
Returns this Vector3f after negating it.


unitize

public float unitize(float tolerance)
Scales this Vector3f to be a unit vector, provided its length exceeds the given tolerance, and returns the length. If the tolerance is not exceeded, do nothing and return a length value of 0.


unitize

public float unitize()
Scale this Vector3f to be a unit vector, with a standard tolerance value (1.0e-06).


squaredLength

public float squaredLength()
Returns the square of the length of this Vector3f.


length

public float length()
Returns the length of this Vector3f.


dotProd

public float dotProd(Vector3f v)
Returns the inner product of this Vector3f with the given one.


crossProd

public Vector3f crossProd(Vector3f v)
Returns the vector product of this Vector3f with the given one.


unitCrossProd

public Vector3f unitCrossProd(Vector3f v)
Returns the vector product of this Vector3f with the given one, scaled to unit length.


projectionOn

public float projectionOn(Vector3f v)
Returns the projection of this Vector3f on the given Vector3f, v.