Autopysta
Loading...
Searching...
No Matches
Geometry::geometry Class Reference

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).
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ geometry() [1/2]

Geometry::geometry::geometry ( double _length,
int _lanes,
double _merge,
double _diverge )

Constructs a geometry object with specified physical properties.

Parameters
_lengthLength of the highway segment in meters.
_lanesNumber of lanes (excluding on/off-ramps).
_mergePosition where the on-ramp ends (0 for no on-ramp).
_divergePosition where the off-ramp starts (>= _length for no off-ramp).
Exceptions
Exceptionif any of the input parameters are invalid.

◆ geometry() [2/2]

Geometry::geometry::geometry ( double length,
int lanes )
inline

Constructs a geometry object with minimal properties (no ramps).

Parameters
lengthLength of the highway segment in meters.
lanesNumber of lanes.

Member Function Documentation

◆ can_change_left()

bool Geometry::geometry::can_change_left ( point * p)

Checks if a vehicle can change lanes to the left.

Parameters
pA point representing the vehicle's current position.
Returns
true if a left lane change is allowed, false otherwise.

◆ can_change_right()

bool Geometry::geometry::can_change_right ( point * p)

Checks if a vehicle can change lanes to the right.

Parameters
pA point representing the vehicle's current position.
Returns
true if a right lane change is allowed, false otherwise.

◆ has_diverge()

bool Geometry::geometry::has_diverge ( )

Checks if the highway segment has an off-ramp (diverge).

Returns
true if there is an off-ramp, false otherwise.

◆ has_merge()

bool Geometry::geometry::has_merge ( )

Checks if the highway segment has an on-ramp (merge).

Returns
true if there is an on-ramp, false otherwise.

◆ lanes()

int Geometry::geometry::lanes ( )

Returns the number of lanes on the highway.

Returns
The total number of lanes (excluding on/off-ramps).

◆ length()

double Geometry::geometry::length ( )

Returns the total length of the highway segment.

Returns
The length of the highway in meters.

◆ merge()

double Geometry::geometry::merge ( )

Returns the position where the on-ramp ends.

Returns
The position of the merge point in meters (0 if no on-ramp).

The documentation for this class was generated from the following file: