6#include "roo_logging.h"
8#if defined(ESP32) || defined(ESP8266) || defined(__linux__)
46 float inInches()
const {
return length_ * 39.37007874f; }
49 float inFeet()
const {
return length_ * 3.280839895f; }
52 float inYards()
const {
return length_ * 1.0936132983f; }
58 bool isUnknown()
const {
return std::isnan(length_); }
63 return length_ == other.length_;
69 return !(other.length_ < length_);
73 return !(length_ < other.length_);
77 return !(length_ == other.length_);
100#if defined(ESP32) || defined(ESP8266) || defined(__linux__)
102 std::string asString()
const;
106 String asArduinoString()
const;
114 explicit Length(
float length) : length_(length) {}
215roo_logging::Stream&
operator<<(roo_logging::Stream& os,
const Length& val);
Representation of length, internally stored as floating-point meters.
Length & operator*=(float multi)
float inInches() const
Returns the length in inches.
bool operator==(const Length &other) const
bool operator>=(const Length &other) const
float inDecimeters() const
Returns the length in decimeters.
bool operator<=(const Length &other) const
float inNanometers() const
Returns the length in nanometers.
float inMicrometers() const
Returns the length in micrometers.
Length()
Creates a length object representing an 'unknown' length.
float inLightYears() const
Returns the length in light years.
friend Length UnknownLength()
Returns a length object representing an unknown length.
float inYards() const
Returns the length in yards.
float inMeters() const
Returns the length in meters.
Length & operator/=(float div)
Length & operator+=(const Length &other)
bool operator>(const Length &other) const
float inCentimeters() const
Returns the length in centimeters.
Length & operator-=(const Length &other)
bool operator!=(const Length &other) const
bool isUnknown() const
Returns whether the object represents an unknown length.
float inKilometers() const
Returns the length in kilometers.
float inFeet() const
Returns the length in feet.
friend Length LengthInMeters(float)
Returns a length object equivalent to the specified length expressed in meters.
bool operator<(const Length &other) const
float inMillimeters() const
Returns the length in millimeters.
For convenience conversion from roo_time::Duration.
Length LengthInMeters(float length)
Returns a length object equivalent to the specified length expressed in meters.
roo_logging::Stream & operator<<(roo_logging::Stream &os, const Area &val)
Length LengthInNanometers(float length)
Returns a length object equivalent to the specified length expressed in nanometers.
Length LengthInYards(float length)
Returns a length object equivalent to the specified length expressed in yards.
Length LengthInMillimeters(float length)
Returns a length object equivalent to the specified length expressed in millimeters.
Length LengthInDecimeters(float length)
Returns a length object equivalent to the specified length expressed in decimeters.
Area operator+(Area a, Area b)
Length LengthInMicrometers(float length)
Returns a length object equivalent to the specified length expressed in micrometers.
Area operator-(Area a, Area b)
Length LengthInLightYears(float length)
Returns a length object equivalent to the specified length expressed in light years.
Length LengthInCentimeters(float length)
Returns a length object equivalent to the specified length expressed in centimeters.
Length LengthInKilometers(float length)
Returns a length object equivalent to the specified length expressed in kilometers.
Length LengthInInches(float length)
Returns a length object equivalent to the specified length expressed in inches.
Area operator/(Area a, float b)
Length LengthInFeet(float length)
Returns a length object equivalent to the specified length expressed in feet.
Area operator*(Area a, float b)
Length UnknownLength()
Returns a length object representing an unknown length.