|
Autopysta
|
Represents the geometry of a highway segment in the simulation. More...
#include <geometry.h>
Public Member Functions | |
| geometry (double _length, int _lanes, double _merge, double _diverge) | |
Constructs a geometry object with specified physical properties. | |
| geometry (double length, int lanes) | |
Constructs a geometry object with minimal properties (no ramps). | |
| double | length () |
| Returns the total length of the highway segment. | |
| int | lanes () |
| Returns the number of lanes on the highway. | |
| bool | can_change_left (point *p) |
| Checks if a vehicle can change lanes to the left. | |
| bool | can_change_right (point *p) |
| Checks if a vehicle can change lanes to the right. | |
| bool | has_merge () |
| Checks if the highway segment has an on-ramp (merge). | |
| double | merge () |
| Returns the position where the on-ramp ends. | |
| bool | has_diverge () |
| Checks if the highway segment has an off-ramp (diverge). | |
Represents the geometry of a highway segment in the simulation.
The geometry class defines the physical characteristics of the highway, including its length, number of lanes, the position of on/off ramps, and constraints for lane-changing maneuvers.
| Geometry::geometry::geometry | ( | double | _length, |
| int | _lanes, | ||
| double | _merge, | ||
| double | _diverge ) |
Constructs a geometry object with specified physical properties.
| _length | Length of the highway segment in meters. |
| _lanes | Number of lanes (excluding on/off-ramps). |
| _merge | Position where the on-ramp ends (0 for no on-ramp). |
| _diverge | Position where the off-ramp starts (>= _length for no off-ramp). |
| Exception | if any of the input parameters are invalid. |
|
inline |
Constructs a geometry object with minimal properties (no ramps).
| length | Length of the highway segment in meters. |
| lanes | Number of lanes. |
| bool Geometry::geometry::can_change_left | ( | point * | p | ) |
Checks if a vehicle can change lanes to the left.
| p | A point representing the vehicle's current position. |
true if a left lane change is allowed, false otherwise. | bool Geometry::geometry::can_change_right | ( | point * | p | ) |
Checks if a vehicle can change lanes to the right.
| p | A point representing the vehicle's current position. |
true if a right lane change is allowed, false otherwise. | bool Geometry::geometry::has_diverge | ( | ) |
Checks if the highway segment has an off-ramp (diverge).
true if there is an off-ramp, false otherwise. | bool Geometry::geometry::has_merge | ( | ) |
Checks if the highway segment has an on-ramp (merge).
true if there is an on-ramp, false otherwise. | int Geometry::geometry::lanes | ( | ) |
Returns the number of lanes on the highway.
| double Geometry::geometry::length | ( | ) |
Returns the total length of the highway segment.
| double Geometry::geometry::merge | ( | ) |
Returns the position where the on-ramp ends.