jist.swans.misc
Class Location

java.lang.Object
  extended by jist.swans.misc.Location
All Implemented Interfaces:
java.lang.Cloneable, JistAPI.Timeless
Direct Known Subclasses:
Location.Location2D, Location.Location3D

public abstract class Location
extends java.lang.Object
implements JistAPI.Timeless, java.lang.Cloneable

Location (of a node).

Since:
SWANS1.0
Version:
$Id: Location.java,v 1.12 2004/04/06 16:07:48 barr Exp $
Author:
Rimon Barr <barr+jist@cs.cornell.edu>

Nested Class Summary
static class Location.Location2D
          A planar location implementation.
static class Location.Location3D
          A three-dimensional location implementation.
 
Constructor Summary
Location()
           
 
Method Summary
abstract  void add(Location l)
          Vector addition of locations...
abstract  float distance(Location l)
          Compute distance between two locations.
abstract  float distanceSqr(Location l)
          Compute distance squared between two locations.
 Location getClone()
          Return clone of location object.
abstract  float getHeight()
          Return height of location.
abstract  float getX()
          Return X-coordinate of location.
abstract  float getY()
          Return Y-coordinate of location.
abstract  boolean inside(Location bounds)
          Determine whether point is inside bounds.
abstract  boolean inside(Location min, Location max)
          Determine whether points is inside bounds.
static Location parse(java.lang.String s)
          Parse string into 2d or 3d Location object.
abstract  Location step(Location l, int steps)
          Divide (scale) vector from current to second location into a number of equal step (displacement) vectors.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Location

public Location()
Method Detail

getX

public abstract float getX()
Return X-coordinate of location.

Returns:
x-coordinate of location

getY

public abstract float getY()
Return Y-coordinate of location.

Returns:
y-coordinate of location

getHeight

public abstract float getHeight()
Return height of location.

Returns:
height of location

distance

public abstract float distance(Location l)
Compute distance between two locations.

Parameters:
l - second location
Returns:
distance between current and second location

distanceSqr

public abstract float distanceSqr(Location l)
Compute distance squared between two locations.

Parameters:
l - second location
Returns:
distance squared between current and second location

step

public abstract Location step(Location l,
                              int steps)
Divide (scale) vector from current to second location into a number of equal step (displacement) vectors.

Parameters:
l - destination location
steps - number of steps to destination
Returns:
step displacement vector

inside

public abstract boolean inside(Location bounds)
Determine whether point is inside bounds.

Parameters:
bounds - bounds to test again
Returns:
whether point within bounds

inside

public abstract boolean inside(Location min,
                               Location max)
Determine whether points is inside bounds.

Parameters:
min - lower left bound
max - upper right bound
Returns:
whether point within bounds

add

public abstract void add(Location l)
Vector addition of locations... Be careful! This method mutates the current object.

Parameters:
l - second location / displacement

getClone

public Location getClone()
Return clone of location object.

Returns:
clone of location object

parse

public static Location parse(java.lang.String s)
Parse string into 2d or 3d Location object.

Parameters:
s - string to be parsed: format = x,y[,h]
Returns:
string parsed into Location object