|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjme.math.Vector
Vector
defines a three dimensional vector of (x,y,z).
Field Summary | |
float |
x
|
float |
y
|
float |
z
|
Constructor Summary | |
Vector()
Constructor creates a base Vector with values of
(0, 0, 0). |
|
Vector(float[] attributes)
Constructor creates a Vector based on an array of
length three. |
|
Vector(float x,
float y,
float z)
Constructor creates a Vector with the value given
in the parameter as (x, y, z). |
|
Vector(Vector v)
Constructor builds a new Vector as a copy of a
passed in vector. |
Method Summary | |
Vector |
add(Vector v)
add adds the values of this vector by another
vector and returns the result. |
Vector |
cross(Vector v)
cross calculates the cross product of this vector
with a parameter vector v. |
Vector |
divide(float scalar)
divide divides the values of this vector by a
scalar and returns the result. |
float |
dot(Vector v)
dot calculates the dot product of this
vector with the parameter vector. |
static void |
generateOrthonormalBasis(Vector u,
Vector v,
Vector w,
boolean isUnitLength)
generateOrthonormalBasis generates a vector that
satisfies u and v are perpendicular in respect to w. |
Vector |
inverseRotate(Matrix m)
|
float |
length()
length calculates the magnitude of this vector. |
float |
lengthSquared()
lengthSquared calculates the squared value of
the magnitude of the vector. |
Vector |
mult(float scalar)
mult multiplies the values of this vector by a
scalar and returns the result. |
void |
negate()
negate sets this vector to the negative (-x, -y, -z). |
Vector |
normalize()
normalize returns the unit vector of this vector. |
Vector |
rotate(Matrix m)
rotate rotates a vector about a rotation matrix. |
Vector |
subtract(Vector v)
subtract subtracts the values of this vector by
another vector and returns the result. |
java.lang.String |
toString()
toString returns the string representation of
this Vector. |
void |
unitize()
unitize sets this vector to the unit vector or
direction vector. |
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 Vector()
Vector
with values of
(0, 0, 0).
public Vector(float x, float y, float z)
Vector
with the value given
in the parameter as (x, y, z).
x
- the x value of the vector.y
- the y value of the vector.z
- the z value of the vector.public Vector(float[] attributes)
Vector
based on an array of
length three. Where the first position is x, second y, and third
z.
attributes
- the attributes of the Vector.
MonkeyRuntimeException
- if the attributes is not length 3.public Vector(Vector v)
Vector
as a copy of a
passed in vector.
v
- the vector to copy.Method Detail |
public Vector divide(float scalar)
divide
divides the values of this vector by a
scalar and returns the result. The values of this vector
remain untouched.
scalar
- the value to divide this vectors attributes by.
Vector
.public Vector mult(float scalar)
mult
multiplies the values of this vector by a
scalar and returns the result. The values of this vector
remain untouched.
scalar
- the value to multiply the vector attributes by.
public Vector add(Vector v)
add
adds the values of this vector by another
vector and returns the result. The values of this vector
remain untouched.
public Vector subtract(Vector v)
subtract
subtracts the values of this vector by
another vector and returns the result. The values of this vector
remain untouched.
public float length()
length
calculates the magnitude of this vector.
public float lengthSquared()
lengthSquared
calculates the squared value of
the magnitude of the vector.
public float dot(Vector v)
dot
calculates the dot product of this
vector with the parameter vector.
v
- the vector to use for the dot product with this.
public Vector cross(Vector v)
cross
calculates the cross product of this vector
with a parameter vector v.
v
- the vector to take the cross product of with this.
public Vector rotate(Matrix m)
rotate
rotates a vector about a rotation matrix. The
resulting vector is returned.
m
- the rotation matrix.
public Vector inverseRotate(Matrix m)
public void negate()
negate
sets this vector to the negative (-x, -y, -z).
public Vector normalize()
normalize
returns the unit vector of this vector.
public void unitize()
unitize
sets this vector to the unit vector or
direction vector.
public static void generateOrthonormalBasis(Vector u, Vector v, Vector w, boolean isUnitLength)
generateOrthonormalBasis
generates a vector that
satisfies u and v are perpendicular in respect to w.
u
- the u vector to be set.v
- the v vector to be set.w
- the w vector should already be set.isUnitLength
- true if w is unitized, false otherwise.public java.lang.String toString()
toString
returns the string representation of
this Vector. The format is as follows:
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |