aim4.map.lane
Class LineSegmentLane

java.lang.Object
  extended by aim4.map.lane.AbstractLane
      extended by aim4.map.lane.LineSegmentLane
All Implemented Interfaces:
Lane

public class LineSegmentLane
extends AbstractLane

A lane class that can be represented by a directed line segment.


Constructor Summary
LineSegmentLane(double x1, double y1, double x2, double y2, double width, double speedLimit)
          Constructs a line-segment lane using two sets of coordinates.
LineSegmentLane(Line2D line, double width, double speedLimit)
          Constructs a line-segment lane using a Line.
LineSegmentLane(Point2D p1, Point2D p2, double width, double speedLimit)
          Constructs a line-segment lane using two points.
 
Method Summary
 boolean contains(Point2D pos)
          Whether or not the provided point can be considered "in" this Lane.
 double distanceAlongLane(Point2D pos)
          Get the distance along the Lane from the start of the Lane to the Point in the center of the Lane nearest the given Point.
 Point2D getEndPoint()
          Get the ending point of the Lane.
 double getHeadingAtNormalizedDistance(double normalizedDistance)
          Get the heading of the Lane at a particular normalized distance from the start of the Lane.
 double getInitialHeading()
          Get the heading of this Lane at its starting point.
 Point2D getLeadPoint(Point2D pos, double leadDist)
          /** Get a point further down the Lane from the nearest point to the given position.
 double getLength()
          Get the length of this Lane.
 Point2D getPointAtNormalizedDistance(double normalizedDistance)
          Get a point in the center of the lane at a particular normalized distance from the start of the Lane.
 Shape getShape()
          Get a Shape describing this Lane, including its width.
 Shape getShape(double startFraction, double endFraction)
          Get a Shape describing an interval of this lane, using normalized distances.
 Point2D getStartPoint()
          Get the starting point of the Lane.
 double getTerminalHeading()
          Get the heading of this Lane at its ending point.
 double getWidth()
          Get the width of this Lane, in meters.
 Point2D intersectionPoint(Line2D l)
          The point at which the the given Line intersects the center of this Lane.
 Shape leftBorder()
          Get a Shape representing the left border of this Lane.
 Point2D leftIntersectionPoint(Line2D l)
          The point at which the the given Line intersects the left border of this Lane.
 double nearestDistance(Point2D pos)
          Get the distance from a point to the center of the Lane.
 Point2D nearestPoint(Point2D p)
          Get the point in the center of the Lane nearest to the provided point.
 double normalizedDistance(double distance)
          Get the normalized distance at the distance from the starting point.
 double normalizedDistanceAlongLane(Point2D pos)
          Get the normalized distance to the point in the center of the lane nearest the provided point.
 double remainingDistanceAlongLane(Point2D pos)
          Get the amount of distance left in this Lane from the point on the Lane nearest to the given point.
 Shape rightBorder()
          Get a Shape representing the right border of this Lane.
 Point2D rightIntersectionPoint(Line2D l)
          The point at which the the given Line intersects the right border of this Lane.
 
Methods inherited from class aim4.map.lane.AbstractLane
getId, getLaneIM, getLeftNeighbor, getNextLane, getPrevLane, getRightNeighbor, getSpeedLimit, hasLeftNeighbor, hasNextLane, hasPrevLane, hasRightNeighbor, setId, setLeftNeighbor, setNextLane, setPrevLane, setRightNeighbor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LineSegmentLane

public LineSegmentLane(Line2D line,
                       double width,
                       double speedLimit)
Constructs a line-segment lane using a Line.

Parameters:
line - the line segment representing the center of the Lane
width - the width of the Lane, in meters
speedLimit - the speed limit of the Lane, in meters per second

LineSegmentLane

public LineSegmentLane(Point2D p1,
                       Point2D p2,
                       double width,
                       double speedLimit)
Constructs a line-segment lane using two points.

Parameters:
p1 - the starting Point of the Lane
p2 - the ending Point of the Lane
width - the width of the Lane, in meters
speedLimit - the speed limit of the Lane, in meters per second

LineSegmentLane

public LineSegmentLane(double x1,
                       double y1,
                       double x2,
                       double y2,
                       double width,
                       double speedLimit)
Constructs a line-segment lane using two sets of coordinates.

Parameters:
x1 - the x coordinate of the starting point of the Lane
y1 - the y coordinate of the starting point of the Lane
x2 - the x coordinate of the ending point of the Lane
y2 - the y coordinate of the ending point of the Lane
width - the width of the Lane, in meters
speedLimit - the speed limit of the Lane, in meters per second
Method Detail

getLength

public double getLength()
Get the length of this Lane.

Specified by:
getLength in interface Lane
Specified by:
getLength in class AbstractLane
Returns:
the length of this Lane, in meters

getStartPoint

public Point2D getStartPoint()
Get the starting point of the Lane.

Specified by:
getStartPoint in interface Lane
Specified by:
getStartPoint in class AbstractLane
Returns:
the starting point of the Lane

getEndPoint

public Point2D getEndPoint()
Get the ending point of the Lane.

Specified by:
getEndPoint in interface Lane
Specified by:
getEndPoint in class AbstractLane
Returns:
the ending point of the Lane

getPointAtNormalizedDistance

public Point2D getPointAtNormalizedDistance(double normalizedDistance)
Get a point in the center of the lane at a particular normalized distance from the start of the Lane.

Specified by:
getPointAtNormalizedDistance in interface Lane
Specified by:
getPointAtNormalizedDistance in class AbstractLane
Parameters:
normalizedDistance - the normalized distance (between 0 and 1) from the start of the Lane
Returns:
the point in the center of the Lane at the given normalized distance

nearestPoint

public Point2D nearestPoint(Point2D p)
Get the point in the center of the Lane nearest to the provided point.

Specified by:
nearestPoint in interface Lane
Specified by:
nearestPoint in class AbstractLane
Parameters:
p - the point to which the nearest point in the center of the Lane should be found
Returns:
the point in the center of the Lane nearest to the given point

nearestDistance

public double nearestDistance(Point2D pos)
Get the distance from a point to the center of the Lane.

Specified by:
nearestDistance in interface Lane
Specified by:
nearestDistance in class AbstractLane
Parameters:
pos - the point from which to find the distance to the Lane
Returns:
the distance from the point to the center of the Lane

getLeadPoint

public Point2D getLeadPoint(Point2D pos,
                            double leadDist)
/** Get a point further down the Lane from the nearest point to the given position.

Specified by:
getLeadPoint in interface Lane
Specified by:
getLeadPoint in class AbstractLane
Parameters:
pos - the position from which to calculate the nearest point in the Lane
leadDist - the lead distance further down the Lane, in meters
Returns:
a point leadDist further down the Lane from the closest point in the Lane to pos

distanceAlongLane

public double distanceAlongLane(Point2D pos)
Get the distance along the Lane from the start of the Lane to the Point in the center of the Lane nearest the given Point.

Specified by:
distanceAlongLane in interface Lane
Specified by:
distanceAlongLane in class AbstractLane
Parameters:
pos - the point to which to find the distance along the Lane
Returns:
the distance along the Lane from the start of the Lane to the Point in the center of the Lane nearest the given Point

remainingDistanceAlongLane

public double remainingDistanceAlongLane(Point2D pos)
Get the amount of distance left in this Lane from the point on the Lane nearest to the given point. This is used so a vehicle can determine how much of the Lane is left, given its current position.

Specified by:
remainingDistanceAlongLane in interface Lane
Specified by:
remainingDistanceAlongLane in class AbstractLane
Parameters:
pos - the point nearest which to find the distance to the end of the Lane
Returns:
the distance from the nearest point on the Lane to the given point to the end of the Lane.

normalizedDistanceAlongLane

public double normalizedDistanceAlongLane(Point2D pos)
Get the normalized distance to the point in the center of the lane nearest the provided point. That is, given a point, find the nearest point in the center of the lane, then find the proportion of the way from the start point of the lane to the endpoint of the lane that that point is.

Specified by:
normalizedDistanceAlongLane in interface Lane
Specified by:
normalizedDistanceAlongLane in class AbstractLane
Parameters:
pos - the point near to which to find the normalized distance
Returns:
the normalized distance to the point in the center of the lane nearest to the given point

normalizedDistance

public double normalizedDistance(double distance)
Get the normalized distance at the distance from the starting point.

Parameters:
distance - the distance along the center of the lane.
Returns:
the normalized distance along the center of the lane.

getInitialHeading

public double getInitialHeading()
Get the heading of this Lane at its starting point.

Specified by:
getInitialHeading in interface Lane
Specified by:
getInitialHeading in class AbstractLane
Returns:
the initial heading of the Lane, in radians

getTerminalHeading

public double getTerminalHeading()
Get the heading of this Lane at its ending point.

Specified by:
getTerminalHeading in interface Lane
Specified by:
getTerminalHeading in class AbstractLane
Returns:
the terminal heading of the Lane, in radians

getHeadingAtNormalizedDistance

public double getHeadingAtNormalizedDistance(double normalizedDistance)
Get the heading of the Lane at a particular normalized distance from the start of the Lane.

Specified by:
getHeadingAtNormalizedDistance in interface Lane
Specified by:
getHeadingAtNormalizedDistance in class AbstractLane
Parameters:
normalizedDistance - the normalized distance (between 0 and 1) from the start of the Lane
Returns:
the heading of the lane at the given normalized distance

intersectionPoint

public Point2D intersectionPoint(Line2D l)
The point at which the the given Line intersects the center of this Lane.

Specified by:
intersectionPoint in interface Lane
Specified by:
intersectionPoint in class AbstractLane
Parameters:
l - the Line with which to find the intersection
Returns:
the point at which the given Line intersects the center of this Lane, or null if it doesn't intersect

getWidth

public double getWidth()
Get the width of this Lane, in meters.

Specified by:
getWidth in interface Lane
Specified by:
getWidth in class AbstractLane
Returns:
the width of this Lane, in meters

getShape

public Shape getShape()
Get a Shape describing this Lane, including its width.

Specified by:
getShape in interface Lane
Specified by:
getShape in class AbstractLane
Returns:
a Shape describing this Lane

getShape

public Shape getShape(double startFraction,
                      double endFraction)
Get a Shape describing an interval of this lane, using normalized distances.

Specified by:
getShape in interface Lane
Specified by:
getShape in class AbstractLane
Parameters:
startFraction - the normalized distance from the start of the lane to the start of the segment which the Shape represents
endFraction - the normalized distance from the start of the lane to the end of the segment which the Shape represents
Returns:
a Shape describing the segment

contains

public boolean contains(Point2D pos)
Whether or not the provided point can be considered "in" this Lane. This is equivalent to determining whether the distance from the point to the Lane is less than half of the width of the Lane.

Specified by:
contains in interface Lane
Specified by:
contains in class AbstractLane
Parameters:
pos - the point to check
Returns:
whether or not the point is in the Lane

leftBorder

public Shape leftBorder()
Get a Shape representing the left border of this Lane.

Specified by:
leftBorder in interface Lane
Specified by:
leftBorder in class AbstractLane
Returns:
a Shape representing the left border of this Lane

rightBorder

public Shape rightBorder()
Get a Shape representing the right border of this Lane.

Specified by:
rightBorder in interface Lane
Specified by:
rightBorder in class AbstractLane
Returns:
a Shape representing the right border of this Lane

leftIntersectionPoint

public Point2D leftIntersectionPoint(Line2D l)
The point at which the the given Line intersects the left border of this Lane.

Specified by:
leftIntersectionPoint in interface Lane
Specified by:
leftIntersectionPoint in class AbstractLane
Parameters:
l - the Line with which to find the intersection
Returns:
the point at which the given Line intersects the left border of this Lane, or null if it doesn't intersect

rightIntersectionPoint

public Point2D rightIntersectionPoint(Line2D l)
The point at which the the given Line intersects the right border of this Lane.

Specified by:
rightIntersectionPoint in interface Lane
Specified by:
rightIntersectionPoint in class AbstractLane
Parameters:
l - the Line with which to find the intersection
Returns:
the point at which the given Line intersects the right border of this Lane, or null if it doesn't intersect


Copyright © 2011. All Rights Reserved.