Class MotionUtils

java.lang.Object
  |
  +--MotionUtils

public class MotionUtils
extends java.lang.Object

MotionUtils is a class with a number of static methods for findings distances and direction. All distances are given in absolute values all directions are given in radians where 0 <= r <= 2pi. in terms of the screen, direction looks like this


       pi/2
        |
   pi --x-- 0
        |
      3pi/2
 

Version:
$Id: MotionUtils.java,v 1.10 2001/11/26 02:10:06 srevilak Exp $
Author:
Steve Revilak

Constructor Summary
MotionUtils()
           
 
Method Summary
static double direction(double x1, double y1, double x2, double y2)
          Performs the same function as direction(Point, Point) but the arguments are integer coordinates.
static double direction(HiResPoint a, HiResPoint b)
          Return the direction between the given pair of HiResPoints
static double direction(java.awt.Point a, java.awt.Point b)
          Return the direction from point a to point b.
static double distance(double x1, double y1, double x2, double y2)
          Return the distance between the given pair of coordinates.
static double distance(HiResPoint a, HiResPoint b)
          Return the distance between the given pair of HiRes points.
static double distance(java.awt.Point a, java.awt.Point b)
          Return the distance between the given pair of points.
static HiResPoint move(double magnitude, double direction)
          Given a magnitude and a direction, return a Point whose x and y members are the deltas that would result from moving a distance of magnitude in the given direction.
static double oppositeDirection(double direction)
          Given a direction, return the opposite direction (eg - PI radians the other way).
static double radiansToDegrees(double rad)
          Convert radians to degrees.
static VectorQuantity resultant(double mag1, double d1, double mag2, double d2)
          Given two magnitudes and two direction, return their resultant.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MotionUtils

public MotionUtils()
Method Detail

distance

public static double distance(double x1,
                              double y1,
                              double x2,
                              double y2)
Return the distance between the given pair of coordinates.

distance

public static double distance(java.awt.Point a,
                              java.awt.Point b)
Return the distance between the given pair of points.

distance

public static double distance(HiResPoint a,
                              HiResPoint b)
Return the distance between the given pair of HiRes points.

direction

public static double direction(java.awt.Point a,
                               java.awt.Point b)
Return the direction from point a to point b. As is taken as the origin of travel, so
    a --> b  gives 0 radians
 and
    b <-- a  gives PI radians
 

direction

public static double direction(HiResPoint a,
                               HiResPoint b)
Return the direction between the given pair of HiResPoints

direction

public static double direction(double x1,
                               double y1,
                               double x2,
                               double y2)
Performs the same function as direction(Point, Point) but the arguments are integer coordinates.

move

public static HiResPoint move(double magnitude,
                              double direction)
Given a magnitude and a direction, return a Point whose x and y members are the deltas that would result from moving a distance of magnitude in the given direction.

oppositeDirection

public static double oppositeDirection(double direction)
Given a direction, return the opposite direction (eg - PI radians the other way).

radiansToDegrees

public static double radiansToDegrees(double rad)
Convert radians to degrees. In JDK1.3, we have Math.toDegrees. However, in JDK1.1, we don't. It's easy enough to say r/PI * 180, so we will.
Parameters:
rad - an angle in radians
Returns:
the angle in degrees

resultant

public static VectorQuantity resultant(double mag1,
                                       double d1,
                                       double mag2,
                                       double d2)
Given two magnitudes and two direction, return their resultant.