|
TinyRobotics
|
Represents a speed measurement with unit conversion support. More...
#include <Speed.h>
Public Member Functions | |
| Speed (float speed, SpeedUnit unit) | |
| void | setValue (float newSpeed, SpeedUnit newUnit) |
| float | getValue (SpeedUnit desiredUnit) const |
| Speed | operator+ (const Speed &other) const |
| Speed | operator- (const Speed &other) const |
| Speed | operator* (float scalar) const |
| Speed | operator/ (float scalar) const |
| bool | operator== (const Speed &other) const |
| bool | operator!= (const Speed &other) const |
| bool | operator< (const Speed &other) const |
| bool | operator<= (const Speed &other) const |
| bool | operator> (const Speed &other) const |
| bool | operator>= (const Speed &other) const |
| Speed & | operator+= (const Speed &other) |
| Speed & | operator-= (const Speed &other) |
| Speed & | operator*= (float scalar) |
| Speed & | operator/= (float scalar) |
Protected Attributes | |
| float | speed = 0.0f |
| SpeedUnit | unit = SpeedUnit::MPS |
| Unit of the speed. | |
Represents a speed measurement with unit conversion support.
The Speed class encapsulates a speed value and its unit, supporting meters per second (MPS), kilometers per hour (KPH), feet per second (FPS), and miles per hour (MPH). It provides methods to set and retrieve the speed in any supported unit, automatically handling conversions.
Example: