Class AbstractHeadway
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
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
ModifierConstructorDescriptionAbstractHeadway
(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 TypeMethodDescriptionboolean
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
hashCode()
final boolean
isAhead()
final boolean
isBehind()
final boolean
toString()
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 objectoverlapFront
- Length; the front-front distance to the other objectoverlap
- Length; the 'center' overlap with the other objectoverlapRear
- Length; the rear-rear distance to the other object- Throws:
GtuException
- when id is null, or parameters are inconsistent
-
AbstractHeadway
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 interfaceHeadway
- 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 interfaceHeadway
- 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 interfaceHeadway
- 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 interfaceHeadway
- Returns:
- Length, the (perceived) overlap with the other object or null if there is no overlap.
-
isAhead
public final boolean isAhead() -
isBehind
public final boolean isBehind() -
isParallel
public final boolean isParallel()- Specified by:
isParallel
in interfaceHeadway
- Returns:
- whether the other object is parallel the reference object.
-
hashCode
public int hashCode() -
equals
-
toString
-