|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.jinx.math.Vector
public class Vector
Vector is a set of three floats, as X/Y/Z coordinates. There are operations
for regular math (that function on all three seperately), as well as
operations that are Vector specific.
API Stability: Beta.
Field Summary | |
---|---|
static Vector |
zero
|
Constructor Summary | |
---|---|
Vector()
Constructs a Vector with all zero components. |
|
Vector(float[] vec)
Constructs a new Vector with the given X/Y/Z coordinates. |
|
Vector(float x,
float y,
float z)
Constructs a new Vector with the given X/Y/Z coordinates. |
|
Vector(java.lang.String s)
Constructs a new Vector by parsing the given String. |
Method Summary | |
---|---|
Vector |
abs()
Returns a Vector whose components have had their sign removed. |
Vector |
add(float v)
Returns the result of adding v to this Vector's components. |
Vector |
add(Vector v)
Returns the result of adding v's components to this Vector's components. |
Vector |
cross(Vector v)
Returns a Vector whose value is the cross product of this and v. |
Vector |
divide(float v)
Returns the result of this Vector's components divided by v's components. |
Vector |
divide(Vector v)
Returns the result of this Vector's compoenents divided by v's components. |
float |
dot(Vector v)
Returns a float whose value is the dot product of this and v. |
boolean |
equals(java.lang.Object obj)
|
void |
fillFloatArray(float[] fa)
Fills a length 3 float array with the values for getX(), getY() and getZ(). |
float |
getX()
Provides the X coordinate. |
float |
getY()
Provides the Y coordinate. |
float |
getZ()
Provides the Z coordinate. |
int |
hashCode()
Returns the hash code for this Vector. |
float |
magnitude()
Returns the the following: sqrt(X*X + Y*Y + Z*Z). |
Vector |
multiply(float v)
Returns the result of multiplying v with this Vector's components. |
Vector |
multiply(Vector v)
Returns the result of multiplying v's components with this Vector's components. |
Vector |
negate()
Negates each component of this Vector. |
Vector |
normalize()
Divides this Vector by it's magnitude to produce a normalized version of it. |
Vector |
subtract(float v)
Returns the result of subtracting v from this Vector's components. |
Vector |
subtract(Vector v)
Returns the result of subtracting v's components from this Vector's components. |
float[] |
toFloatArray()
Converts this Vector to a (new) float array. |
java.lang.String |
toString()
Provides a String representation of this Vector. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final Vector zero
Constructor Detail |
---|
public Vector()
public Vector(float x, float y, float z)
x
- the X coordinate.y
- the Y coordinate.z
- the Z coordinate.public Vector(float[] vec)
vec
- the coordinates in an array.public Vector(java.lang.String s)
s
- the String to parse.Method Detail |
---|
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public float getX()
public float getY()
public float getZ()
public Vector abs()
public float dot(Vector v)
v
- the Vector to use.
public Vector cross(Vector v)
v
- the Vector to use.
public Vector add(Vector v)
v
- the Vector to add.
public Vector add(float v)
v
- the float to add.
public Vector subtract(Vector v)
v
- the Vector to subtract.
public Vector subtract(float v)
v
- the float to subtract.
public Vector multiply(Vector v)
v
- the Vector to multiply.
public Vector multiply(float v)
v
- the float to multiply.
public Vector divide(Vector v)
v
- the Vector to divide by.
public Vector divide(float v)
v
- the float to divide by.
public float magnitude()
public Vector negate()
public Vector normalize()
public float[] toFloatArray()
public void fillFloatArray(float[] fa)
fa
- the float array to fill.
java.lang.IllegalArgumentException
- if fa is not length 3.public java.lang.String toString()
toString
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |