uk.ac.lancs.relate.trigger
Class Trackable

java.lang.Object
  extended by uk.ac.lancs.relate.trigger.Trackable
Direct Known Subclasses:
TrackableDevice

public class Trackable
extends java.lang.Object

This class represents a trackable user, device or physical object.

Author:
Sara Streng and Dominique Guinard
Personal Homepage

Constructor Summary
Trackable(java.lang.String id, Location p, Orientation o, Motion m)
          Creates a new Trackable with a unique id, location, orientation and motion
 
Method Summary
 double getDirectionTo(Location p)
          Returns the direction in which a second location is from this point of view (in degrees 0 - 360).
 double getDistanceTo(Location p)
          Returns the distance from this location to a given second location.
 java.lang.String getId()
          Returns the unique id.
 Location getLocation()
          Returns the current location.
 Motion getMotion()
          Returns the current motion.
 Orientation getOrientation()
          Returns the current orientation.
 boolean hasBackTo(Location p)
          Returns true if the Trackable is oriented towards a given location, meaning the angle between the orientation and the direction in which the target is located is less than 20 degrees.
 boolean isCloserThan(double limit, Location p)
          Returns true if the distance to a given second location is closer than a given limit.
 boolean isFacing(Location p)
          Returns true if the Trackable is oriented towards a given location, meaning the angle between the orientation and the direction in which the target is located is less than 20 degrees.
 boolean isLeftOf(Location p)
          Returns true if the angle between the Trackable's orientation and the direction in which the target is located is between 45 and 135 degrees and the target is to the left from the Trackable's point of view.
 boolean isMoving()
          Returns true if the velocity is not null.
 boolean isMovingAway(Location p)
          Returns true if the Trackable is moving towards a given location, meaning the angle between the direction in which the Trackable is moving and the direction in which the target is located is higher than 90 degrees.
 boolean isMovingTowards(Location p)
          Returns true if the Trackable is moving towards a given location, meaning the angle between the direction in which the Trackable is moving and the direction in which the target is located is less than 20 degrees.
 boolean isRightOf(Location p)
          Returns true if the angle between the Trackable's orientation and the direction in which the target is located is between 45 and 135 degrees and the target is to the right from the Trackable's point of view.
 void setLocation(Location location)
          Sets the current location.
 void setMotion(Motion motion)
          Sets the current motion.
 void setOrientation(Orientation orientation)
          Sets the current orientation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Trackable

public Trackable(java.lang.String id,
                 Location p,
                 Orientation o,
                 Motion m)
Creates a new Trackable with a unique id, location, orientation and motion

Parameters:
id - unique id
p - location
o - orientation
m - motion
Method Detail

getId

public java.lang.String getId()
Returns the unique id.

Returns:
unique id

getMotion

public Motion getMotion()
Returns the current motion.

Returns:
motion

setMotion

public void setMotion(Motion motion)
Sets the current motion.

Parameters:
motion - motion

getOrientation

public Orientation getOrientation()
Returns the current orientation.

Returns:
orientation

setOrientation

public void setOrientation(Orientation orientation)
Sets the current orientation.

Parameters:
orientation - orientation

getLocation

public Location getLocation()
Returns the current location.

Returns:
location

setLocation

public void setLocation(Location location)
Sets the current location.

Parameters:
location - location

getDistanceTo

public double getDistanceTo(Location p)
Returns the distance from this location to a given second location.

Parameters:
p - second location
Returns:
distance

getDirectionTo

public double getDirectionTo(Location p)
Returns the direction in which a second location is from this point of view (in degrees 0 - 360).

Parameters:
p - second location
Returns:
degree

isCloserThan

public boolean isCloserThan(double limit,
                            Location p)
Returns true if the distance to a given second location is closer than a given limit.

Parameters:
limit - limit
p - second location
Returns:
true if a location is closer than a given limit

isFacing

public boolean isFacing(Location p)
Returns true if the Trackable is oriented towards a given location, meaning the angle between the orientation and the direction in which the target is located is less than 20 degrees.

Parameters:
p - target location
Returns:
true if deviance is less than 20 degrees

hasBackTo

public boolean hasBackTo(Location p)
Returns true if the Trackable is oriented towards a given location, meaning the angle between the orientation and the direction in which the target is located is less than 20 degrees.

Parameters:
p - target location
Returns:
true if deviance is less than 20 degrees

isRightOf

public boolean isRightOf(Location p)
Returns true if the angle between the Trackable's orientation and the direction in which the target is located is between 45 and 135 degrees and the target is to the right from the Trackable's point of view.

Parameters:
p - target location
Returns:
true if the target is to the right

isLeftOf

public boolean isLeftOf(Location p)
Returns true if the angle between the Trackable's orientation and the direction in which the target is located is between 45 and 135 degrees and the target is to the left from the Trackable's point of view.

Parameters:
p - target location
Returns:
true if the target is to the right

isMoving

public boolean isMoving()
Returns true if the velocity is not null.

Returns:
true if the velocity is not null

isMovingTowards

public boolean isMovingTowards(Location p)
Returns true if the Trackable is moving towards a given location, meaning the angle between the direction in which the Trackable is moving and the direction in which the target is located is less than 20 degrees.

Parameters:
p - target location
Returns:
true if deviance is less than 20 degrees

isMovingAway

public boolean isMovingAway(Location p)
Returns true if the Trackable is moving towards a given location, meaning the angle between the direction in which the Trackable is moving and the direction in which the target is located is higher than 90 degrees.

Parameters:
p - target location
Returns:
true if deviance is higher than 90 degrees