|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcs015.Swarm.Vector
Constructor Summary | |
Vector()
This constructor initializes the vector. |
|
Vector(int angle,
double vel)
This constructor initializes the vector with given orientation and velocity. |
Method Summary | |
Vector |
add(Vector v)
This method returns a new vector which is the sum of this vector and the parameter |
Vector |
copy()
This method will return a copy of the current Vector, or in other words, another vector is made with the same orientation and speed and the new reference is returned. |
Vector |
createDirectionallyConstrainedVector(java.awt.Point source,
java.awt.Point target)
This method will return a new vector with current speed and direction towards a specific point on the screen, within a limit So a vector pointing away from the target point will not turn all the way towards the target but just a little bit towards the target. |
Vector |
createRandomlyConstrainedVector()
This method will return a new vector with changed direction and speed by a random amount within a limit set by your TAs. |
int |
getRotation()
This method will return the current rotation of the vector, or in other words, it will return the angle of the vector between it an the positive x axis. |
double |
getVelocity()
This method will return the current velocity of the vector, or in other words, it will return the length of the vector. |
java.awt.Point |
movePositionAlong(java.awt.Point location)
This method returns a new java.awt.Point based on the parameter location. |
void |
rotate(int angle)
|
void |
setRotation(int angle)
This method will set the current rotation of the vector, or in other words, it will set the angle of the vector between it an the positive x axis without modifing the vector's velocity. |
void |
setVelocity(double vel)
This method will set the current velocity of the vector, or in other words, it will set the length of the vector without changing the rotation (or direction) of the vector. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Vector()
public Vector(int angle, double vel)
angle
- the rotation anglevel
- the velocityMethod Detail |
public Vector add(Vector v)
v
- vector to add to the current vectorpublic java.awt.Point movePositionAlong(java.awt.Point location)
location
- The current source of the vector.public Vector createRandomlyConstrainedVector()
public Vector createDirectionallyConstrainedVector(java.awt.Point source, java.awt.Point target)
source
- The vector's point of origintarget
- The position the vector turns towards.public double getVelocity()
public void setVelocity(double vel)
vel
- The vector's new velocitypublic int getRotation()
public void setRotation(int angle)
angle
- The new orientation angle of the vector (in degrees)public void rotate(int angle)
public Vector copy()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |