

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
java.lang.Object y25.graphics.Vector3D
Represents a vector in three dimensional space.
A vector's x,y and z coordinates can be retrieved and set by accessing it's
x,y and z members directly, e.g. vector.x = 3*vector.z
.
Most operations on a Vector3D
can be chained, since a
reference to the vector is returned by most methods, e.g.
vector.set(2,3,4).add(1,2,3).scale(0.5).reverse()
.
Field Summary  
float 
x
The xcoordinate of the vector. 
float 
y
The ycoordinate of the vector. 
float 
z
The zcoordinate of the vector. 
Constructor Summary  
Vector3D()
Creates a nullvector (a vector whose entries are all 0). 

Vector3D(float xx,
float yy,
float zz)
Creates a vector that points in the given direction. 

Vector3D(Point3D p)
Creates a vector by interpreting the passed point as a vector and copying its coordinates. 

Vector3D(Point3D from,
Point3D to)
Creates a vector that points from point from to point
to . 

Vector3D(Vector3D v)
Creates a vector that points in the same direction as the passed vector. 
Method Summary  
Vector3D 
add(Vector3D v)
Adds the given vector to this one. 
Vector3D 
cross(Vector3D v)
Computes the cross product of this vector with the passed one and stores the result in this vector. 
float 
dot(Vector3D v)
Computes the dot product of this vector and the passed one. 
Vector3D 
getAdded(Vector3D a)
Adds the given vector to a copy of this one and returns the copy. 
Vector3D 
getCrossed(Vector3D v)
Computes the cross product of this vector with the passed one and returns the result. 
int 
getMaxAxis()
Determines the most dominant axis of this vector and returns its index. 
int 
getMinAxis()
Determines the least dominant axis of this vector and returns its index. 
Vector3D 
getNormalized()
Normalizes a copy of this vector and returns the copy. 
Vector3D 
getOrthogonal()
Returns a vector that is orthogonal to this one. 
Point3D 
getPoint3D()
Returns a Point3D with the same x,y,z entries as this
vector. 
Vector3D 
getReversed()
Reverses a copy of this vector and returns the copy. 
Vector3D 
getScaled(float s)
Scales a copy of this vector by the given scaling factor and returns the copy. 
Vector3D 
getSubtracted(Vector3D a)
Subtracts the given vector from a copy of this one and returns the copy. 
boolean 
isZero()
Returns true if this is a nullvector (all entries are
0 ), false otherwise. 
float 
length()
Returns the length of this vector. 
Vector3D 
normalize()
Normalizes this vector. 
Vector3D 
reverse()
Reverses the direction of this vector. 
Vector3D 
scale(float s)
Scales this vector by the given scaling factor. 
Vector3D 
set(float xx,
float yy,
float zz)
Sets this vector to point in the given direction. 
Vector3D 
set(Point3D p)
Interprets the passed point as a vector and sets this vector accordingly.. 
Vector3D 
set(Point3D from,
Point3D to)
Sets this vector to point from from to to . 
Vector3D 
set(Vector3D v)
Sets this vector to point in the same direction as the passed vector. 
Vector3D 
subtract(Vector3D v)
Subtracts the given vector from this one. 
String 
toString()

Methods inherited from class java.lang.Object 
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait 
Field Detail 
public float x
public float y
public float z
Constructor Detail 
public Vector3D()
public Vector3D(Vector3D v)
public Vector3D(float xx, float yy, float zz)
public Vector3D(Point3D p)
public Vector3D(Point3D from, Point3D to)
from
to point
to
.
Method Detail 
public Vector3D set(float xx, float yy, float zz)
public Vector3D set(Vector3D v)
public Vector3D set(Point3D p)
set(new Point3D(0,0,0), p)
. Returns
a reference to this vector.
public Vector3D set(Point3D from, Point3D to)
from
to to
.
Returns a reference to this vector.
public boolean isZero()
true
if this is a nullvector (all entries are
0
), false
otherwise.
public float length()
public Vector3D normalize()
length()
equals 1
. Returns a reference to
this vector.
public Vector3D getNormalized()
public Vector3D cross(Vector3D v)
In a right handed coordinate system, where X, Y and Z denote the vectors
of the axes, we have: Z = X.cross(Y)
and
Z  Y.cross(X)
.
public Vector3D getCrossed(Vector3D v)
public Vector3D reverse()
public Vector3D getReversed()
public Vector3D scale(float s)
public Vector3D getScaled(float s)
public Vector3D add(Vector3D v)
public Vector3D getAdded(Vector3D a)
public Vector3D subtract(Vector3D v)
public Vector3D getSubtracted(Vector3D a)
public float dot(Vector3D v)
public String toString()
public int getMinAxis()
The least dominant axis of a vector is the one with the smallest absolute
value, e.g. for a vector (2,3,1)
, the least dominant
axis is the zaxis.
The xaxis has index 0
, the yaxis has index
1
and the zaxis has index 2
.
public int getMaxAxis()
The most dominant axis of a vector is the one with the highest absolute
value, e.g. for a vector (2,3,1)
, the most dominant axis
is the yaxis.
The xaxis has index 0
, the yaxis has index
1
and the zaxis has index 2
.
public Vector3D getOrthogonal()
Note that there are infinitely many such vectors (and they all lie on a plane), so this method just returns an arbitrary one of them.
public Point3D getPoint3D()
Point3D
with the same x,y,z entries as this
vector.


PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 