|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.cult3d.math.Vector2
A two element Vector with x, y coordinates.
Constructor Summary | |
Vector2()
Constructs and initializes a new vector. |
|
Vector2(float[] array)
Constructs a new vector and initializes it from the array parameter. |
|
Vector2(float x,
float y)
Constructs a new vector and initializes it to the specified values. |
|
Vector2(Vector2 v)
Constructs a new vector and initializes it from the vector parameter. |
Method Summary | |
void |
add(Vector2 v)
Sets this vector to the sum of itself and the vector parameter. |
void |
add(Vector2 v1,
Vector2 v2)
Sets this vector to the sum of the two vector parameters. |
float |
angle(Vector2 v)
Returns the angle in radians between this vector and the parameter. |
void |
div(float f)
Divides this vector with the parameter. |
void |
div(Vector2 v,
float f)
Sets this vector to the v parameter divided with the f parameter |
float |
dot(Vector2 v)
Computes the dot product of itself and the parameter. |
float |
dot(Vector2 v1,
Vector2 v2)
Computes the dot product of vectors v1 and v2. |
boolean |
equals(java.lang.Object obj)
Returns true if the Object obj is of type Vector2 and all of the coordinates of obj are equal to the corresponding coordinates in this Vector2. |
java.lang.String |
getInfo()
This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations and versions of Cult3D. |
float |
getX()
Gets this vectors x coordinate. |
float |
getY()
Gets this vectors y coordinate. |
float |
length()
Returns the length of this vector. |
void |
mult(float f)
Multiplies this vector with the parameter. |
void |
mult(Vector2 v,
float f)
Sets this vector to the v parameter multiplied with the f parameter |
void |
normalize()
Sets this vector to its normal. |
void |
normalize(Vector2 v)
Sets this vector to the parameters normal. |
void |
rotate(float a)
Rotates the vector by a specified angle. |
void |
setVector(float[] array)
Sets this vector to the values in the array parameter. |
void |
setVector(float x,
float y)
Sets this vector to the parameter values. |
void |
setVector(Vector2 v)
Sets this vector to the same values as the parameter. |
void |
setX(float x)
Sets this vectors x coordinate. |
void |
setY(float y)
Sets this vectors y coordinate. |
void |
sub(Vector2 v)
Sets this vector to the difference of itself and the vector parameter. |
void |
sub(Vector2 v1,
Vector2 v2)
Sets this vector to the difference of the two vector parameters. |
java.lang.String |
toString()
Returns a string representation of the values of this object. |
Methods inherited from class java.lang.Object |
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public Vector2()
public Vector2(float x, float y)
x
- the x coordinatey
- the y coordinatepublic Vector2(float[] array)
array
- array of length 2public Vector2(Vector2 v)
v
- the source vectorMethod Detail |
public void setVector(float x, float y)
x
- the x coordinatey
- the y coordinatepublic void setVector(float[] array)
array
- array of length 2public void setVector(Vector2 v)
v
- the source vectorpublic void setX(float x)
x
- the x coordinatepublic void setY(float y)
y
- the y coordinatepublic float getX()
public float getY()
public void add(Vector2 v)
v
- the vector to addpublic void add(Vector2 v1, Vector2 v2)
v1
- the first vector to addv2
- the second vector to addpublic void sub(Vector2 v)
v
- the vector to subtractpublic void sub(Vector2 v1, Vector2 v2)
v1
- the first vectorv2
- the second vectorpublic void div(float f)
f
- value to divide with.public void div(Vector2 v, float f)
v
- the vector to dividef
- value to divide with.public void mult(float f)
f
- value to multiplie with.public void mult(Vector2 v, float f)
v
- the vector to multiplief
- value to multiplie with.public float dot(Vector2 v)
v
- the vectorpublic float dot(Vector2 v1, Vector2 v2)
v1
- the first vectorv2
- the second vectorpublic final float length()
public final void normalize()
public final void normalize(Vector2 v)
v
- the vector to normalize.public final float angle(Vector2 v)
v
- the other vector.public final void rotate(float a)
a
- angle to roatate the vectorpublic boolean equals(java.lang.Object obj)
public java.lang.String getInfo()
This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations and versions of Cult3D.
public java.lang.String toString()
Returns a string representation of the values of this object.
The string contains the name of this class and the current x,y values of this vector.
This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations and versions of Cult3D.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |