|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectzombie.iso.Vector2
public class Vector2
Field Summary | |
---|---|
float |
x
The horizontal part of this vector |
float |
y
The vertical part of this vector |
Constructor Summary | |
---|---|
Vector2()
Create a new vector with zero length |
|
Vector2(float x,
float y)
Create a new vector with specified horizontal and vertical parts |
|
Vector2(Vector2 other)
Create a new vector which is identical to another vector |
Method Summary | |
---|---|
Vector2 |
add(Vector2 other)
Add another vector to this one and return as a new vector |
Vector2 |
addToThis(Vector2 other)
Add another vector to this one and store the result in this one |
Vector2 |
aimAt(Vector2 other)
Set the direction of this vector to point to another vector, maintaining the length |
float |
angleTo(Vector2 other)
Calculate the angle between this point and another |
Vector2 |
clone()
Clone this vector |
float |
distanceTo(Vector2 other)
Calculate the distance between this point and another |
static float |
dot(float x,
float y,
float tx,
float ty)
|
float |
dot(Vector2 other)
|
boolean |
equals(java.lang.Object other)
See if this vector is equal to another |
static Vector2 |
fromAwtPoint(java.awt.Point p)
Create a new vector from an AWT Point |
static Vector2 |
fromLengthDirection(float length,
float direction)
Create a new vector with a specified length and direction |
float |
getDirection()
get the direction in which this vector is pointing Note: if the length of this vector is 0, then the direction will also be 0 |
float |
getLength()
get the length of this vector |
float |
getX()
|
float |
getY()
|
void |
normalize()
|
void |
rotate(float rad)
|
Vector2 |
set(float x,
float y)
Set the horizontal and vertical parts of this vector |
Vector2 |
set(Vector2 other)
Make this vector identical to another vector |
Vector2 |
setDirection(float direction)
Set the direction of this vector, maintaining the length |
Vector2 |
setLength(float length)
Set the length of this vector, maintaining the direction |
Vector2 |
setLengthAndDirection(float direction,
float length)
Set the length and direction of this vector |
void |
setX(float x)
|
void |
setY(float y)
|
java.awt.Dimension |
toAwtDimension()
Convert this vector to an AWT Dimension |
java.awt.Point |
toAwtPoint()
Convert this vector to an AWT Point |
java.lang.String |
toString()
Returns a string representing this vector |
Methods inherited from class java.lang.Object |
---|
getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public float x
public float y
Constructor Detail |
---|
public Vector2()
public Vector2(Vector2 other)
other
- The Vector2
to copypublic Vector2(float x, float y)
x
- The horizontal party
- The vertical partMethod Detail |
---|
public void rotate(float rad)
public static Vector2 fromAwtPoint(java.awt.Point p)
p
- The java.awt.Point
to convert
Vector2
representing the Pointpublic static Vector2 fromLengthDirection(float length, float direction)
direction
- The direction of the new vector, in radianslength
- The length of the new vector
public Vector2 add(Vector2 other)
other
- The other Vector2
to add to this one
Vector2
public Vector2 addToThis(Vector2 other)
other
- The other Vector2
to add to this one
public Vector2 aimAt(Vector2 other)
other
- The Vector2
to point this one at.public float angleTo(Vector2 other)
other
- The second point as vector
public Vector2 clone()
clone
in class java.lang.Object
public float distanceTo(Vector2 other)
other
- The second point as vector
public float dot(Vector2 other)
public static float dot(float x, float y, float tx, float ty)
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
other
- A Vector2
to compare this one to
true
if other
is a Vector2
equal to this onepublic float getDirection()
public float getLength()
public void normalize()
public Vector2 set(Vector2 other)
other
- The Vector2
to copypublic Vector2 set(float x, float y)
x
- The horizontal party
- The vertical partpublic Vector2 setDirection(float direction)
direction
- The new direction of this vector, in radianspublic Vector2 setLength(float length)
length
- The length of this vectorpublic Vector2 setLengthAndDirection(float direction, float length)
direction
- The direction of this vector, in radianslength
- The length of this vectorpublic java.awt.Dimension toAwtDimension()
java.awt.Dimension
public java.awt.Point toAwtPoint()
java.awt.Point
public java.lang.String toString()
toString
in class java.lang.Object
String
representing this vectorpublic float getX()
public void setX(float x)
x
- the x to setpublic float getY()
public void setY(float y)
y
- the y to set
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |