game.physics
Class Vector2D

java.lang.Object
  extended byjava.awt.geom.Point2D
      extended bygame.physics.Vector2D
All Implemented Interfaces:
java.lang.Cloneable

public class Vector2D
extends java.awt.geom.Point2D


Nested Class Summary
 
Nested classes inherited from class java.awt.geom.Point2D
java.awt.geom.Point2D.Double, java.awt.geom.Point2D.Float
 
Constructor Summary
Vector2D()
           
Vector2D(double x, double y)
           
Vector2D(Vector2D vector)
           
 
Method Summary
 void add(double scalar, Vector2D v)
          Adds a scalar multiple of another vector to this one.
 void add(Vector2D v)
          Adds another vector to this one.
 double getDotProduct(Vector2D v)
           
 double getMagnitude()
           
 double getX()
           
 double getY()
           
 void multiply(double scalar)
          Multiplies this vector by a scalar.
 void setLocation(double x, double y)
           
 void setMagnitude(double m)
           
 void subtract(double scalar, Vector2D v)
          Subtracts a scalar multiple of another vector from this one.
 void subtract(Vector2D v)
          Subtracts another vector from this one.
 java.lang.String toString()
           
 void zero()
          Sets X and Y to 0.
 
Methods inherited from class java.awt.geom.Point2D
clone, distance, distance, distance, distanceSq, distanceSq, distanceSq, equals, hashCode, setLocation
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Vector2D

public Vector2D()

Vector2D

public Vector2D(Vector2D vector)

Vector2D

public Vector2D(double x,
                double y)
Method Detail

getX

public double getX()
See Also:
Point2D.getX()

getY

public double getY()
See Also:
Point2D.getY()

setLocation

public void setLocation(double x,
                        double y)
See Also:
Point2D.setLocation(double, double)

zero

public void zero()
Sets X and Y to 0.


add

public void add(Vector2D v)
Adds another vector to this one.

Parameters:
v - the vector to add

add

public void add(double scalar,
                Vector2D v)
Adds a scalar multiple of another vector to this one.

Parameters:
scalar - the factor to multiply v by
v - the vector to add

subtract

public void subtract(Vector2D v)
Subtracts another vector from this one.

Parameters:
v - the vector to subtract

subtract

public void subtract(double scalar,
                     Vector2D v)
Subtracts a scalar multiple of another vector from this one.

Parameters:
scalar - the factor to multiply y by
v - the vector to subtract

multiply

public void multiply(double scalar)
Multiplies this vector by a scalar.

Parameters:
scalar - the factor to multiply by

getDotProduct

public double getDotProduct(Vector2D v)

getMagnitude

public double getMagnitude()

setMagnitude

public void setMagnitude(double m)

toString

public java.lang.String toString()
See Also:
Object.toString()