Facemorph
Class Vector3

java.lang.Object
  extended by Facemorph.Vector3
All Implemented Interfaces:
java.io.Serializable

public class Vector3
extends java.lang.Object
implements java.io.Serializable

Simple 3D vector class

See Also:
Serialized Form

Field Summary
 float x
          x coord
 float y
          y coord
 float z
          z coord
 
Constructor Summary
Vector3()
          Construct a zero Vector3D
Vector3(float a, float b, float c)
          Construct a full Vector 3D
Vector3(Vector3 p)
          Construct a zero Vector3D
 
Method Summary
 void add(Vector3 p)
           
 Vector3 crossProduct(Vector3 v1)
          Returns the cross (vector) product of this vector with v1
 float distance(Vector3 p)
           
 float distanceSquared(Vector3 p)
           
 float magnitude()
          returns the magnitude of this vector
 boolean normalise()
          Normalises this vector to have magnitude 1
 float scalarProduct(Vector3 v1)
          returns the scalar (dot) product of this vector with v1
 void scale(float s)
           
 void set(float i, float j, float k)
          Set the value of this Vector3D
 void sub(Vector3 p)
           
 Vector3 transform(Matrix3 mat)
          Transform this vector using the matrix given
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

x

public float x
x coord


y

public float y
y coord


z

public float z
z coord

Constructor Detail

Vector3

public Vector3()
Construct a zero Vector3D


Vector3

public Vector3(Vector3 p)
Construct a zero Vector3D


Vector3

public Vector3(float a,
               float b,
               float c)
Construct a full Vector 3D

Parameters:
a - x coord
b - y coord
c - z coord
Method Detail

set

public void set(float i,
                float j,
                float k)
Set the value of this Vector3D

Parameters:
i - the new x value
j - the new y value
k - the new z value

transform

public Vector3 transform(Matrix3 mat)
Transform this vector using the matrix given

Parameters:
mat - The matrix to transform this with
Returns:
The transformed vector

add

public void add(Vector3 p)

scale

public void scale(float s)

distanceSquared

public float distanceSquared(Vector3 p)

distance

public float distance(Vector3 p)

sub

public void sub(Vector3 p)

crossProduct

public Vector3 crossProduct(Vector3 v1)
Returns the cross (vector) product of this vector with v1

Parameters:
v1 - The vector to cross with
Returns:
The result of the cross product operation i.e. this x v1

normalise

public boolean normalise()
Normalises this vector to have magnitude 1

Returns:
true if the vector was sucessfully normalised, false otherwise

magnitude

public float magnitude()
returns the magnitude of this vector

Returns:
The length of this vector

scalarProduct

public float scalarProduct(Vector3 v1)
returns the scalar (dot) product of this vector with v1

Parameters:
v1 - The vector to dot with
Returns:
The result of this.v1