GP.Attributes
Class Velocity

java.lang.Object
  |
  +--GP.Attributes.Velocity

public class Velocity
extends java.lang.Object


Constructor Summary
Velocity()
          Initializes velocity with default direction (0 degrees) and speed (1 pixel per move):
Velocity(double dx, double dy)
          Initializes velocity that represents the given change in x and y.
Velocity(Orientation direction, double speed)
          Initializes velocity with given direction and speed.
Velocity(Orientation direction, Value speed)
          Initializes velocity with given direction and speed.
Velocity(Position source, Position target)
          Initializes velocity that represents the direction and distance needed to move from the source to the target.
Velocity(Velocity other)
          Initializes velocity with identical values as given Velocity
 
Method Summary
 void Accelerate(double change)
          Change the velocity's current speed, without changing its direction, by the given amount.
 void Accelerate(Value change)
          Change the velocity's current speed, without changing its direction, by the given amount.
 Velocity Add(Velocity other)
           
 Velocity Copy()
          Creates an exact copy of the current velocity.
 Velocity Difference(Velocity other)
           
 boolean equals(java.lang.Object o)
           
 Orientation GetDirection()
           
 Position GetNextPosition(Position current)
          Creates a new GP.Attributes.Position based on moving the given position by the velocity's speed and direction.
 double GetSpeed()
           
 double GetXChange()
           
 double GetYChange()
           
 Velocity Negate()
           
 void SetDirection(double direction)
          Set velocity's current direction in degrees from the positive x axis, without modifing its speed.
 void SetDirection(Orientation direction)
          Set velocity's current direction in degrees from the positive x axis, without modifing its speed.
 void SetSpeed(double speed)
          Set velocity's current speed, without changing its direction.
 void SetSpeed(Value speed)
          Set velocity's current speed, without changing its direction.
 java.lang.String toString()
           
 void Turn(double change)
          Change velocity's current direction in degrees from the positive x axis, without modifing its speed.
 void Turn(Orientation change)
          Change velocity's current direction in degrees from the positive x axis, without modifing its speed.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Velocity

public Velocity()
Initializes velocity with default direction (0 degrees) and speed (1 pixel per move):

Velocity

public Velocity(Orientation direction,
                double speed)
Initializes velocity with given direction and speed.

Velocity

public Velocity(Orientation direction,
                Value speed)
Initializes velocity with given direction and speed.

Velocity

public Velocity(double dx,
                double dy)
Initializes velocity that represents the given change in x and y.

Velocity

public Velocity(Position source,
                Position target)
Initializes velocity that represents the direction and distance needed to move from the source to the target.

Velocity

public Velocity(Velocity other)
Initializes velocity with identical values as given Velocity
Method Detail

Copy

public Velocity Copy()
Creates an exact copy of the current velocity.

GetNextPosition

public Position GetNextPosition(Position current)
Creates a new GP.Attributes.Position based on moving the given position by the velocity's speed and direction.

Add

public Velocity Add(Velocity other)

Difference

public Velocity Difference(Velocity other)

Negate

public Velocity Negate()

GetSpeed

public double GetSpeed()
Returns:
current speed of the velocity in pixels per time step

SetSpeed

public void SetSpeed(double speed)
Set velocity's current speed, without changing its direction.
Parameters:
speed - velocity's new speed

SetSpeed

public void SetSpeed(Value speed)
Set velocity's current speed, without changing its direction.
Parameters:
speed - velocity's new speed

Accelerate

public void Accelerate(double change)
Change the velocity's current speed, without changing its direction, by the given amount.
Parameters:
change - amount to change velocity's speed

Accelerate

public void Accelerate(Value change)
Change the velocity's current speed, without changing its direction, by the given amount.
Parameters:
change - amount to change velocity's speed

GetDirection

public Orientation GetDirection()
Returns:
current direction of the velocity, i.e. its angle in degrees from the positive x axis. (note the positive y axis points down, not up).

SetDirection

public void SetDirection(double direction)
Set velocity's current direction in degrees from the positive x axis, without modifing its speed. Note the positive y axis points down, not up.
Parameters:
direction - new direction of the velocity (in degrees)

SetDirection

public void SetDirection(Orientation direction)
Set velocity's current direction in degrees from the positive x axis, without modifing its speed.
Parameters:
direction - new direction of the velocity

Turn

public void Turn(double change)
Change velocity's current direction in degrees from the positive x axis, without modifing its speed.
Parameters:
change - amount to change direction of the velocity

Turn

public void Turn(Orientation change)
Change velocity's current direction in degrees from the positive x axis, without modifing its speed.
Parameters:
change - amount to change direction of the velocity

GetXChange

public double GetXChange()

GetYChange

public double GetYChange()

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object