33#include <NDEVR/String.h>
35#include <NDEVR/Unit.h>
44 :
Unit(name, translated_id)
45 , reference(reference)
79 return reference.
convertToString(program_space, add_comma, min_decimals, max_decimals, min_digits, include_abv, direction);
83 reference.
toString(s, program_space, add_comma, min_decimals, max_decimals, min_digits, include_abv, direction);
91 return reference.
fromString(unit_string, direction);
105 return reference.
toFormula(unit_string, direction);
109 return reference.
epsilon(value, direction);
113 return reference.
subUnit(direction);
117 return reference.
matrix();
125 :
Unit(
std::move(name),
std::move(translated_id))
127 , core_abbreviation(abbreviation)
132 lib_assert(direction < 3,
"Out of bounds direction");
134 return program_space * scale;
138 lib_assert(direction < 3,
"Out of bounds direction");
140 return program_space / scale;
152 return scale * program_space;
156 return program_space / scale;
160 return toString(convertToUnit(program_space, direction), add_comma, min_decimals, max_decimals, min_digits, include_abv, direction);
164 return convertFromUnit(fromString(unit_string, direction), direction);
174 return core_abbreviation;
192 :
Unit(
std::move(name),
std::move(translated_id))
195 , core_abbreviation(abbreviation)
200 lib_assert(direction < 3,
"Out of bounds direction");
202 return program_space * scale + offset;
206 lib_assert(direction < 3,
"Out of bounds direction");
208 return (program_space - offset) / scale;
212 return scale * program_space + offset;
216 return (program_space - offset) / scale;
220 return scale * program_space + offset;
224 return (program_space - offset) / scale;
230 return core_abbreviation;
256 , local_matrix(mat * base.matrix())
259 [[nodiscard]]
virtual fltp08 convertToUnit(
const fltp08& program_space,
const uint01 direction = X)
const override;
260 [[nodiscard]]
virtual fltp08 convertFromUnit(
const fltp08& program_space,
const uint01 direction = X)
const override;
266 [[nodiscard]]
virtual fltp08 epsilon(
fltp08 value,
uint01 direction = X)
const override;
282 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;
283 [[nodiscard]]
virtual fltp08 fromString(
const String& unit_string,
uint01 direction =
X)
const override;
286 [[nodiscard]]
virtual String getNextPreferredSeparator(
const String&
string,
uint01 direction)
const override;
308 [[nodiscard]]
virtual fltp08 convertToUnit(
const fltp08& program_space,
uint01 direction = X)
const override;
311 [[nodiscard]]
virtual fltp08 convertFromUnit(
const fltp08& program_space,
uint01 direction = X)
const override;
320 [[nodiscard]]
virtual fltp08 epsilon(
fltp08 value,
uint01 direction = X)
const override;
331 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);
333 uint04 min_digits,
bool use_abv =
true,
uint01 direction =
X)
const override;
338 String getNextPreferredSeparator(
const String&
string,
uint01 direction =
X)
const override;
352 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);
354 uint04 min_digits,
bool use_abv =
true,
uint01 direction =
X)
const override;
358 String getNextPreferredSeparator(
const String& current_string,
uint01 direction =
X)
const override;
372 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);
374 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;
377 String getNextPreferredSeparator(
const String&
string,
uint01 direction =
X)
const override;
386 [[nodiscard]]
virtual fltp08 convertToUnit(
const fltp08& program_space,
uint01 direction =
X)
const override;
387 [[nodiscard]]
virtual fltp08 convertFromUnit(
const fltp08& program_space,
uint01 direction =
X)
const override;
392 [[nodiscard]]
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;
393 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;
394 [[nodiscard]]
virtual fltp08 convertFromString(
const String& unit_string,
uint01 direction =
X)
const override;
395 [[nodiscard]]
virtual fltp08 fromString(
const String& unit_string,
uint01 direction =
X)
const override;
397 [[nodiscard]]
virtual String getNextPreferredSeparator(
const String& current_string,
uint01 direction =
X)
const override;
398 [[nodiscard]]
virtual String toFormula(
const String& unit_string,
uint01 direction =
X)
const override;
399 [[nodiscard]]
virtual const Unit* subUnit(
uint01 direction)
const override;
#define UNUSED(expr)
Definition BaseValues.hpp:433
#define lib_assert(expression, message)
Asserts some logic in the code. Disabled in non debug mode by default. Can be re-enabled in release u...
Definition LibAssert.h:70
Stores an angle in an optimized format.
Definition StringStream.h:352
Definition Matrix.hpp:173
Definition Vertex.hpp:341
t_type getAs() const
Definition String.h:334
Definition TranslatedString.h:9
An element of a vector space. An element of the real coordinate space Rn Basis vector,...
Definition Vector.hpp:62
A vertex.
Definition Vertex.hpp:54
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:98
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:120
@ X
Definition BaseValues.hpp:200
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:181
Contains logic for converting angles into user defined units including up-direction and clockwise-log...
Definition UnitTypes.h:300
virtual ~AngleUnit()=default
Definition BaseValues.hpp:272
Definition UnitTypes.h:371
uint04 max_decimal_digits
Definition UnitTypes.h:381
Definition UnitTypes.h:384
const Unit * elevation_unit
Definition UnitTypes.h:405
const Unit * location_unit
Definition UnitTypes.h:404
Definition UnitTypes.h:252
virtual const Unit * subUnit(uint01) const override
Definition UnitTypes.h:271
const Matrix< fltp08 > local_matrix
Definition UnitTypes.h:253
MatrixUnit(String name, const TranslatedString &translated_id, const Matrix< fltp08 > &mat, const Unit &base)
Definition UnitTypes.h:254
virtual Matrix< fltp08 > matrix() const override
Definition UnitTypes.h:267
Definition UnitTypes.h:41
virtual const Unit * subUnit(uint01 direction) const override
Definition UnitTypes.h:111
virtual fltp08 fromString(const String &unit_string, uint01 direction=X) const override
Definition UnitTypes.h:89
virtual Ray< 3, fltp08 > convertFromUnit(const Ray< 3, fltp08 > &program_space) const override
Definition UnitTypes.h:73
virtual fltp08 convertToUnit(const fltp08 &program_space, const uint01 direction=X) const override
Definition UnitTypes.h:53
virtual fltp08 convertFromUnit(const fltp08 &program_space, const uint01 direction=X) const override
Definition UnitTypes.h:57
virtual fltp08 convertFromString(const String &unit_string, uint01 direction=X) const override
Definition UnitTypes.h:85
virtual const TranslatedString & abbreviation(uint01 direction=X) const override
Definition UnitTypes.h:93
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:77
virtual Vertex< 3, fltp08 > convertFromUnit(const Vertex< 3, fltp08 > &program_space) const override
Definition UnitTypes.h:65
const Unit & reference
Definition UnitTypes.h:42
virtual Ray< 3, fltp08 > convertToUnit(const Ray< 3, fltp08 > &program_space) const override
Definition UnitTypes.h:69
ReferenceUnit(String name, TranslatedString translated_id, const Unit &reference)
Definition UnitTypes.h:43
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:81
virtual String toFormula(const String &unit_string, uint01 direction=X) const override
Definition UnitTypes.h:103
virtual Matrix< fltp08 > matrix() const override
Definition UnitTypes.h:115
virtual String getNextPreferredSeparator(const String ¤t_string, uint01 direction=X) const override
Definition UnitTypes.h:98
virtual fltp08 epsilon(fltp08 value, uint01 direction=X) const override
Definition UnitTypes.h:107
virtual Vertex< 3, fltp08 > convertToUnit(const Vertex< 3, fltp08 > &program_space) const override
Definition UnitTypes.h:61
Definition UnitTypes.h:187
virtual const Unit * subUnit(uint01) const override
Definition UnitTypes.h:232
virtual Ray< 3, fltp08 > convertFromUnit(const Ray< 3, fltp08 > &program_space) const override
Definition UnitTypes.h:222
virtual fltp08 convertToUnit(const fltp08 &program_space, const uint01 direction=X) const override
Definition UnitTypes.h:198
virtual fltp08 convertFromUnit(const fltp08 &program_space, const uint01 direction=X) const override
Definition UnitTypes.h:204
virtual const TranslatedString & abbreviation(uint01 direction=X) const override
Definition UnitTypes.h:227
virtual Vertex< 3, fltp08 > convertFromUnit(const Vertex< 3, fltp08 > &program_space) const override
Definition UnitTypes.h:214
virtual Ray< 3, fltp08 > convertToUnit(const Ray< 3, fltp08 > &program_space) const override
Definition UnitTypes.h:218
virtual Unit * clone(const String &new_name, const TranslatedString &new_display_name) const override
Definition UnitTypes.h:241
const fltp08 offset
Definition UnitTypes.h:189
virtual Matrix< fltp08 > matrix() const override
Definition UnitTypes.h:236
ScaledOffsetUnit(String name, TranslatedString translated_id, TranslatedString abbreviation, fltp08 scale, fltp08 offset)
Definition UnitTypes.h:191
virtual Vertex< 3, fltp08 > convertToUnit(const Vertex< 3, fltp08 > &program_space) const override
Definition UnitTypes.h:210
const TranslatedString core_abbreviation
Definition UnitTypes.h:190
const fltp08 scale
Definition UnitTypes.h:188
Definition UnitTypes.h:121
virtual fltp08 fromString(const String &unit_string, uint01 direction=X) const override
Definition UnitTypes.h:166
virtual const Unit * subUnit(uint01) const override
Definition UnitTypes.h:176
virtual Ray< 3, fltp08 > convertFromUnit(const Ray< 3, fltp08 > &program_space) const override
Definition UnitTypes.h:154
virtual fltp08 convertToUnit(const fltp08 &program_space, const uint01 direction=X) const override
Definition UnitTypes.h:130
virtual fltp08 convertFromUnit(const fltp08 &program_space, const uint01 direction=X) const override
Definition UnitTypes.h:136
virtual fltp08 convertFromString(const String &unit_string, uint01 direction=X) const override
Definition UnitTypes.h:162
virtual const TranslatedString & abbreviation(uint01 direction=X) const override
Definition UnitTypes.h:171
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:158
virtual Vertex< 3, fltp08 > convertFromUnit(const Vertex< 3, fltp08 > &program_space) const override
Definition UnitTypes.h:146
ScaledUnit(String name, TranslatedString translated_id, TranslatedString abbreviation, fltp08 scale)
Definition UnitTypes.h:124
virtual Ray< 3, fltp08 > convertToUnit(const Ray< 3, fltp08 > &program_space) const override
Definition UnitTypes.h:150
virtual Matrix< fltp08 > matrix() const override
Definition UnitTypes.h:180
virtual Vertex< 3, fltp08 > convertToUnit(const Vertex< 3, fltp08 > &program_space) const override
Definition UnitTypes.h:142
const TranslatedString core_abbreviation
Definition UnitTypes.h:123
const fltp08 scale
Definition UnitTypes.h:122
Definition UnitTypes.h:349
const fltp08 sub_unit_a
Definition UnitTypes.h:365
const TranslatedString abr_major
Definition UnitTypes.h:362
const TranslatedString abr_minor_a
Definition UnitTypes.h:363
const TranslatedString abr_minor_b
Definition UnitTypes.h:364
uint04 max_decimal_digits
Definition UnitTypes.h:367
const fltp08 sub_unit_b
Definition UnitTypes.h:366
Definition UnitTypes.h:329
const TranslatedString abr_major
Definition UnitTypes.h:341
const TranslatedString abr_minor
Definition UnitTypes.h:342
const fltp08 sub_unit
Definition UnitTypes.h:343
uint04 max_decimal_digits
Definition UnitTypes.h:344
Definition UnitTypes.h:279
const TranslatedString abr_major
Definition UnitTypes.h:289
const TranslatedString abr_minor
Definition UnitTypes.h:290
const fltp08 sub_unit
Definition UnitTypes.h:291
uint04 max_decimal_digits
Definition UnitTypes.h:292
virtual const Unit * subUnit(uint01 direction) const =0
virtual String getNextPreferredSeparator(const String ¤t_string, uint01 direction=X) const
Definition Unit.cpp:51
virtual fltp08 convertFromUnit(const fltp08 &unit_space, const uint01 direction=X) const =0
virtual Matrix< fltp08 > matrix() const =0
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:62
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:32
virtual fltp08 convertFromString(const String &unit_string, uint01 direction=X) const
Definition Unit.h:78
virtual String toFormula(const String &unit_string, uint01 direction=X) const
Definition Unit.cpp:63
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:44
virtual fltp08 fromString(const String &unit_string, uint01 direction=X) const
Definition Unit.h:82
virtual fltp08 epsilon(fltp08 value, uint01 direction=X) const
Definition Unit.cpp:77