jumbo.euclid
Class Vector3

java.lang.Object
  |
  +--jumbo.euclid.Status
        |
        +--jumbo.euclid.Vector3

public class Vector3
extends Status

Vector3 - 3-dimensional vector

A vector has thre components giving it a length and a direction (whose sign is important),but no position. Vectors are often normalised to unit length.

Vectors and points are very closely related and some people use them interchangeably. A Point3 has a position and cannot be normalised. In very many routines, however, Vectors and Points can either be used interchangeably, or there are equivalent routines or they can be converted using cross-constructors. (They cannot be interconverted through casts).

The default vector is 0.0, 0.0, 0.0. Some operations on this will result in ZerolengthVector Exceptions.


Constructor Summary
Vector3()
          null constructor
Vector3(Choice3 axis)
          axial unit vector constructor: unit vectors along X, Y, Z axes
Vector3(double[] array)
          formed from vector components
Vector3(double x, double y, double z)
          formed from vector components
Vector3(Point3 p)
          make a vector from a point
Vector3(RealArray f)
          copy constructor from RealArray:
Vector3(Vector3 v)
          copy constructor:
 
Method Summary
 Vector3 clone(Point3 p)
          from Point3
 Vector3 clone(Vector3 v)
           
 Vector3 cross(Vector3 v3)
          Vector product
protected  double dot(double[] v3)
          dot product - protected
 double dot(Vector3 v3)
          dot product
 double elementAt(int n)
          subscript operator: counts from ZERO
 boolean equals(Vector3 v)
          are two vectors equal lengths?
 Angle getAngleMadeWith(Vector3 v2)
          angle between two vectors
 double[] getArray()
          get the vector components
 double getLength()
          return vector length
 double getScalarTripleProduct(Vector3 v2, Vector3 v3)
           
 Vector3 getUnitVector()
           
 boolean isIdenticalTo(Vector3 v)
          are two vectors identical?
 boolean isZero()
          is a vector null?
 boolean longerThan(Vector3 v)
          vector length > vector length?
static void main(java.lang.String[] args)
          tests Vector3 routines = new Vector3
 Vector3 multiplyBy(double f)
          scalar multiplication v = v*f
 Vector3 negative()
           
 Vector3 normalise()
          Normalise vector
 Vector3 plus(Vector3 v3)
           
 Vector3 projectOnto(Vector3 v3)
          projection of this onto v3
 Vector3 setElementAt(int n, double f)
          subscript operator: counts from ZERO
 void shallowCopy(Vector3 v)
          shallowCopy
 Vector3 subtract(Vector3 v3)
           
 java.lang.String toString()
           
 Vector3 transform(Transform3 t)
          transform a vector
 
Methods inherited from class jumbo.euclid.Status
NYI
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Vector3

public Vector3()
null constructor

Vector3

public Vector3(double x,
               double y,
               double z)
formed from vector components

Vector3

public Vector3(double[] array)
formed from vector components

Vector3

public Vector3(Choice3 axis)
axial unit vector constructor: unit vectors along X, Y, Z axes

Vector3

public Vector3(Vector3 v)
copy constructor:

Vector3

public Vector3(RealArray f)
copy constructor from RealArray:

Vector3

public Vector3(Point3 p)
make a vector from a point
Method Detail

shallowCopy

public void shallowCopy(Vector3 v)
shallowCopy

clone

public Vector3 clone(Vector3 v)

clone

public Vector3 clone(Point3 p)
from Point3

getArray

public double[] getArray()
get the vector components

equals

public boolean equals(Vector3 v)
are two vectors equal lengths?

longerThan

public boolean longerThan(Vector3 v)
vector length > vector length?

multiplyBy

public Vector3 multiplyBy(double f)
scalar multiplication v = v*f

plus

public Vector3 plus(Vector3 v3)

subtract

public Vector3 subtract(Vector3 v3)

negative

public Vector3 negative()

elementAt

public double elementAt(int n)
subscript operator: counts from ZERO

setElementAt

public Vector3 setElementAt(int n,
                            double f)
subscript operator: counts from ZERO

isIdenticalTo

public boolean isIdenticalTo(Vector3 v)
are two vectors identical?

isZero

public boolean isZero()
is a vector null?

transform

public Vector3 transform(Transform3 t)
transform a vector

cross

public Vector3 cross(Vector3 v3)
Vector product

normalise

public Vector3 normalise()
Normalise vector

getUnitVector

public Vector3 getUnitVector()

getLength

public double getLength()
return vector length

dot

public double dot(Vector3 v3)
dot product

dot

protected double dot(double[] v3)
dot product - protected

getAngleMadeWith

public Angle getAngleMadeWith(Vector3 v2)
                       throws ZeroVectorException
angle between two vectors
Throws:
ZeroVectorException - v2 or this is zero length

getScalarTripleProduct

public double getScalarTripleProduct(Vector3 v2,
                                     Vector3 v3)

projectOnto

public Vector3 projectOnto(Vector3 v3)
                    throws ZeroVectorException
projection of this onto v3
Throws:
ZeroVectorException - v2 or this is zero length

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

main

public static void main(java.lang.String[] args)
tests Vector3 routines = new Vector3