|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.brackeen.javagamebook.math3D.Vector3D
The Vector3D class implements a 3D vector with the floating-point values x, y, and z. Vectors can be thought of either as a (x,y,z) point or as a vector from (0,0,0) to (x,y,z).
Field Summary | |
float |
x
|
float |
y
|
float |
z
|
Constructor Summary | |
Vector3D()
Creates a new Vector3D at (0,0,0). |
|
Vector3D(float x,
float y,
float z)
Creates a new Vector3D with the specified (x, y, z) values. |
|
Vector3D(Vector3D v)
Creates a new Vector3D with the same values as the specified Vector3D. |
Method Summary | |
void |
add(float x,
float y,
float z)
Adds the specified (x, y, z) values to this vector. |
void |
add(Transform3D xform)
Adds the specified transform to this vector. |
void |
add(Vector3D v)
Adds the specified vector to this vector. |
void |
addRotation(Transform3D xform)
Rotates this vector with the angle of the specified transform. |
void |
divide(float s)
Divides this vector by the specified value. |
boolean |
equals(float x,
float y,
float z)
Checks if this Vector3D is equal to the specified x, y, and z coordinates. |
boolean |
equals(java.lang.Object obj)
Checks if this Vector3D is equal to the specified Object. |
float |
getDistance(Vector3D v)
Gets the distance between this vector and the specified vector. |
float |
getDistanceSq(Vector3D v)
Gets the distance squared between this vector and the specified vector. |
float |
getDotProduct(Vector3D v)
Returns the dot product of this vector and the specified vector. |
float |
length()
Returns the length of this vector as a float. |
void |
multiply(float s)
Multiplies this vector by the specified value. |
void |
normalize()
Converts this Vector3D to a unit vector, or in other words, a vector of length 1. |
void |
rotateX(float angle)
Rotate this vector around the x axis the specified amount. |
void |
rotateX(float cosAngle,
float sinAngle)
Rotate this vector around the x axis the specified amount, using pre-computed cosine and sine values of the angle to rotate. |
void |
rotateY(float angle)
Rotate this vector around the y axis the specified amount. |
void |
rotateY(float cosAngle,
float sinAngle)
Rotate this vector around the y axis the specified amount, using pre-computed cosine and sine values of the angle to rotate. |
void |
rotateZ(float angle)
Rotate this vector around the z axis the specified amount. |
void |
rotateZ(float cosAngle,
float sinAngle)
Rotate this vector around the y axis the specified amount, using pre-computed cosine and sine values of the angle to rotate. |
void |
setLength(float newLength)
Sets the length of this Vector3D |
void |
setTo(float x,
float y,
float z)
Sets this vector to the specified (x, y, z) values. |
void |
setTo(Vector3D v)
Sets the vector to the same values as the specified Vector3D. |
void |
setToCrossProduct(Vector3D u,
Vector3D v)
Sets this vector to the cross product of the two specified vectors. |
void |
subtract(float x,
float y,
float z)
Subtracts the specified (x, y, z) values to this vector. |
void |
subtract(Transform3D xform)
Subtracts the specified transform to this vector. |
void |
subtract(Vector3D v)
Subtracts the specified vector from this vector. |
void |
subtractRotation(Transform3D xform)
Rotates this vector with the opposite angle of the specified transform. |
java.lang.String |
toString()
Converts this Vector3D to a String representation. |
Methods inherited from class java.lang.Object |
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 x, float y, float z)
Method Detail |
public boolean equals(java.lang.Object obj)
public boolean equals(float x, float y, float z)
public void setTo(Vector3D v)
public void setTo(float x, float y, float z)
public void add(float x, float y, float z)
public void subtract(float x, float y, float z)
public void add(Vector3D v)
add
in interface Transformable
public void subtract(Vector3D v)
subtract
in interface Transformable
public void multiply(float s)
public void divide(float s)
public float length()
public void normalize()
public java.lang.String toString()
public void rotateX(float angle)
public void rotateY(float angle)
public void rotateZ(float angle)
public void rotateX(float cosAngle, float sinAngle)
public void rotateY(float cosAngle, float sinAngle)
public void rotateZ(float cosAngle, float sinAngle)
public void add(Transform3D xform)
add
in interface Transformable
public void subtract(Transform3D xform)
subtract
in interface Transformable
public void addRotation(Transform3D xform)
addRotation
in interface Transformable
public void subtractRotation(Transform3D xform)
subtractRotation
in interface Transformable
public float getDotProduct(Vector3D v)
public void setToCrossProduct(Vector3D u, Vector3D v)
public float getDistanceSq(Vector3D v)
public float getDistance(Vector3D v)
public void setLength(float newLength)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |