33#include <NDEVR/String.h>
35#include <NDEVR/Unit.h>
47 :
Unit(name, translated_id)
48 , reference(reference)
82 return reference.
convertToString(program_space, add_comma, min_decimals, max_decimals, min_digits, include_abv, direction);
86 reference.
toString(s, program_space, add_comma, min_decimals, max_decimals, min_digits, include_abv, direction);
94 return reference.
fromString(unit_string, direction);
108 return reference.
toFormula(unit_string, direction);
112 return reference.
epsilon(value, direction);
116 return reference.
subUnit(direction);
120 return reference.
matrix();
131 :
Unit(
std::move(name),
std::move(translated_id))
133 , core_abbreviation(abbreviation)
138 lib_assert(direction < 3,
"Out of bounds direction");
140 return program_space * scale;
144 lib_assert(direction < 3,
"Out of bounds direction");
146 return program_space / scale;
158 return scale * program_space;
162 return program_space / scale;
166 return toString(convertToUnit(program_space, direction), add_comma, min_decimals, max_decimals, min_digits, include_abv, direction);
170 return convertFromUnit(fromString(unit_string, direction), direction);
180 return core_abbreviation;
201 :
Unit(
std::move(name),
std::move(translated_id))
204 , core_abbreviation(abbreviation)
209 lib_assert(direction < 3,
"Out of bounds direction");
211 return program_space * scale + offset;
215 lib_assert(direction < 3,
"Out of bounds direction");
217 return (program_space - offset) / scale;
221 return scale * program_space + offset;
225 return (program_space - offset) / scale;
229 return scale * program_space + offset;
233 return (program_space - offset) / scale;
239 return core_abbreviation;
268 , local_matrix(mat * base.matrix())
349 TwoPartAngleUnit(
const String& name,
const TranslatedString& translated_name,
const TranslatedString& abr_major,
const TranslatedString& abr_minor,
fltp08 sub_unit,
fltp08 scale,
const Vector<3, bool>& normalized,
Vector<3, fltp08> upper_limits,
Vector<3, fltp08> reflex_point,
Vector<3, bool> reflexes_up);
351 uint04 min_digits,
bool use_abv =
true,
uint01 direction = X)
const override;
372 ThreePartAngleUnit(
const String& name,
const TranslatedString& translated_name,
const TranslatedString& abr_major,
const TranslatedString& abr_minor_a,
const TranslatedString& abr_minor_b,
fltp08 sub_unit_a,
fltp08 sub_unit_b,
fltp08 scale,
const Vector<3, bool>& normalized,
Vector<3, fltp08> upper_limits,
Vector<3, fltp08> reflex_point,
Vector<3, bool> reflexes_up);
374 uint04 min_digits,
bool use_abv =
true,
uint01 direction = X)
const override;
396 DDMMSSAngleUnit(
const String& name,
const TranslatedString& translated_name,
const TranslatedString& abbreviation,
fltp08 scale,
const Vector<3, bool>& normalized,
const Vector<3, fltp08>& upper_limits,
const Vector<3, fltp08>& reflexes,
const Vector<3, bool>& reflexes_up);
#define UNUSED(expr)
Definition BaseValues.hpp:409
#define lib_assert(expression, message)
Definition LibAssert.h:61
The primary angle storage class for this API. Stores an angle in an optimized format.
Definition StringStream.h:540
Definition Matrix.hpp:176
Definition Vertex.hpp:317
The core String class for the NDEVR API.
Definition String.h:69
t_type getAs() const
Converts a string into an object. To use this function an object must have overwritten StringStream<t...
Definition String.h:143
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
Definition TranslatedString.h:13
A fixed-size array with better performance compared to dynamic containers.
Definition Vector.hpp:60
A vertex or point. A specific type of Vector used primarily for spacial location information.
Definition Vertex.hpp:48
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:80
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:149
Contains logic for converting angles into user defined units including up-direction and clockwise-log...
Definition UnitTypes.h:315
virtual Ray< 3, fltp08 > convertFromUnit(const Ray< 3, fltp08 > &program_space) const override
AngleUnit(const String &name, const TranslatedString &translated_name, const TranslatedString &abbreviation, fltp08 scale, const Vector< 3, bool > &normalized, const Vector< 3, fltp08 > &upper_limits, const Vector< 3, fltp08 > &reflexes, const Vector< 3, bool > &reflexes_up)
virtual fltp08 convertToUnit(const fltp08 &program_space, uint01 direction=X) const override
virtual fltp08 convertFromUnit(const fltp08 &program_space, uint01 direction=X) const override
AngleUnit(const String &name, const TranslatedString &translated_name, const TranslatedString &abbreviation, fltp08 scale)
virtual Vertex< 3, fltp08 > convertFromUnit(const Vertex< 3, fltp08 > &program_space) const override
virtual Ray< 3, fltp08 > convertToUnit(const Ray< 3, fltp08 > &program_space) const override
virtual ~AngleUnit()=default
virtual fltp08 denormalize(fltp08 value, uint01 direction) const
virtual fltp08 epsilon(fltp08 value, uint01 direction=X) const override
virtual Vertex< 3, fltp08 > convertToUnit(const Vertex< 3, fltp08 > &program_space) const override
virtual fltp08 normalize(fltp08 value, uint01 direction) const
virtual Unit * clone(const String &name, const TranslatedString &translated_id) const override
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
Definition BaseValues.hpp:233
Degrees, Minutes, Seconds stored in a compact way where degrees and minutes are seperated by a decima...
Definition UnitTypes.h:395
String getNextPreferredSeparator(const String &string, uint01 direction=X) const override
fltp08 epsilon(fltp08 value, uint01 direction=X) const override
DDMMSSAngleUnit(const String &name, const TranslatedString &translated_name, const TranslatedString &abbreviation, const AngleUnit &unit)
fltp08 fromString(const String &unit_string, uint01 direction=X) const override
uint04 max_decimal_digits
Definition UnitTypes.h:405
DDMMSSAngleUnit(const String &name, const TranslatedString &translated_name, const TranslatedString &abbreviation, fltp08 scale, const Vector< 3, bool > &normalized, const Vector< 3, fltp08 > &upper_limits, const Vector< 3, fltp08 > &reflexes, const Vector< 3, bool > &reflexes_up)
void toString(String &string, const fltp08 &local_space, bool add_comma, uint04 min_decimals, uint04 max_decimals, uint04 min_digits, bool use_abv=true, uint01 direction=X) const override
virtual Unit * clone(const String &name, const TranslatedString &translated_id) const override
An Unit that has both a location and elevation (Think Lat/Lon which has meters for elevation)
Definition UnitTypes.h:411
virtual const Unit * subUnit(uint01 direction) const override
virtual fltp08 fromString(const String &unit_string, uint01 direction=X) const override
virtual Ray< 3, fltp08 > convertFromUnit(const Ray< 3, fltp08 > &program_space) const override
void toString(String &string, const fltp08 &program_space, bool add_comma, uint04 min_decimals, uint04 max_decimals, uint04 min_digits, bool include_abv=true, uint01 direction=X) const override
virtual fltp08 convertToUnit(const fltp08 &program_space, uint01 direction=X) const override
virtual fltp08 convertFromString(const String &unit_string, uint01 direction=X) const override
virtual fltp08 convertFromUnit(const fltp08 &program_space, uint01 direction=X) const override
virtual const TranslatedString & abbreviation(uint01 direction=X) const override
virtual String convertToString(const fltp08 &program_space, bool add_comma, uint04 min_decimals, uint04 max_decimals, uint04 min_digits, bool include_abv=true, uint01 direction=X) const override
virtual TranslatedString translatedAxisName(uint04 index) const override
virtual Vertex< 3, fltp08 > convertFromUnit(const Vertex< 3, fltp08 > &program_space) const override
virtual Ray< 3, fltp08 > convertToUnit(const Ray< 3, fltp08 > &program_space) const override
virtual String toFormula(const String &unit_string, uint01 direction=X) const override
LocationElevationUnit(String name, TranslatedString translated_id, const Unit *location_unit, const Unit *elevation_unit)
fltp08 epsilon(fltp08 value, uint01 direction) const override
virtual Matrix< fltp08 > matrix() const override
virtual String getNextPreferredSeparator(const String ¤t_string, uint01 direction=X) const override
const Unit * elevation_unit
Definition UnitTypes.h:432
const Unit * location_unit
Definition UnitTypes.h:431
virtual Vertex< 3, fltp08 > convertToUnit(const Vertex< 3, fltp08 > &program_space) const override
virtual Unit * clone(const String &name, const TranslatedString &translated_id) const override
A unit that has a complex rotational offset. Think northing-easting vs easting-southing.
Definition UnitTypes.h:264
virtual const Unit * subUnit(uint01) const override
Definition UnitTypes.h:283
virtual Ray< 3, fltp08 > convertFromUnit(const Ray< 3, fltp08 > &program_space) const override
virtual fltp08 convertToUnit(const fltp08 &program_space, const uint01 direction=X) const override
const Matrix< fltp08 > local_matrix
Definition UnitTypes.h:265
virtual fltp08 convertFromUnit(const fltp08 &program_space, const uint01 direction=X) const override
virtual Vertex< 3, fltp08 > convertFromUnit(const Vertex< 3, fltp08 > &program_space) const override
virtual Ray< 3, fltp08 > convertToUnit(const Ray< 3, fltp08 > &program_space) const override
MatrixUnit(String name, const TranslatedString &translated_id, const Matrix< fltp08 > &mat, const Unit &base)
Definition UnitTypes.h:266
virtual Matrix< fltp08 > matrix() const override
Definition UnitTypes.h:279
virtual fltp08 epsilon(fltp08 value, uint01 direction=X) const override
virtual Vertex< 3, fltp08 > convertToUnit(const Vertex< 3, fltp08 > &program_space) const override
virtual Unit * clone(const String &name, const TranslatedString &translated_id) const override
Definition UnitTypes.h:44
virtual const Unit * subUnit(uint01 direction) const override
Definition UnitTypes.h:114
virtual fltp08 fromString(const String &unit_string, uint01 direction=X) const override
Definition UnitTypes.h:92
virtual Ray< 3, fltp08 > convertFromUnit(const Ray< 3, fltp08 > &program_space) const override
Definition UnitTypes.h:76
virtual fltp08 convertToUnit(const fltp08 &program_space, const uint01 direction=X) const override
Definition UnitTypes.h:56
virtual fltp08 convertFromUnit(const fltp08 &program_space, const uint01 direction=X) const override
Definition UnitTypes.h:60
virtual fltp08 convertFromString(const String &unit_string, uint01 direction=X) const override
Definition UnitTypes.h:88
virtual const TranslatedString & abbreviation(uint01 direction=X) const override
Definition UnitTypes.h:96
virtual String convertToString(const fltp08 &program_space, bool add_comma, uint04 min_decimals, uint04 max_decimals, uint04 min_digits, bool include_abv=true, uint01 direction=X) const override
Definition UnitTypes.h:80
virtual Vertex< 3, fltp08 > convertFromUnit(const Vertex< 3, fltp08 > &program_space) const override
Definition UnitTypes.h:68
const Unit & reference
Definition UnitTypes.h:45
virtual Ray< 3, fltp08 > convertToUnit(const Ray< 3, fltp08 > &program_space) const override
Definition UnitTypes.h:72
ReferenceUnit(String name, TranslatedString translated_id, const Unit &reference)
Definition UnitTypes.h:46
virtual void toString(String &s, const fltp08 &program_space, bool add_comma, uint04 min_decimals, uint04 max_decimals, uint04 min_digits, bool include_abv=true, uint01 direction=X) const override
Definition UnitTypes.h:84
virtual String toFormula(const String &unit_string, uint01 direction=X) const override
Definition UnitTypes.h:106
virtual Matrix< fltp08 > matrix() const override
Definition UnitTypes.h:118
virtual String getNextPreferredSeparator(const String ¤t_string, uint01 direction=X) const override
Definition UnitTypes.h:101
virtual fltp08 epsilon(fltp08 value, uint01 direction=X) const override
Definition UnitTypes.h:110
virtual Vertex< 3, fltp08 > convertToUnit(const Vertex< 3, fltp08 > &program_space) const override
Definition UnitTypes.h:64
A unit that has both a scale and an offset (think degrees celcius vs fahrenheit)
Definition UnitTypes.h:196
virtual const Unit * subUnit(uint01) const override
Definition UnitTypes.h:241
virtual Ray< 3, fltp08 > convertFromUnit(const Ray< 3, fltp08 > &program_space) const override
Definition UnitTypes.h:231
virtual fltp08 convertToUnit(const fltp08 &program_space, const uint01 direction=X) const override
Definition UnitTypes.h:207
virtual fltp08 convertFromUnit(const fltp08 &program_space, const uint01 direction=X) const override
Definition UnitTypes.h:213
virtual const TranslatedString & abbreviation(uint01 direction=X) const override
Definition UnitTypes.h:236
virtual Vertex< 3, fltp08 > convertFromUnit(const Vertex< 3, fltp08 > &program_space) const override
Definition UnitTypes.h:223
virtual Ray< 3, fltp08 > convertToUnit(const Ray< 3, fltp08 > &program_space) const override
Definition UnitTypes.h:227
virtual Unit * clone(const String &new_name, const TranslatedString &new_display_name) const override
Definition UnitTypes.h:250
const fltp08 offset
Definition UnitTypes.h:198
virtual Matrix< fltp08 > matrix() const override
Definition UnitTypes.h:245
ScaledOffsetUnit(String name, TranslatedString translated_id, TranslatedString abbreviation, fltp08 scale, fltp08 offset)
Definition UnitTypes.h:200
virtual Vertex< 3, fltp08 > convertToUnit(const Vertex< 3, fltp08 > &program_space) const override
Definition UnitTypes.h:219
const TranslatedString core_abbreviation
Definition UnitTypes.h:199
const fltp08 scale
Definition UnitTypes.h:197
A unit that describes a simple scale (think meters vs feet)
Definition UnitTypes.h:127
virtual fltp08 fromString(const String &unit_string, uint01 direction=X) const override
Definition UnitTypes.h:172
virtual const Unit * subUnit(uint01) const override
Definition UnitTypes.h:182
virtual Ray< 3, fltp08 > convertFromUnit(const Ray< 3, fltp08 > &program_space) const override
Definition UnitTypes.h:160
virtual fltp08 convertToUnit(const fltp08 &program_space, const uint01 direction=X) const override
Definition UnitTypes.h:136
virtual fltp08 convertFromUnit(const fltp08 &program_space, const uint01 direction=X) const override
Definition UnitTypes.h:142
virtual fltp08 convertFromString(const String &unit_string, uint01 direction=X) const override
Definition UnitTypes.h:168
virtual const TranslatedString & abbreviation(uint01 direction=X) const override
Definition UnitTypes.h:177
virtual String convertToString(const fltp08 &program_space, bool add_comma, uint04 min_decimals, uint04 max_decimals, uint04 min_digits, bool include_abv=true, uint01 direction=X) const override
Definition UnitTypes.h:164
virtual Vertex< 3, fltp08 > convertFromUnit(const Vertex< 3, fltp08 > &program_space) const override
Definition UnitTypes.h:152
ScaledUnit(String name, TranslatedString translated_id, TranslatedString abbreviation, fltp08 scale)
Definition UnitTypes.h:130
virtual Ray< 3, fltp08 > convertToUnit(const Ray< 3, fltp08 > &program_space) const override
Definition UnitTypes.h:156
virtual Matrix< fltp08 > matrix() const override
Definition UnitTypes.h:186
virtual Vertex< 3, fltp08 > convertToUnit(const Vertex< 3, fltp08 > &program_space) const override
Definition UnitTypes.h:148
virtual Unit * clone(const String &name, const TranslatedString &translated_id) const override
const TranslatedString core_abbreviation
Definition UnitTypes.h:129
const fltp08 scale
Definition UnitTypes.h:128
An angle unit that contains two-parts (Degrees, Minutes, Seconds)
Definition UnitTypes.h:369
const fltp08 sub_unit_a
Definition UnitTypes.h:385
fltp08 epsilon(fltp08 value, uint01 direction=X) const override
const TranslatedString abr_major
Definition UnitTypes.h:382
const TranslatedString abr_minor_a
Definition UnitTypes.h:383
const TranslatedString abr_minor_b
Definition UnitTypes.h:384
String getNextPreferredSeparator(const String ¤t_string, uint01 direction=X) const override
fltp08 fromString(const String &unit_string, uint01 direction=X) const override
uint04 max_decimal_digits
Definition UnitTypes.h:387
ThreePartAngleUnit(const String &name, const TranslatedString &translated_name, const TranslatedString &abr_major, const TranslatedString &abr_minor_a, const TranslatedString &abr_minor_b, fltp08 sub_unit_a, fltp08 sub_unit_b, fltp08 scale, const Vector< 3, bool > &normalized, Vector< 3, fltp08 > upper_limits, Vector< 3, fltp08 > reflex_point, Vector< 3, bool > reflexes_up)
const fltp08 sub_unit_b
Definition UnitTypes.h:386
void toString(String &string, const fltp08 &local_space, bool add_comma, uint04 min_decimals, uint04 max_decimals, uint04 min_digits, bool use_abv=true, uint01 direction=X) const override
ThreePartAngleUnit(const String &name, const TranslatedString &translated_name, const TranslatedString &abr_major, const TranslatedString &abr_minor_a, const TranslatedString &abr_minor_b, fltp08 sub_unit_a, fltp08 sub_unit_b, const AngleUnit &angle_unit)
virtual Unit * clone(const String &name, const TranslatedString &translated_id) const override
An angle unit that contains two-parts (Degrees, Minutes)
Definition UnitTypes.h:347
TwoPartAngleUnit(const String &name, const TranslatedString &translated_name, const TranslatedString &abr_major, const TranslatedString &abr_minor, fltp08 sub_unit, const AngleUnit &angle_unit)
String getNextPreferredSeparator(const String &string, uint01 direction=X) const override
fltp08 epsilon(fltp08 value, uint01 direction=X) const override
const TranslatedString abr_major
Definition UnitTypes.h:359
const TranslatedString abr_minor
Definition UnitTypes.h:360
const fltp08 sub_unit
Definition UnitTypes.h:361
fltp08 fromString(const String &unit_string, uint01 direction=X) const override
uint04 max_decimal_digits
Definition UnitTypes.h:362
TwoPartAngleUnit(const String &name, const TranslatedString &translated_name, const TranslatedString &abr_major, const TranslatedString &abr_minor, fltp08 sub_unit, fltp08 scale, const Vector< 3, bool > &normalized, Vector< 3, fltp08 > upper_limits, Vector< 3, fltp08 > reflex_point, Vector< 3, bool > reflexes_up)
void toString(String &string, const fltp08 &local_space, bool add_comma, uint04 min_decimals, uint04 max_decimals, uint04 min_digits, bool use_abv=true, uint01 direction=X) const override
virtual Unit * clone(const String &name, const TranslatedString &translated_id) const override
A unit that has two parts (Think feet, inches)
Definition UnitTypes.h:294
virtual fltp08 fromString(const String &unit_string, uint01 direction=X) const override
virtual fltp08 epsilon(fltp08 value, uint01 direction) const override
TwoPartUnit(const String &name, const TranslatedString &translated_id, const TranslatedString &abr_major, const TranslatedString &abr_minor, fltp08 scale, fltp08 sub_unit)
const TranslatedString abr_major
Definition UnitTypes.h:304
const TranslatedString abr_minor
Definition UnitTypes.h:305
virtual String getNextPreferredSeparator(const String &string, uint01 direction) const override
const fltp08 sub_unit
Definition UnitTypes.h:306
uint04 max_decimal_digits
Definition UnitTypes.h:307
void toString(String &string, const fltp08 &local_space, bool add_comma, uint04 min_decimals, uint04 max_decimals, uint04 min_digits, bool include_abv=true, uint01 direction=X) const override
virtual Unit * clone(const String &name, const TranslatedString &translated_id) const override
A definition of how to describe and display data. Units can be of any type.
Definition Unit.h:36
virtual const Unit * subUnit(uint01 direction) const =0
virtual fltp08 convertFromUnit(const fltp08 &unit_space, const uint01 direction=X) const =0
virtual String toFormula(const String &unit_string, uint01 direction=X) const
virtual Matrix< fltp08 > matrix() const =0
virtual fltp08 epsilon(fltp08 value, uint01 direction=X) const
String toString(const fltp08 &unit_space, bool add_comma, uint04 min_decimals, uint04 max_decimals, uint04 min_digits, bool include_abv=true, uint01 direction=X) const
Definition Unit.h:70
virtual const TranslatedString & abbreviation(uint01 direction=X) const =0
virtual fltp08 convertToUnit(const fltp08 &program_space, const uint01 direction=X) const =0
TranslatedString axis_abbreviations[4]
Definition Unit.h:40
virtual fltp08 convertFromString(const String &unit_string, uint01 direction=X) const
Definition Unit.h:86
virtual String getNextPreferredSeparator(const String ¤t_string, uint01 direction=X) const
String convertToString(const Angle< t_angle_type > &program_space, bool add_comma, uint04 min_decimals, uint04 max_decimals, uint04 min_digits, bool include_abv=true, uint01 direction=X) const
Definition Unit.h:52
virtual fltp08 fromString(const String &unit_string, uint01 direction=X) const
Definition Unit.h:90