Class Vector3D

java.lang.Object
  |
  +--Jama.Matrix
        |
        +--Vector3D

public class Vector3D
extends Jama.Matrix

Represents a line vector in 3D space. The vector is in the homogeneous coordinate system (x,y,z,1)

See Also:
Serialized Form

Fields inherited from class Jama.Matrix
A, m, n
 
Constructor Summary
Vector3D()
          Constructs a zero vector.
Vector3D(double x, double y, double z)
          Constructs a 3D vector.
Vector3D(double x, double y, double z, boolean normalized)
          Constructs a 3D vector, optionally normalized.
Vector3D(Jama.Matrix m)
          Constructs a vector from a matrix.
Vector3D(Point3D pt)
          Constructs a vector by taking the (x,y,z) elements of the point.
 
Method Summary
static Vector3D add(Vector3D A, Vector3D B)
          adds two vectors
static Vector3D add(Vector3D A, Vector3D B, boolean normalized)
          adds two vectors
 Vector3D cross(Vector3D B)
          Returns the cross product A x B .
 double dot(Vector3D B)
          returns the dot vector A.B .
 double getH()
          Returns the homogeneous (H) factor.
 double getX()
          returns the first (X) element of the vector.
 double getY()
          returns the second (Y) element of the vector.
 double getZ()
          returns the third (Z) element of the vector.
 double norm()
          Returns the norm (vector length) of this vector.
 void normalize()
          Normalizes this vector.
 Vector3D normalized()
          Returns the normalized form of this vector.
static Vector3D normalized(double x, double y, double z)
          Returns a normalized vector with the specified (x,y,z) values.
 void set(Jama.Matrix m)
          Sets the vectors x,y,z,h values from the matrix.
 void set(Point3D pt)
          Sets the vectors x,y,z values from the point.
 void setH(double v)
          Sets the homogeneous factor.
 void setX(double v)
          Sets the first (X) element of the vector.
 void setY(double v)
          Sets the second (Y) element of the vector.
 void setZ(double v)
          Sets the third (Z) element of the vector.
static Vector3D subtract(Vector3D A, Vector3D B)
          Subtracts two vectors
 Jama.Matrix times(double s)
          Multiplies the vector by a scalar.
 String toString()
          Returns the string representation of the vector.
 void unhomogenize()
          Divides the x,y,z factor by h if necessary.
 
Methods inherited from class Jama.Matrix
arrayLeftDivide, arrayLeftDivideEquals, arrayRightDivide, arrayRightDivideEquals, arrayTimes, arrayTimesEquals, checkMatrixDimensions, chol, clone, cond, constructWithCopy, copy, det, eig, get, getArray, getArrayCopy, getColumnDimension, getColumnPackedCopy, getMatrix, getMatrix, getMatrix, getMatrix, getRowDimension, getRowPackedCopy, identity, inverse, lu, minus, minusEquals, norm1, norm2, normF, normInf, plus, plusEquals, print, print, print, print, qr, random, rank, read, set, setMatrix, setMatrix, setMatrix, setMatrix, solve, solveTranspose, svd, times, timesEquals, trace, transpose, uminus
 
Methods inherited from class java.lang.Object
, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Constructor Detail

Vector3D

public Vector3D(double x,
                double y,
                double z,
                boolean normalized)
Constructs a 3D vector, optionally normalized.
Parameters:
x - the x value of the vector.
y - the y value of the vector.
z - the z value of the vector.
normalized - if true, normalizes the new vector.

Vector3D

public Vector3D(double x,
                double y,
                double z)
Constructs a 3D vector.
Parameters:
x - the x value of the vector.
y - the y value of the vector.
z - the z value of the vector.

Vector3D

public Vector3D(Point3D pt)
Constructs a vector by taking the (x,y,z) elements of the point.
Parameters:
pt - the 3D point.

Vector3D

public Vector3D(Jama.Matrix m)
Constructs a vector from a matrix.
Parameters:
m - the 4x1 homogeneous matrix. The matrix must not be modified afterwards.

Vector3D

public Vector3D()
Constructs a zero vector.
Method Detail

set

public void set(Point3D pt)
Sets the vectors x,y,z values from the point. Sets the homogeneous factor to 1.
Parameters:
pt - the source point.

set

public void set(Jama.Matrix m)
Sets the vectors x,y,z,h values from the matrix.
Parameters:
m - the 4x1 homogeneous source matrix.

times

public Jama.Matrix times(double s)
Multiplies the vector by a scalar.
Overrides:
times in class Jama.Matrix
Returns:
C = s*A, an instance of Vector3D

toString

public String toString()
Returns the string representation of the vector.
Overrides:
toString in class Object
Returns:
"Vector3D [x y z h]"

getX

public double getX()
returns the first (X) element of the vector.

getY

public double getY()
returns the second (Y) element of the vector.

getZ

public double getZ()
returns the third (Z) element of the vector.

getH

public double getH()
Returns the homogeneous (H) factor.

setX

public void setX(double v)
Sets the first (X) element of the vector.
Parameters:
v - the new value of X.

setY

public void setY(double v)
Sets the second (Y) element of the vector.
Parameters:
v - the new value of Y.

setZ

public void setZ(double v)
Sets the third (Z) element of the vector.
Parameters:
v - the new value of Z.

setH

public void setH(double v)
Sets the homogeneous factor.

unhomogenize

public void unhomogenize()
Divides the x,y,z factor by h if necessary.

normalized

public Vector3D normalized()
Returns the normalized form of this vector.

norm

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

normalize

public void normalize()
Normalizes this vector.

normalized

public static Vector3D normalized(double x,
                                  double y,
                                  double z)
Returns a normalized vector with the specified (x,y,z) values.

cross

public Vector3D cross(Vector3D B)
Returns the cross product A x B .
Parameters:
B - the other vector

dot

public double dot(Vector3D B)
returns the dot vector A.B .
Parameters:
B - the other vector

add

public static Vector3D add(Vector3D A,
                           Vector3D B)
adds two vectors

add

public static Vector3D add(Vector3D A,
                           Vector3D B,
                           boolean normalized)
adds two vectors

subtract

public static Vector3D subtract(Vector3D A,
                                Vector3D B)
Subtracts two vectors
Returns:
A-B;