simulator.model
Class SMVector

java.lang.Object
  extended by simulator.model.SMVector
All Implemented Interfaces:
CartesianVect, PolarVect

public class SMVector
extends java.lang.Object
implements PolarVect, CartesianVect

Vector manipulation class that implements both PolarVect and CartesianVect interfaces.

Version:
$Revision: 385 $ $Date: 2008-03-11 10:10:33 -0230 (Tue, 11 Mar 2008) $

Method Summary
 double getAngle()
           
 double getMagnitude()
           
 double getX()
          Get the x coordinate.
 double getY()
          Get the y coordinate.
static SMVector makeCartesian(double x, double y)
          Construct a vector from cartesian coordinates
static SMVector makePolar(double mag, double ang)
          Construct a vector from polar coordinates
 void setCartesian(double x, double y)
          Set the value of this in Cartesian form
 void setPolar(double mag, double ang)
          Set the value of this in Polar form
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

makePolar

public static SMVector makePolar(double mag,
                                 double ang)
Construct a vector from polar coordinates

Parameters:
mag - magnitude 0 <= mag
ang - angle in degrees from the positive x axis. 0 <= ang < 360.
Returns:
new vector

makeCartesian

public static SMVector makeCartesian(double x,
                                     double y)
Construct a vector from cartesian coordinates

Parameters:
x - horizontal component 0 is to the left.
y - vertical component 0 is to the bottom
Returns:
New vector

getAngle

public double getAngle()
Specified by:
getAngle in interface PolarVect
Returns:
angle in degrees between 0 and 360

getMagnitude

public double getMagnitude()
Specified by:
getMagnitude in interface PolarVect
Returns:
magnitude

getX

public double getX()
Description copied from interface: CartesianVect
Get the x coordinate.

Specified by:
getX in interface CartesianVect
Returns:
x-axis value in meters or metres/sec. 0 is to the left.

getY

public double getY()
Description copied from interface: CartesianVect
Get the y coordinate.

Specified by:
getY in interface CartesianVect
Returns:
y-axis value in meters or metres/sec. 0 is to the bottom.

setCartesian

public void setCartesian(double x,
                         double y)
Set the value of this in Cartesian form

Parameters:
x - horizontal coord. 0 is to the left
y - vertical coord. 0 is to the top

setPolar

public void setPolar(double mag,
                     double ang)
Set the value of this in Polar form

Parameters:
mag - magnitude. 0 <= mag
ang - angle in degrees from positive x axis. 0 <= ang < 360