|
TinyRobotics
|
Represents a distance measurement with unit conversion support. More...
#include <Distance.h>
Public Member Functions | |
| Distance (float distance, DistanceUnit unit) | |
| void | setValue (float newDistance, DistanceUnit newUnit) |
| float | getValue (DistanceUnit desiredUnit) const |
| Distance | operator+ (const Distance &other) const |
| Distance | operator- (const Distance &other) const |
| Distance | operator* (float scalar) const |
| Distance | operator/ (float scalar) const |
| bool | operator== (const Distance &other) const |
| bool | operator!= (const Distance &other) const |
| bool | operator< (const Distance &other) const |
| bool | operator<= (const Distance &other) const |
| bool | operator> (const Distance &other) const |
| bool | operator>= (const Distance &other) const |
| Distance & | operator+= (const Distance &other) |
| Distance & | operator-= (const Distance &other) |
| Distance & | operator*= (float scalar) |
| Distance & | operator/= (float scalar) |
Protected Attributes | |
| float | distance = 0.0f |
| DistanceUnit | unit = DistanceUnit::M |
| Unit of the distance. | |
Represents a distance measurement with unit conversion support.
The Distance class encapsulates a distance value and its unit, supporting meters (M), centimeters (CM), millimeters (MM), and feet (FEET). It provides methods to set and retrieve the distance in any supported unit, automatically handling conversions.
Example:
|
protected |
Unit of the distance.