simuLCS
Class Vector2D

java.lang.Object
  extended bysimuLCS.Vector2D

public class Vector2D
extends java.lang.Object

Handles all the functions for 2D Vectors.

Author:
Benoit

Field Summary
private  double x
           
private  double y
           
 
Constructor Summary
Vector2D()
          Creates a vector (0,0)
Vector2D(double xp, double yp)
          Creates a vector (xp,yp)
Vector2D(java.awt.geom.Point2D p)
          Creates a vector between (0,0) and the given point
Vector2D(java.awt.geom.Point2D p1, java.awt.geom.Point2D p2)
          Creates the vector between two given points
Vector2D(Vector2D v)
          Creates a clone of a given vector
 
Method Summary
 void add(Vector2D v)
          Add the given vector to this vector (it modifies the vector)
static Vector2D getCorrectedVector(Vector2D movVector, Arena a, Entity me, java.awt.Graphics2D g)
          Correct the vector so that it doesn't bring the Entity outside the Arena.
 double getNorm()
          Get the norm of the Vector
 Vector2D getNormalLeft()
          Get a perpendicular vector, on the left
 double getX()
           
 double getY()
           
 void multiplyByConstant(double d)
          Change the scale of the vector by multiplying its coordinates by a contant
 void opposite()
          Change the vector into its opposite
 void paint(java.awt.geom.Point2D p, java.awt.Graphics2D g, java.awt.Color c)
          Paints the vector (useful for debugging)
 void setUnitVector(java.awt.geom.Point2D p1, java.awt.geom.Point2D p2)
          Set the Vector to the unit vector between the two points the previous values of the Vector are lost.
 void setX(double d)
           
 void setY(double d)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

x

private double x

y

private double y
Constructor Detail

Vector2D

public Vector2D()
Creates a vector (0,0)


Vector2D

public Vector2D(double xp,
                double yp)
Creates a vector (xp,yp)

Parameters:
xp -
yp -

Vector2D

public Vector2D(java.awt.geom.Point2D p)
Creates a vector between (0,0) and the given point

Parameters:
p -

Vector2D

public Vector2D(java.awt.geom.Point2D p1,
                java.awt.geom.Point2D p2)
Creates the vector between two given points

Parameters:
p1 -
p2 -

Vector2D

public Vector2D(Vector2D v)
Creates a clone of a given vector

Parameters:
v -
Method Detail

add

public void add(Vector2D v)
Add the given vector to this vector (it modifies the vector)

Parameters:
v -

opposite

public void opposite()
Change the vector into its opposite


multiplyByConstant

public void multiplyByConstant(double d)
Change the scale of the vector by multiplying its coordinates by a contant

Parameters:
d -

setUnitVector

public void setUnitVector(java.awt.geom.Point2D p1,
                          java.awt.geom.Point2D p2)
Set the Vector to the unit vector between the two points the previous values of the Vector are lost.

Parameters:
p1 -
p2 -

getNorm

public double getNorm()
Get the norm of the Vector

Returns:

getX

public double getX()
Returns:

getY

public double getY()
Returns:

setX

public void setX(double d)
Parameters:
d -

setY

public void setY(double d)
Parameters:
d -

toString

public java.lang.String toString()

paint

public void paint(java.awt.geom.Point2D p,
                  java.awt.Graphics2D g,
                  java.awt.Color c)
Paints the vector (useful for debugging)

Parameters:
p -
g -
c -

getNormalLeft

public Vector2D getNormalLeft()
Get a perpendicular vector, on the left

Returns:

getCorrectedVector

public static Vector2D getCorrectedVector(Vector2D movVector,
                                          Arena a,
                                          Entity me,
                                          java.awt.Graphics2D g)
Correct the vector so that it doesn't bring the Entity outside the Arena.

Parameters:
a -
me -
Returns: