java.lang.ObjectVector
public class Vector
Vector - This class was written as a utility class for Greenfoot scenarios. This class represents a 2-dimensional vector. The vector can be used to deal with movement information (speed and direction) of actors. An actor can store a vector, and then other vectors can be added to modify the current velocity and direction.
Constructor Summary | |
---|---|
Vector()
|
|
Vector(int direction,
double length)
|
Method Summary | |
---|---|
void |
add(Vector other)
Add other vector to this vector. |
Vector |
copy()
Create a copy of this vector. |
int |
getDirection()
|
double |
getLength()
|
double |
getX()
|
double |
getY()
|
void |
reduceLength(double d)
|
void |
scale(double factor)
|
void |
setDirection(int direction)
Set the direction of this vector. |
void |
setNeutral()
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Vector()
public Vector(int direction, double length)
Method Detail |
---|
public void add(Vector other)
public Vector copy()
public int getDirection()
public double getLength()
public double getX()
public double getY()
public void reduceLength(double d)
public void scale(double factor)
public void setDirection(int direction)
public void setNeutral()
public java.lang.String toString()
toString
in class java.lang.Object