- Main Page
- Modules
- Classes
- Files
- Related Pages

- Class List
- Class Hierarchy
- Class Members

# Car Class Reference

`#include <Car.h>`

Inheritance diagram for Car:

List of all members.

## Public Member Functions
| Car (Sector *sector, const Vector3r &size, const Vector3r &pos, const dReal direction, const dReal weight, const dReal whdia, const dReal whthick, const dReal whweight, const dReal maxSpeed)
virtual | ~Car ()
Sector * | getSector ()
Vector3r | getPosition () const
Vector3r | getPrevPosition () const
Vector3r | getDirection () const
Vector3r | getPrevDirection () const
dReal | getSpeed ()
void | getBoundingBox (Vector3r &aa, Vector3r &bb)
SectorDeque & | getPlannedSectors ()
SectorVector & | getPassedSectors ()
virtual void | initialize ()
virtual void | computeStep ()
virtual void | performStep ()
void | carAddedToSectorHandler (Sector *s, Car *c)
void | carRemovedFromSectorHandler (Sector *s, Car *c)
void | visualize ()
bool | getShowCarBorderPaths ()
void | toggleShowCarBorderPaths ()
bool | getShowCarBezierPath ()
void | toggleShowCarBezierPath ()
bool | getShowCarDirection ()
void | toggleShowCarDirection ()
bool | getShowCarIntersectionPoints ()
void | toggleShowCarIntersectionPoints ()
std::string | toString () const
## Private Types
| MODE_FREEWAY
| MODE_FOLLOW
| MODE_LET_GO
enum | DriveMode { MODE_FREEWAY, MODE_FOLLOW, MODE_LET_GO }
## Private Member Functions
void | tracePath ()
void | selectNextBezierPoint ()
void | switchSector ()
bool | isColliding (Car *car)
CarPriority | decidePriority (Car *car)
void | addCarEventHandler (Sector *sector)
void | removeCarEventHandler (Sector *sector)
## Private Attributes
Sector * | _sector
SectorDeque | _plannedSectors
SectorVector | _passedSectors
Line | _transitLine
Vector3r | _position
Vector3r | _prevPosition
Vector3r | _direction
dReal | _trajectoryDeviation
Vector3r | _prevDirection
Vector3r | _lastPoint
Vector3r | _targetPoint
Vector3r | _nextPoint
Line | _switchLine
bool | _expectNewSector
SectorCarMapping | _carsInSight
dBodyID | _body
dBodyID | _wheels [4]
dJointID | _hinges [4]
dGeomID | _box
dGeomID | _spheres [4]
dSpaceID | _space
Vector3r | _size
Vector3r | _pathTrackPoint
dReal | _wheelRadius
dReal | _wheelThickness
Polygon | _path
Polygon | _leftPathBorder
Polygon | _rightPathBorder
Polygon | _bezierPath
dReal | _speed
dReal | _targetSpeed
dReal | _maxSpeed
dReal | _acceleration
dReal | _maxAcceleration
dReal | _maxDecceleration
DriveMode | _driveMode
Polygon | _points
std::vector< PVector3r > | _vectors
bool | _showCarBorderPaths
bool | _showCarBezierPath
bool | _showCarDirection
bool | _showCarIntersectionPoints
## Friends
class | CarSource
std::ostream & | operator<< (std::ostream &os, const Car &car)

## Member Enumeration Documentation

enum Car::DriveMode`[private]`

Enumerator:

  MODE_FREEWAY |
  MODE_FOLLOW |
  MODE_LET_GO |

## Constructor & Destructor Documentation

Car::Car | ( | Sector * | sector,
|  | const Vector3r & | size,
|  | const Vector3r & | pos,
|  | const dReal | direction,
|  | const dReal | weight,
|  | const dReal | whdia,
|  | const dReal | whthick,
|  | const dReal | whweight,
|  | const dReal | maxSpeed |
| ) |  |  |

Car::~Car | ( |  | ) | `[virtual]`

## Member Function Documentation

void Car::addCarEventHandler | ( | Sector * | sector | ) | `[private]`

Registers with a sector to listen to car events

void Car::carAddedToSectorHandler | ( | Sector * | s,
|  | Car * | c |
| ) |  |  |

Handler for new car in sector event

void Car::carRemovedFromSectorHandler | ( | Sector * | s,
|  | Car * | c |
| ) |  |  |

Handler for car removed from sector event

void Car::computeStep | ( |  | ) | `[virtual]`

Computes the actions to be done during the Perform phase of the simulation step

Implements Animated.

CarPriority Car::decidePriority | ( | Car * | car | ) | `[private]`

Decides if car should let go or will let go

void Car::getBoundingBox | ( | Vector3r & | aa,
|  | Vector3r & | bb |
| ) |  |  |

Gives the left bottom back and right top front corner points of the car's bounding box

Vector3r Car::getDirection | ( |  | ) | const`[inline]`

Gives car's actual direction

SectorVector& Car::getPassedSectors | ( |  | ) | `[inline]`

Gives the car's passed sectors

SectorDeque& Car::getPlannedSectors | ( |  | ) | `[inline]`

Gives the planned sectors the car intends to go through

Vector3r Car::getPosition | ( |  | ) | const`[inline]`

Gives car's actual position

Vector3r Car::getPrevDirection | ( |  | ) | const`[inline]`

Gives car's previous direction

Vector3r Car::getPrevPosition | ( |  | ) | const`[inline]`

Gives car's previous position

Sector* Car::getSector | ( |  | ) | `[inline]`

Gives the current sector the object is in

bool Car::getShowCarBezierPath | ( |  | ) | `[inline]`

get status of showing car's Bezier tracking line

bool Car::getShowCarBorderPaths | ( |  | ) | `[inline]`

get status of showing car's right and left tracking lines

bool Car::getShowCarDirection | ( |  | ) | `[inline]`

get status of showing car's direction vector

bool Car::getShowCarIntersectionPoints | ( |  | ) | `[inline]`

get status of showing car's intersection points

dReal Car::getSpeed | ( |  | ) | `[inline]`

Gives car's actual speed

void Car::initialize | ( |  | ) | `[virtual]`

Initializes the car once the simulation starts

Implements Animated.

bool Car::isColliding | ( | Car * | car | ) | `[private]`

Check if car is colliding with projected _bezierPath

void Car::performStep | ( |  | ) | `[virtual]`

Performs the actions as computed in the Compute phase of the simulation step

Implements Animated.

void Car::removeCarEventHandler | ( | Sector * | sector | ) | `[private]`

Registers with a sector to listen to car events

void Car::selectNextBezierPoint | ( |  | ) | `[private]`

Selects the next point on the computed Bezier path

void Car::switchSector | ( |  | ) | `[private]`

Switches to the next planned sector

void Car::toggleShowCarBezierPath | ( |  | ) | `[inline]`

toggle showing car's Bezier tracking line

void Car::toggleShowCarBorderPaths | ( |  | ) | `[inline]`

Toggle showing car's right and left tracking lines

void Car::toggleShowCarDirection | ( |  | ) | `[inline]`

toggle showing car's direction vector

void Car::toggleShowCarIntersectionPoints | ( |  | ) | `[inline]`

toggle showing car's intersection points

std::string Car::toString | ( |  | ) | const`[virtual]`

Gives important car metrics in a string

Implements SimulationObject.

void Car::tracePath | ( |  | ) | `[private]`

Traces a path through a sector based on _startLine and _transitLine

void Car::visualize | ( |  | ) | `[virtual]`

Display the car

Implements Visualized.

## Friends And Related Function Documentation

friend class CarSource`[friend]`

std::ostream& operator<< | ( | std::ostream & | os,
|  | const Car & | car |
| ) |  |  | `[friend]`

## Member Data Documentation

dReal Car::_acceleration`[private]`

Current car acceleration (can be negative if braking

Polygon Car::_bezierPath`[private]`

Projected Bezier path in current sector

dBodyID Car::_body`[private]`

ODE body for main car hull

dGeomID Car::_box`[private]`

ODE geom for the hull

SectorCarMapping Car::_carsInSight`[private]`

Vector of cars in sight

Vector3r Car::_direction`[private]`

The current direction

DriveMode Car::_driveMode`[private]`

Current driving mode

bool Car::_expectNewSector`[private]`

Flag for state when the car has already computed the path through the next sector and will switch to it soon

dJointID Car::_hinges[4]`[private]`

ODE hinges to connect hull and wheels

Vector3r Car::_lastPoint`[private]`

The last point on the Bezier path the car has already passed

Polygon Car::_leftPathBorder`[private]`

Projected trajectory left border

dReal Car::_maxAcceleration`[private]`

Maximum acceleration the car can do

dReal Car::_maxDecceleration`[private]`

Maximum deccleration the car can do

dReal Car::_maxSpeed`[private]`

Maximum speed the car can do

Vector3r Car::_nextPoint`[private]`

The next point on the Bezier path the car is going to aim at once it passes the _targetPoint

SectorVector Car::_passedSectors`[private]`

Sectors the car has passed

Polygon Car::_path`[private]`

Path to follow in current sector

Vector3r Car::_pathTrackPoint`[private]`

Path tracking point this point is supposed to be in between the front wheels and act as a reference point for tracking deviation from the computed trajectory path

SectorDeque Car::_plannedSectors`[private]`

Vector of sectors planned to drive through

Polygon Car::_points`[private]`

Vector3r Car::_position`[private]`

The current position

Vector3r Car::_prevDirection`[private]`

The direction in previous step

Vector3r Car::_prevPosition`[private]`

The position in previous step

Polygon Car::_rightPathBorder`[private]`

Projected trajectory right border

Sector* Car::_sector`[private]`

The current sector

bool Car::_showCarBezierPath`[private]`

Status attribute for showing car's Bezier tracking line

bool Car::_showCarBorderPaths`[private]`

Status attribute for showing car's right and left tracking lines

bool Car::_showCarDirection`[private]`

Status attribute for showing car's direction vector

bool Car::_showCarIntersectionPoints`[private]`

Status attribute for showing car's intersection points with sector

Vector3r Car::_size`[private]`

Car's size

dSpaceID Car::_space`[private]`

Car's own ODE collision space

dReal Car::_speed`[private]`

Current car speed

dGeomID Car::_spheres[4]`[private]`

ODE geoms for the wheels

Line Car::_switchLine`[private]`

Line on which the car will swich to follow next segment of the Bezier path

Vector3r Car::_targetPoint`[private]`

The current point on the Bezier path the car is aiming at

dReal Car::_targetSpeed`[private]`

Target speed to reach

dReal Car::_trajectoryDeviation`[private]`

The sideways deviation from the computed trajectory

Line Car::_transitLine`[private]`

End line for path through the current sector

std::vector<PVector3r> Car::_vectors`[private]`

dReal Car::_wheelRadius`[private]`

Radius of car's wheels

dBodyID Car::_wheels[4]`[private]`

ODE bodies for wheels

dReal Car::_wheelThickness`[private]`

Thickness of car's wheels

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

- src/sim/Car.h
- src/sim/Car.cpp