aim4.map.lane
Class LaneIM

java.lang.Object
  extended by aim4.map.lane.LaneIM

public class LaneIM
extends Object

The lane and intersection manager relationship.


Constructor Summary
LaneIM(Lane lane)
          Create a lane and intersection manager relationship object.
 
Method Summary
 double distanceFromPrevIntersection(Point2D p)
          Find the distance from a point, projected onto the Lane, to the previous intersection that a vehicle at that position on the Lane would have encountered.
 double distanceToFirstIntersection()
          Get the distance from the start of this Lane to the first IntersectionManager that this Lane, or any Lane it leads into intersects.
 double distanceToNextIntersection(Point2D p)
          Find the distance to the next IntersectionManager a vehicle at the given position will encounter.
 double distanceToNextIntersectionManager(IntersectionManager im)
          Get the distance from the given IntersectionManager to the next one that that this Lane, or any Lane it leads into enters.
 IntersectionManager firstIntersectionManager()
          Get the first IntersectionManager that this Lane, or any Lane it leads into enters.
 Lane laneToFirstIntersection()
          Find the next Lane, including this one, that enters an intersection at any point.
 Lane laneToNextIntersection(Point2D p)
          Find the next Lane, including this one, that will enter an intersection, starting at the point in this Lane nearest the provided point.
 IntersectionManager lastIntersectionManager()
          Get the last IntersectionManager that this Lane, or any Lane that leads into it enters.
 IntersectionManager nextIntersectionManager(IntersectionManager im)
          Get the IntersectionManager that this Lane, or any Lane it leads into enters, after the given IntersectionManager.
 IntersectionManager nextIntersectionManager(Point2D p)
          Find the next IntersectionManager a vehicle at the given position will encounter.
 void registerIntersectionManager(IntersectionManager im)
          Register an IntersectionManager with this Lane.
 double remainingDistanceFromLastIntersection()
          Get the distance from the end of this Lane to the last IntersectionManager that this Lane, or any Lane that leads into it entered.
 double timeToNextIntersectionManager(IntersectionManager im, double maxVelocity)
          Get the approximate time from the given IntersectionManager to the next one that that this Lane, or any Lane it leads into enters, based on distances and speed limits.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LaneIM

public LaneIM(Lane lane)
Create a lane and intersection manager relationship object.

Parameters:
lane - the lane.
Method Detail

registerIntersectionManager

public void registerIntersectionManager(IntersectionManager im)
Register an IntersectionManager with this Lane. If the Lane does not intersect the area controlled by the IntersectionManager, it has no effect. Otherwise, the IntersectionManager is stored and returned under certain circumstances by the nextIntersectionManager method.

Parameters:
im - the IntersectionManager to register

firstIntersectionManager

public IntersectionManager firstIntersectionManager()
Get the first IntersectionManager that this Lane, or any Lane it leads into enters. Recursively searches through all subsequent Lanes.

Returns:
the first IntersectionManager this Lane, or any Lane it leads into enters

distanceToFirstIntersection

public double distanceToFirstIntersection()
Get the distance from the start of this Lane to the first IntersectionManager that this Lane, or any Lane it leads into intersects. Recursively searches through all subsequent Lanes. Returns Double.MAX_VALUE if no such IntersectionManager exists.

Returns:
the distance from the start of this Lane to the first IntersectionManager this Lane, or any lane it leads into intersects, or Double.MAX_VALUE if no such IntersectionManager exists

laneToFirstIntersection

public Lane laneToFirstIntersection()
Find the next Lane, including this one, that enters an intersection at any point.

Returns:
the next Lane, following the chain of Lanes in which this Lane is, that enters an intersection, at any point

lastIntersectionManager

public IntersectionManager lastIntersectionManager()
Get the last IntersectionManager that this Lane, or any Lane that leads into it enters. Recursively searches through all previous Lanes.

Returns:
the last IntersectionManager this Lane, or any Lane that leads into it enters.

remainingDistanceFromLastIntersection

public double remainingDistanceFromLastIntersection()
Get the distance from the end of this Lane to the last IntersectionManager that this Lane, or any Lane that leads into it entered. Recursively searches through all previous Lanes. Returns Double.MAX_VALUE if no such IntersectionManager exists.

Returns:
the distance from the end of this Lane to the last IntersectionManager this Lane, or any lane that leads into it entered, or Double.MAX_VALUE if no such IntersectionManager exists

nextIntersectionManager

public IntersectionManager nextIntersectionManager(Point2D p)
Find the next IntersectionManager a vehicle at the given position will encounter. These are indexed based on how far along the lane the vehicle is, from 0 (at the start) to 1 (at the end).

Parameters:
p - the location of the hypothetical vehicle
Returns:
the next IntersectionManager the vehicle will encounter, or null if none

distanceToNextIntersection

public double distanceToNextIntersection(Point2D p)
Find the distance to the next IntersectionManager a vehicle at the given position will encounter. First projects the point onto the Lane.

Parameters:
p - the current location of the vehicle
Returns:
the distance along the Lane from the point on the Lane nearest to the given point to the next IntersectionManager a vehicle at the given point will encounter; if there is no next intersection, return Double.MAX_VALUE

laneToNextIntersection

public Lane laneToNextIntersection(Point2D p)
Find the next Lane, including this one, that will enter an intersection, starting at the point in this Lane nearest the provided point.

Parameters:
p - the current location of the vehicle
Returns:
the next Lane, following the chain of Lanes in which this Lane is, that will enter an intersection, starting at the point in this Lane nearest the provided point

distanceFromPrevIntersection

public double distanceFromPrevIntersection(Point2D p)
Find the distance from a point, projected onto the Lane, to the previous intersection that a vehicle at that position on the Lane would have encountered.

Parameters:
p - the current location of the vehicle
Returns:
the distance from a point, projected onto the Lane, to the previous intersection that a vehicle at that position on the Lane would have encountered

nextIntersectionManager

public IntersectionManager nextIntersectionManager(IntersectionManager im)
Get the IntersectionManager that this Lane, or any Lane it leads into enters, after the given IntersectionManager.

Parameters:
im - the IntersectionManager to which we would like the successor
Returns:
the IntersectionManager that this Lane, or any Lane it leads into enters, after the given IntersectionManager

distanceToNextIntersectionManager

public double distanceToNextIntersectionManager(IntersectionManager im)
Get the distance from the given IntersectionManager to the next one that that this Lane, or any Lane it leads into enters.

Parameters:
im - the IntersectionManager at which to start
Returns:
the distance, in meters, departing the given IntersectionManager, to reach the next IntersectionManager

timeToNextIntersectionManager

public double timeToNextIntersectionManager(IntersectionManager im,
                                            double maxVelocity)
Get the approximate time from the given IntersectionManager to the next one that that this Lane, or any Lane it leads into enters, based on distances and speed limits.

Parameters:
im - the IntersectionManager at which to start
maxVelocity - the maximum velocity of the vehicle
Returns:
the time, in seconds, that it should take once departing the given IntersectionManager, to reach the next IntersectionManager


Copyright © 2011. All Rights Reserved.