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

public abstract class AbstractHeadway extends 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-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.

Author:
Alexander Verbraeck, Peter Knoppers, Wouter Schakel
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.opentrafficsim.road.gtu.lane.perception.headway.Headway

    Headway.ObjectType
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
     
    AbstractHeadway(org.djunits.value.vdouble.scalar.Length distance)
    Construct a new Headway information object, for an object ahead of us or behind us.
     
    AbstractHeadway(org.djunits.value.vdouble.scalar.Length overlapFront, org.djunits.value.vdouble.scalar.Length overlap, org.djunits.value.vdouble.scalar.Length overlapRear)
    Construct a new Headway information object, for an object parallel with us.
    protected
    AbstractHeadway(org.djunits.value.vdouble.scalar.Length distance, org.djunits.value.vdouble.scalar.Length overlapFront, org.djunits.value.vdouble.scalar.Length overlap, org.djunits.value.vdouble.scalar.Length overlapRear)
    Construct a new Headway information object, for an object in front, behind, or in parallel with us.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    final org.djunits.value.vdouble.scalar.Length
    Retrieve the strongly typed distance to the other object.
    final org.djunits.value.vdouble.scalar.Length
    Return the (perceived) overlap with the other object.
    final org.djunits.value.vdouble.scalar.Length
    Return the (perceived) front overlap to the other object.
    final org.djunits.value.vdouble.scalar.Length
    Return the (perceived) rear overlap to the other object.
    int
    final boolean
    final boolean
    final boolean

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.opentrafficsim.road.gtu.lane.perception.headway.Headway

    compareTo, getAcceleration, getId, getLength, getObjectType, getSpeed
  • Constructor Details

    • AbstractHeadway

      protected AbstractHeadway(org.djunits.value.vdouble.scalar.Length distance, org.djunits.value.vdouble.scalar.Length overlapFront, org.djunits.value.vdouble.scalar.Length overlap, org.djunits.value.vdouble.scalar.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(org.djunits.value.vdouble.scalar.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(org.djunits.value.vdouble.scalar.Length overlapFront, org.djunits.value.vdouble.scalar.Length overlap, org.djunits.value.vdouble.scalar.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 org.djunits.value.vdouble.scalar.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 org.djunits.value.vdouble.scalar.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 org.djunits.value.vdouble.scalar.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 org.djunits.value.vdouble.scalar.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 Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object