|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcdx.VectorMath
public final class VectorMath
The VectorMath
class implements the mathematical functions
for manipulating vectors of two and three dimensions. Its operators are
patterned after three address code machines, specifying two operands and
a destination operand. This machine is optimised for performance, thus the
methods are static, contain no calls, create no objects, and do not perform
error checking or synchronisation.
Constructor Summary | |
---|---|
VectorMath()
|
Method Summary | |
---|---|
static void |
add(Vector2d a,
Vector2d b,
Vector2d dest)
The add method takes two vectors and adds them, placing the
result in a third vector. |
static void |
add(Vector3d a,
Vector3d b,
Vector3d dest)
The add method takes two vectors and adds them, placing the
result in a third vector. |
static void |
convert(Vector2d src,
Vector3d dest)
The convert methods have been overridden to allow 2d vectors
to be converted to 3d vectors and vice versa. |
static void |
convert(Vector3d src,
Vector2d dest)
The convert methods have been overridden to allow 2d vectors
to be converted to 3d vectors and vice versa. |
static float |
distance(Vector2d a,
Vector2d b)
The distance method takes two vectors and computes their
(Euclidean) distance. |
static float |
distance(Vector2d a,
Vector3d b)
The distance method takes two vectors and computes their
(Euclidean) distance. |
static float |
distance(Vector3d a,
Vector2d b)
The distance method takes two vectors and computes their
(Euclidean) distance. |
static float |
distance(Vector3d a,
Vector3d b)
The distance method takes two vectors and computes their
(Euclidean) distance. |
static float |
dotProduct(Vector2d a,
Vector2d b)
The dotProduct method computes the dot product between two
vectors using the standard inner product formula. |
static float |
dotProduct(Vector3d a,
Vector3d b)
The dotProduct method computes the dot product between two
vectors using the standard inner product formula. |
static float |
magnitude(Vector2d a)
The magnitude method takes a Vector2d and
computes its magnitude according the Euclidean norm. |
static float |
magnitude(Vector3d a)
The magnitude method takes a Vector3d and
computes its magnitude according the Euclidean norm. |
static void |
normalize(Vector2d a,
Vector2d dest)
The normalize method takes a Vector2d and if it
is non-zero, will normalize it so that its magnitude will be 1. |
static void |
normalize(Vector3d a,
Vector3d dest)
The normalize method takes a Vector3d and if it
is non-zero, will normalize it so that its magnitude will be 1. |
static float |
phi(Vector3d a)
The phi method takes a Vector3d and calculates
the elevation between the XY-plane and the vector. |
static int |
quadrant(Vector2d a)
The quadrant method is a utility function for two dimensional
vectors that takes a vector as a parameter and will return an integer
describing what quadrant of the xy plane the vector lies in. |
static void |
rotate(Vector3d a,
float radians,
Vector3d dest)
The rotate method takes a Vector3d and a scalar
float value and will rotate the vector in the xy plane. |
static void |
scale(Vector2d a,
float scale,
Vector2d dest)
The scale method takes a Vector2d and a scalar
float value multiplies each component of the Vector, storing the result
in the third parameter. |
static void |
scale(Vector3d a,
float scale,
Vector3d dest)
The scale method takes a Vector3d and a scalar
float value multiplies each component of the Vector, storing the result
in the third parameter. |
static float |
sqDistance(Vector2d a,
Vector2d b)
The sqDistance method takes two vectors and computes the
square of their (Euclidean) distance. |
static float |
sqDistance(Vector2d a,
Vector3d b)
The sqDistance method takes two vectors and computes the
square of their (Euclidean) distance. |
static float |
sqDistance(Vector3d a,
Vector2d b)
The sqDistance method takes two vectors and computes the
square of their (Euclidean) distance. |
static float |
sqDistance(Vector3d a,
Vector3d b)
The sqDistance method takes two vectors and computes the
square of their (Euclidean) distance. |
static void |
subtract(Vector2d a,
Vector2d b,
Vector2d dest)
The subtract method takes two vectors and subtracts them,
placing the result in a third vector. |
static void |
subtract(Vector3d a,
Vector3d b,
Vector3d dest)
The subtract method takes two vectors and subtracts them,
placing the result in a third vector. |
static float |
theta(Vector3d a)
The theta method takes a Vector3d and calculates
the angle between the X-axis and the vector, ignoring the z component of
the vector. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public VectorMath()
Method Detail |
---|
public static void add(Vector3d a, Vector3d b, Vector3d dest)
add
method takes two vectors and adds them, placing the
result in a third vector.
a
- the value of the first vectorb
- the value of the second vectordest
- the destination Vector3d to store the resultpublic static void subtract(Vector3d a, Vector3d b, Vector3d dest)
subtract
method takes two vectors and subtracts them,
placing the result in a third vector.
a
- the value of the first vectorb
- the value of the second vectordest
- the destination Vector3d to store the resultpublic static void scale(Vector3d a, float scale, Vector3d dest)
scale
method takes a Vector3d
and a scalar
float value multiplies each component of the Vector, storing the result
in the third parameter.
a
- the value of the first vectorscale
- the value to scale the vector bydest
- the destination Vector3d to store the resultpublic static void normalize(Vector3d a, Vector3d dest)
normalize
method takes a Vector3d
and if it
is non-zero, will normalize it so that its magnitude will be 1.
a
- the value of the vector to normalizedest
- the destination Vector3d to store the result
ZeroVectorException
- if the vector is zeropublic static float magnitude(Vector3d a)
magnitude
method takes a Vector3d
and
computes its magnitude according the Euclidean norm.
a
- the value of the vector of which to compute the magnitude
public static float distance(Vector3d a, Vector3d b)
distance
method takes two vectors and computes their
(Euclidean) distance.
a
- the value of the first vectorb
- the value of the second vector
public static float sqDistance(Vector3d a, Vector3d b)
sqDistance
method takes two vectors and computes the
square of their (Euclidean) distance. This is just an optimization for
the distance
method that avoids an expensive floating point
square root computation.
a
- the value of the first vectorb
- the value of the second vector
public static float dotProduct(Vector3d a, Vector3d b)
dotProduct
method computes the dot product between two
vectors using the standard inner product formula.
a
- the value of the first vectorb
- the value of the second vector
public static void rotate(Vector3d a, float radians, Vector3d dest)
rotate
method takes a Vector3d
and a scalar
float value and will rotate the vector in the xy plane.
a
- the value of the first vectorradians
- the value to rotate the vector bydest
- the destination Vector3d to store the resultpublic static float theta(Vector3d a)
theta
method takes a Vector3d
and calculates
the angle between the X-axis and the vector, ignoring the z component of
the vector.
a
- the vector of which to calculate the theta angle
ZeroVectorException
- if the vector passed equals the zero vector,
for which the theta value is undefinedpublic static float phi(Vector3d a)
phi
method takes a Vector3d
and calculates
the elevation between the XY-plane and the vector.
a
- the vector of which to calculate the phi angle
ZeroVectorException
- if the vector passed equals the zero vector,
for which the phi value is undefinedpublic static void add(Vector2d a, Vector2d b, Vector2d dest)
add
method takes two vectors and adds them, placing the
result in a third vector.
a
- the value of the first vectorb
- the value of the second vectordest
- the destination Vector2d to store the resultpublic static void subtract(Vector2d a, Vector2d b, Vector2d dest)
subtract
method takes two vectors and subtracts them,
placing the result in a third vector.
a
- the value of the first vectorb
- the value of the second vectordest
- the destination Vector2d to store the resultpublic static void scale(Vector2d a, float scale, Vector2d dest)
scale
method takes a Vector2d
and a scalar
float value multiplies each component of the Vector, storing the result
in the third parameter.
a
- the value of the first vectorscale
- the value to scale the vector bydest
- the destination Vector2d to store the resultpublic static void normalize(Vector2d a, Vector2d dest)
normalize
method takes a Vector2d
and if it
is non-zero, will normalize it so that its magnitude will be 1.
a
- the value of the vector to normalizedest
- the destination Vector2d to store the result
ZeroVectorException
- if the vector is zeropublic static float magnitude(Vector2d a)
magnitude
method takes a Vector2d
and
computes its magnitude according the Euclidean norm.
a
- the value of the vector of which to compute the magnitude
public static float distance(Vector2d a, Vector2d b)
distance
method takes two vectors and computes their
(Euclidean) distance.
a
- the value of the first vectorb
- the value of the second vector
public static float sqDistance(Vector2d a, Vector2d b)
sqDistance
method takes two vectors and computes the
square of their (Euclidean) distance. This is just an optimization for
the distance
method that avoids an expensive floating point
square root computation.
a
- the value of the first vectorb
- the value of the second vector
public static float dotProduct(Vector2d a, Vector2d b)
dotProduct
method computes the dot product between two
vectors using the standard inner product formula.
a
- the value of the first vectorb
- the value of the second vector
public static int quadrant(Vector2d a)
quadrant
method is a utility function for two dimensional
vectors that takes a vector as a parameter and will return an integer
describing what quadrant of the xy plane the vector lies in.
a
- the vector to compute the quadrant of
public static void convert(Vector3d src, Vector2d dest)
convert
methods have been overridden to allow 2d vectors
to be converted to 3d vectors and vice versa.
src
- the value of the source vectordest
- the value of the destination vectorpublic static void convert(Vector2d src, Vector3d dest)
convert
methods have been overridden to allow 2d vectors
to be converted to 3d vectors and vice versa.
src
- the value of the source vectordest
- the value of the destination vectorpublic static float distance(Vector3d a, Vector2d b)
distance
method takes two vectors and computes their
(Euclidean) distance. It has been overloaded to allow the computation
of the distance between a 3d vector and a 2d vector.
a
- the value of the first vectorb
- the value of the second vector
public static float distance(Vector2d a, Vector3d b)
distance
method takes two vectors and computes their
(Euclidean) distance. It has been overloaded to allow the computation
of the distance between a 3d vector and a 2d vector.
a
- the value of the first vectorb
- the value of the second vector
public static float sqDistance(Vector3d a, Vector2d b)
sqDistance
method takes two vectors and computes the
square of their (Euclidean) distance. This is just an optimization for
the distance
method that avoids an expensive floating point
square root computation. It has been overloaded to allow the computation
of the distance between a 3d vector and a 2d vector.
a
- the value of the first vectorb
- the value of the second vector
public static float sqDistance(Vector2d a, Vector3d b)
sqDistance
method takes two vectors and computes the
square of their (Euclidean) distance. This is just an optimization for
the distance
method that avoids an expensive floating point
square root computation. It has been overloaded to allow the computation
of the distance between a 3d vector and a 2d vector.
a
- the value of the first vectorb
- the value of the second vector
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |