Class AbstractHeadway

java.lang.Object
org.opentrafficsim.road.gtu.lane.perception.headway.AbstractHeadway
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<Headway>, Identifiable, PerceivedObject, Headway
Direct Known Subclasses:
AbstractHeadwayCopy, CarFollowingUtil.CarFollowingHeadway, HeadwayGTUReal

public abstract class AbstractHeadway
extends java.lang.Object
implements Headway
Super class for non-delayed and non-erroneous perception. Sub classes should wrap the actual simulation object to obtain information. One exception to this is AbstractHeadwayCopy (and all it's sub classes), which contains such information directly, and is a super class for delayed and/or erroneous perception.

Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.

Version:
$Revision$, $LastChangedDate$, by $Author$, initial version 24 mrt. 2017
Author:
Alexander Verbraeck, Peter Knoppers, Wouter Schakel
See Also:
Serialized Form
  • Constructor Details

    • AbstractHeadway

      protected AbstractHeadway​(Length distance, Length overlapFront, Length overlap, Length overlapRear) throws GTUException
      Construct a new Headway information object, for an object in front, behind, or in parallel with us.
      Parameters:
      distance - Length; the distance to the other object
      overlapFront - Length; the front-front distance to the other object
      overlap - Length; the 'center' overlap with the other object
      overlapRear - Length; the rear-rear distance to the other object
      Throws:
      GTUException - when id is null, or parameters are inconsistent
    • AbstractHeadway

      public AbstractHeadway​(Length distance) throws GTUException
      Construct a new Headway information object, for an object ahead of us or behind us.
      Parameters:
      distance - the distance to the other object; if this constructor is used, distance cannot be null.
      Throws:
      GTUException - when id is null, or parameters are inconsistent
    • AbstractHeadway

      public AbstractHeadway​(Length overlapFront, Length overlap, Length overlapRear) throws GTUException
      Construct a new Headway information object, for an object parallel with us.
      Parameters:
      overlapFront - the front-front distance to the other object; if this constructor is used, this value cannot be null.
      overlap - the 'center' overlap with the other object; if this constructor is used, this value cannot be null.
      overlapRear - the rear-rear distance to the other object; if this constructor is used, this value cannot be null.
      Throws:
      GTUException - when id is null, or parameters are inconsistent
  • Method Details

    • getDistance

      public final Length getDistance()
      Retrieve the strongly typed distance to the other object.
      Specified by:
      getDistance in interface Headway
      Returns:
      Length; the distance to the object, return value null indicates that the other object is parallel to the reference object
    • getOverlapFront

      public final Length getOverlapFront()
      Return the (perceived) front overlap to the other object. This value should be null if there is no overlap. In the figure for two GTUs below, it is distance c, positive for GTU1, negative for GTU2.
       ----------
       |  GTU 1 |          ----->
       ----------
            ---------------
            |    GTU 2    |          ----->
            ---------------
       | a  | b |     c   |
       
      Specified by:
      getOverlapFront in interface Headway
      Returns:
      Length; the (perceived) front overlap to the other object or null if there is no overlap.
    • getOverlapRear

      public final Length getOverlapRear()
      Return the (perceived) rear overlap to the other object. This value should be null if there is no overlap.In the figure below for two GTUs, it is distance a, positive for GTU1, negative for GTU2.
       ----------
       |  GTU 1 |          ----->
       ----------
            ---------------
            |    GTU 2    |          ----->
            ---------------
       | a  | b |     c   |
       
      Specified by:
      getOverlapRear in interface Headway
      Returns:
      Length; the (perceived) rear overlap to the other object or null if there is no overlap.
    • getOverlap

      public final Length getOverlap()
      Return the (perceived) overlap with the other object. This value should be null if there is no overlap. In the figure below for two GTUs, it is distance b, positive for GTU1 and GTU2.
       ----------
       |  GTU 1 |          ----->
       ----------
            ---------------
            |    GTU 2    |          ----->
            ---------------
       | a  | b |     c   |
       
      Specified by:
      getOverlap in interface Headway
      Returns:
      Length, the (perceived) overlap with the other object or null if there is no overlap.
    • isAhead

      public final boolean isAhead()
      Specified by:
      isAhead in interface Headway
      Returns:
      whether the other object is in front of the reference object.
    • isBehind

      public final boolean isBehind()
      Specified by:
      isBehind in interface Headway
      Returns:
      whether the other object is behind the reference object.
    • isParallel

      public final boolean isParallel()
      Specified by:
      isParallel in interface Headway
      Returns:
      whether the other object is parallel the reference object.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class java.lang.Object
    • equals

      public boolean equals​(java.lang.Object obj)
      Overrides:
      equals in class java.lang.Object
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object