NDEVR
API Documentation
UnitTypes.h
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Base
28File: Units
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include <NDEVR/String.h>
34#include "DLLInfo.h"
35#include <NDEVR/Unit.h>
36namespace NDEVR
37{
38
43 class INIFactory;
44 struct NDEVR_BASE_API ReferenceUnit : public Unit
45 {
46 const Unit& reference;
47
54 ReferenceUnit(StringView name, TranslatedString translated_id, const Unit& reference)
55 : Unit(name, translated_id)
56 , reference(reference)
57 {
58 axis_abbreviations[0] = reference.axis_abbreviations[0];
59 axis_abbreviations[1] = reference.axis_abbreviations[1];
60 axis_abbreviations[2] = reference.axis_abbreviations[2];
61 axis_abbreviations[3] = reference.axis_abbreviations[3];
62 }
63
70 [[nodiscard]] virtual fltp08 convertToUnit(const fltp08& program_space, const uint01 direction = X) const override
71 {
72 return reference.convertToUnit(program_space, direction);
73 }
74
81 [[nodiscard]] virtual fltp08 convertFromUnit(const fltp08& program_space, const uint01 direction = X) const override
82 {
83 return reference.convertToUnit(program_space, direction);
84 }
85
91 [[nodiscard]] virtual Vertex<3, fltp08> convertToUnit(const Vertex<3, fltp08>& program_space) const override
92 {
93 return reference.convertToUnit(program_space);
94 }
95
101 [[nodiscard]] virtual Vertex<3, fltp08> convertFromUnit(const Vertex<3, fltp08>& program_space) const override
102 {
103 return reference.convertFromUnit(program_space);
104 }
105
111 [[nodiscard]] virtual Ray<3, fltp08> convertToUnit(const Ray<3, fltp08>& program_space) const override
112 {
113 return reference.convertToUnit(program_space);
114 }
115
121 [[nodiscard]] virtual Ray<3, fltp08> convertFromUnit(const Ray<3, fltp08>& program_space) const override
122 {
123 return reference.convertFromUnit(program_space);
124 }
125
137 [[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
138 {
139 return reference.convertToString(program_space, add_comma, min_decimals, max_decimals, min_digits, include_abv, direction);
140 }
141
153 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
154 {
155 reference.toString(s, program_space, add_comma, min_decimals, max_decimals, min_digits, include_abv, direction);
156 }
157
164 [[nodiscard]] virtual fltp08 convertFromString(const StringView& unit_string, uint01 direction = X) const override
165 {
166 return reference.convertFromString(unit_string, direction);
167 }
168
175 [[nodiscard]] virtual fltp08 fromString(const StringView& unit_string, uint01 direction = X) const override
176 {
177 return reference.fromString(unit_string, direction);
178 }
179
185 [[nodiscard]] virtual const TranslatedString& abbreviation(uint01 direction = X) const override
186 {
187 return reference.abbreviation(direction);
188 }
189
196 [[nodiscard]] virtual StringView getNextPreferredSeparator(const StringView& current_string, uint01 direction = X) const override
197 {
198 return reference.getNextPreferredSeparator(current_string, direction);
199 }
200
206 virtual void toFormula(StringAllocatingView& unit_string, uint01 direction = X) const override
207 {
208 reference.toFormula(unit_string, direction);
209 }
210
217 [[nodiscard]] virtual fltp08 epsilon(fltp08 value, uint01 direction = X) const override
218 {
219 return reference.epsilon(value, direction);
220 }
221
227 [[nodiscard]] virtual const Unit* subUnit(uint01 direction) const override
228 {
229 return reference.subUnit(direction);
230 }
231
236 [[nodiscard]] virtual Matrix<fltp08> matrix() const override
237 {
238 return reference.matrix();
239 }
240 };
245 struct NDEVR_BASE_API ScaledUnit : public Unit
246 {
247 const fltp08 scale;
249
262
269 [[nodiscard]] virtual fltp08 convertToUnit(const fltp08& program_space, const uint01 direction = X) const override
270 {
271 lib_assert(direction < 3, "Out of bounds direction");
272 UNUSED(direction);
273 return program_space * scale;
274 }
275
282 [[nodiscard]] virtual fltp08 convertFromUnit(const fltp08& program_space, const uint01 direction = X) const override
283 {
284 lib_assert(direction < 3, "Out of bounds direction");
285 UNUSED(direction);//Not used for simple conversions
286 return program_space / scale;
287 }
288
294 [[nodiscard]] virtual Vertex<3, fltp08> convertToUnit(const Vertex<3, fltp08>& program_space) const override
295 {
296 return Vertex<3, fltp08>(scale * program_space);
297 }
298
304 [[nodiscard]] virtual Vertex<3, fltp08> convertFromUnit(const Vertex<3, fltp08>& program_space) const override
305 {
306 return Vertex<3, fltp08>(program_space / scale);
307 }
308
314 [[nodiscard]] virtual Ray<3, fltp08> convertToUnit(const Ray<3, fltp08>& program_space) const override
315 {
316 return scale * program_space;
317 }
318
324 [[nodiscard]] virtual Ray<3, fltp08> convertFromUnit(const Ray<3, fltp08>& program_space) const override
325 {
326 return program_space / scale;
327 }
328
340 [[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
341 {
342 return toString(convertToUnit(program_space, direction), add_comma, min_decimals, max_decimals, min_digits, include_abv, direction);
343 }
344
351 [[nodiscard]] virtual fltp08 convertFromString(const StringView& unit_string, uint01 direction = X) const override
352 {
353 return convertFromUnit(fromString(unit_string, direction), direction);
354 }
355
362 [[nodiscard]] virtual fltp08 fromString(const StringView& unit_string, uint01 direction = X) const override
363 {
364 UNUSED(direction);
365 return unit_string.getAs<fltp08>();
366 }
367
373 [[nodiscard]] virtual const TranslatedString& abbreviation(uint01 direction = X) const override
374 {
375 UNUSED(direction);
376 return core_abbreviation;
377 }
378
384 [[nodiscard]] virtual const Unit* subUnit(uint01) const override
385 {
386 return this;
387 }
388
393 [[nodiscard]] virtual Matrix<fltp08> matrix() const override
394 {
395 return Matrix<fltp08>::ScalerMatrix(scale);
396 }
397
404 [[nodiscard]] virtual Unit* clone(const StringView& name, const TranslatedString& translated_id) const override;;
405 };
406
410 struct NDEVR_BASE_API ScaledOffsetUnit : public Unit
411 {
412 const fltp08 scale;
415
430
437 [[nodiscard]] virtual fltp08 convertToUnit(const fltp08& program_space, const uint01 direction = X) const override
438 {
439 lib_assert(direction < 3, "Out of bounds direction");
440 UNUSED(direction);
441 return program_space * scale + offset;
442 }
443
450 [[nodiscard]] virtual fltp08 convertFromUnit(const fltp08& program_space, const uint01 direction = X) const override
451 {
452 lib_assert(direction < 3, "Out of bounds direction");
453 UNUSED(direction);//Not used for simple conversions
454 return (program_space - offset) / scale;
455 }
456
462 [[nodiscard]] virtual Vertex<3, fltp08> convertToUnit(const Vertex<3, fltp08>& program_space) const override
463 {
464 return scale * program_space + offset;
465 }
466
472 [[nodiscard]] virtual Vertex<3, fltp08> convertFromUnit(const Vertex<3, fltp08>& program_space) const override
473 {
474 return (program_space - offset) / scale;
475 }
476
482 [[nodiscard]] virtual Ray<3, fltp08> convertToUnit(const Ray<3, fltp08>& program_space) const override
483 {
484 return scale * program_space + offset;
485 }
486
492 [[nodiscard]] virtual Ray<3, fltp08> convertFromUnit(const Ray<3, fltp08>& program_space) const override
493 {
494 return (program_space - offset) / scale;
495 }
496
502 [[nodiscard]] virtual const TranslatedString& abbreviation(uint01 direction = X) const override
503 {
504 UNUSED(direction);
505 return core_abbreviation;
506 }
507
513 [[nodiscard]] virtual const Unit* subUnit(uint01) const override
514 {
515 return this;
516 }
517
522 [[nodiscard]] virtual Matrix<fltp08> matrix() const override
523 {
524 return Matrix<fltp08>::ScalerMatrix(scale);
525 }
526
533 [[nodiscard]] virtual Unit* clone(const StringView& new_name, const TranslatedString& new_display_name) const override
534 {
535 ScaledOffsetUnit* unit = new ScaledOffsetUnit(new_name, new_display_name, abbreviation(), scale, offset);
536 unit->axis_abbreviations[0] = axis_name_ids[0];
537 unit->axis_abbreviations[1] = axis_name_ids[1];
538 unit->axis_abbreviations[2] = axis_name_ids[2];
539 unit->axis_abbreviations[3] = axis_name_ids[3];
540 return unit;
541 }
542 };
543
547 struct NDEVR_BASE_API MatrixUnit : public ReferenceUnit
548 {
550
559 : ReferenceUnit(name, translated_id, base)
560 , local_matrix(mat * base.matrix())
561 {}
562
569 [[nodiscard]] virtual fltp08 convertToUnit(const fltp08& program_space, const uint01 direction = X) const override;
570
577 [[nodiscard]] virtual fltp08 convertFromUnit(const fltp08& program_space, const uint01 direction = X) const override;
578
584 [[nodiscard]] virtual Vertex<3, fltp08> convertToUnit(const Vertex<3, fltp08>& program_space) const override;
585
591 [[nodiscard]] virtual Vertex<3, fltp08> convertFromUnit(const Vertex<3, fltp08>& program_space) const override;
592
598 [[nodiscard]] virtual Ray<3, fltp08> convertToUnit(const Ray<3, fltp08>& program_space) const override;
599
605 [[nodiscard]] virtual Ray<3, fltp08> convertFromUnit(const Ray<3, fltp08>& program_space) const override;
606
613 [[nodiscard]] virtual fltp08 epsilon(fltp08 value, uint01 direction = X) const override;
614
619 [[nodiscard]] virtual Matrix<fltp08> matrix() const override
620 {
621 return local_matrix;
622 }
623
629 [[nodiscard]] virtual const Unit* subUnit(uint01) const override
630 {
631 return &reference;
632 }
633
640 [[nodiscard]] virtual Unit* clone(const StringView& name, const TranslatedString& translated_id) const override;
641 };
642
647 struct NDEVR_BASE_API TwoPartUnit : public ScaledUnit
648 {
659
671 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;
672
679 [[nodiscard]] virtual fltp08 fromString(const StringView& unit_string, uint01 direction = X) const override;
680
687 [[nodiscard]] virtual fltp08 epsilon(fltp08 value, uint01 direction) const override;
688
695 [[nodiscard]] virtual StringView getNextPreferredSeparator(const StringView& string, uint01 direction) const override;
696
703 [[nodiscard]] virtual Unit* clone(const StringView& name, const TranslatedString& translated_id) const override;
704
709 };
710
716 struct NDEVR_BASE_API AngleUnit : public ScaledUnit
717 {
726 protected:
740 const Vector<3, fltp08>& reflexes, const Vector<3, bool>& reflexes_up);
741 public:
742 virtual ~AngleUnit() = default;
743
750 [[nodiscard]] virtual fltp08 convertToUnit(const fltp08& program_space, uint01 direction = X) const override;
751
758 [[nodiscard]] virtual fltp08 normalize(fltp08 value, uint01 direction) const;
759
766 [[nodiscard]] virtual fltp08 denormalize(fltp08 value, uint01 direction) const;
767
774 [[nodiscard]] virtual fltp08 convertFromUnit(const fltp08& program_space, uint01 direction = X) const override;
775
781 [[nodiscard]] virtual Vertex<3, fltp08> convertToUnit(const Vertex<3, fltp08>& program_space) const override;
782
788 [[nodiscard]] virtual Ray<3, fltp08> convertToUnit(const Ray<3, fltp08>& program_space) const override;
789
795 [[nodiscard]] virtual Vertex<3, fltp08> convertFromUnit(const Vertex<3, fltp08>& program_space) const override;
796
802 [[nodiscard]] virtual Ray<3, fltp08> convertFromUnit(const Ray<3, fltp08>& program_space) const override;
803
810 [[nodiscard]] virtual Unit* clone(const StringView& name, const TranslatedString& translated_id) const override;
811
818 [[nodiscard]] virtual fltp08 epsilon(fltp08 value, uint01 direction = X) const override;
819
825 };
826
830 struct NDEVR_BASE_API TwoPartAngleUnit : public AngleUnit
831 {
842
857
869 void toString(String& string, const fltp08& local_space, bool add_comma, uint04 min_decimals, uint04 max_decimals,
870 uint04 min_digits, bool use_abv = true, uint01 direction = X) const override;
871
878 fltp08 fromString(const StringView& unit_string, uint01 direction = X) const override;
879
880
887 StringView getNextPreferredSeparator(const StringView& string, uint01 direction = X) const override;
888
895 fltp08 epsilon(fltp08 value, uint01 direction = X) const override;
896
903 [[nodiscard]] virtual Unit* clone(const StringView& name, const TranslatedString& translated_id) const override;
904
909 };
910
915 struct NDEVR_BASE_API ThreePartAngleUnit : public AngleUnit
916 {
929
946
958 void toString(String& string, const fltp08& local_space, bool add_comma, uint04 min_decimals, uint04 max_decimals,
959 uint04 min_digits, bool use_abv = true, uint01 direction = X) const override;
960
967 fltp08 fromString(const StringView& unit_string, uint01 direction = X) const override;
968
975 StringView getNextPreferredSeparator(const StringView& current_string, uint01 direction = X) const override;
976
983 fltp08 epsilon(fltp08 value, uint01 direction = X) const override;
984
991 [[nodiscard]] virtual Unit* clone(const StringView& name, const TranslatedString& translated_id) const override;
992
999 };
1000
1006 struct NDEVR_BASE_API DDMMSSAngleUnit : public AngleUnit
1007 {
1020
1028 DDMMSSAngleUnit(const StringView& name, const TranslatedString& translated_name, const TranslatedString& abbreviation, const AngleUnit& unit);
1029
1041 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;
1042
1049 fltp08 fromString(const StringView& unit_string, uint01 direction = X) const override;
1050
1057 StringView getNextPreferredSeparator(const StringView& string, uint01 direction = X) const override;
1058
1065 fltp08 epsilon(fltp08 value, uint01 direction = X) const override;
1066
1073 [[nodiscard]] virtual Unit* clone(const StringView& name, const TranslatedString& translated_id) const override;
1074
1076 };
1077
1081 struct NDEVR_BASE_API LocationElevationUnit : public Unit
1082 {
1091
1098 [[nodiscard]] virtual fltp08 convertToUnit(const fltp08& program_space, uint01 direction = X) const override;
1099
1106 [[nodiscard]] virtual fltp08 convertFromUnit(const fltp08& program_space, uint01 direction = X) const override;
1107
1113 [[nodiscard]] virtual Vertex<3, fltp08> convertToUnit(const Vertex<3, fltp08>& program_space) const override;
1114
1120 [[nodiscard]] virtual Vertex<3, fltp08> convertFromUnit(const Vertex<3, fltp08>& program_space) const override;
1121
1127 [[nodiscard]] virtual Ray<3, fltp08> convertToUnit(const Ray<3, fltp08>& program_space) const override;
1128
1134 [[nodiscard]] virtual Ray<3, fltp08> convertFromUnit(const Ray<3, fltp08>& program_space) const override;
1135
1147 [[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;
1148
1160 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;
1161
1168 [[nodiscard]] virtual fltp08 convertFromString(const StringView& unit_string, uint01 direction = X) const override;
1169
1176 [[nodiscard]] virtual fltp08 fromString(const StringView& unit_string, uint01 direction = X) const override;
1177
1183 [[nodiscard]] virtual const TranslatedString& abbreviation(uint01 direction = X) const override;
1184
1191 [[nodiscard]] virtual StringView getNextPreferredSeparator(const StringView& current_string, uint01 direction = X) const override;
1192
1198 virtual void toFormula(StringAllocatingView& unit_string, uint01 direction = X) const override;
1199
1205 [[nodiscard]] virtual const Unit* subUnit(uint01 direction) const override;
1206
1213 [[nodiscard]] virtual Unit* clone(const StringView& name, const TranslatedString& translated_id) const override;
1214
1221 fltp08 epsilon(fltp08 value, uint01 direction) const override;
1222
1228 [[nodiscard]] virtual TranslatedString translatedAxisName(uint04 index) const override;
1229
1234 [[nodiscard]] virtual Matrix<fltp08> matrix() const override;
1235
1238 };
1239
1240
1241}
static constexpr sint04 INDEX_PI
Optimized angle constant representing PI; allows integers to store angles to some degree of accuracy.
Definition Angle.h:305
Contains methods for easily reading and writing to an INI file including efficient casting,...
Definition INIReader.h:107
Templated logic for doing matrix multiplication.
Definition Matrix.hpp:182
This class is like a string view, but may optionally store the data internally Useful if the return t...
Definition String.h:1278
The core String View class for the NDEVR API.
Definition StringView.h:58
t_type getAs() const
Converts a string into an object.
Definition StringView.h:125
The core String class for the NDEVR API.
Definition String.h:95
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
Definition Vector.hpp:62
A point in N-dimensional space, used primarily for spatial location information.
Definition Vertex.hpp:44
The primary namespace for the NDEVR SDK.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
double fltp08
Defines an alias representing an 8 byte floating-point number.
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
@ name
The display name of the object.
STL namespace.
Vector< 3, bool > normalized
Per-axis flags indicating whether angles should be normalized to their range.
Definition UnitTypes.h:823
virtual fltp08 normalize(fltp08 value, uint01 direction) const
Normalizes an angle value to its canonical range for the given axis.
virtual fltp08 convertFromUnit(const fltp08 &program_space, uint01 direction=X) const override
Converts a scalar angle from this unit back to program space.
virtual Ray< 3, fltp08 > convertFromUnit(const Ray< 3, fltp08 > &program_space) const override
Converts a 3D ray of angles from this unit back to program space.
AngleUnit(const StringView &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)
Constructs an AngleUnit with full configuration for normalization and reflexes.
virtual fltp08 denormalize(fltp08 value, uint01 direction) const
Reverses normalization on an angle value for the given axis.
virtual fltp08 convertToUnit(const fltp08 &program_space, uint01 direction=X) const override
Converts a scalar angle from program space to this unit.
virtual Ray< 3, fltp08 > convertToUnit(const Ray< 3, fltp08 > &program_space) const override
Converts a 3D ray of angles from program space to this unit.
virtual Vertex< 3, fltp08 > convertToUnit(const Vertex< 3, fltp08 > &program_space) const override
Converts a 3D vertex of angles from program space to this unit.
virtual fltp08 epsilon(fltp08 value, uint01 direction=X) const override
Returns the smallest meaningful angular difference for a value in this unit.
Vector< 3, fltp08 > reflex_point
Per-axis reflex points where angle wrapping behavior changes.
Definition UnitTypes.h:822
virtual Vertex< 3, fltp08 > convertFromUnit(const Vertex< 3, fltp08 > &program_space) const override
Converts a 3D vertex of angles from this unit back to program space.
fltp08 period
The full period of the angle in internal units (default 2*PI).
Definition UnitTypes.h:820
Vector< 3, bool > reflexes_up
Per-axis flags indicating the direction of reflex angle wrapping.
Definition UnitTypes.h:824
virtual Unit * clone(const StringView &name, const TranslatedString &translated_id) const override
Creates a copy of this angle unit with a new name and display name.
Vector< 3, fltp08 > upper_limits
Per-axis upper limits for angle normalization.
Definition UnitTypes.h:821
AngleUnit(const StringView &name, const TranslatedString &translated_name, const TranslatedString &abbreviation, fltp08 scale)
Constructs an AngleUnit with the given scale factor.
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
fltp08 epsilon(fltp08 value, uint01 direction=X) const override
Returns the smallest meaningful angular difference for a value in this unit.
StringView getNextPreferredSeparator(const StringView &string, uint01 direction=X) const override
Returns the next preferred separator character for user input parsing.
fltp08 fromString(const StringView &unit_string, uint01 direction=X) const override
Parses a compact DDMMSS-formatted string into a numeric value in this unit's space.
DDMMSSAngleUnit(const StringView &name, const TranslatedString &translated_name, const TranslatedString &abbreviation, const AngleUnit &unit)
Constructs a DDMMSSAngleUnit from an existing AngleUnit configuration.
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
Writes a compact DDMMSS-formatted angle string into the given string.
DDMMSSAngleUnit(const StringView &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)
Constructs a DDMMSSAngleUnit with full configuration.
virtual Unit * clone(const StringView &name, const TranslatedString &translated_id) const override
Creates a copy of this unit with a new name and display name.
uint04 max_decimal_digits
The maximum number of decimal digits allowed for the seconds portion.
Definition UnitTypes.h:1075
const Unit * location_unit
The unit used for horizontal location axes (X, Y).
Definition UnitTypes.h:1236
virtual fltp08 convertFromString(const StringView &unit_string, uint01 direction=X) const override
Converts a unit-formatted string to a program-space value using the appropriate sub-unit.
virtual TranslatedString translatedAxisName(uint04 index) const override
Returns the translated axis name for the given index.
virtual fltp08 convertToUnit(const fltp08 &program_space, uint01 direction=X) const override
Converts a scalar from program space to this unit, selecting location or elevation based on direction...
LocationElevationUnit(StringView name, TranslatedString translated_id, const Unit *location_unit, const Unit *elevation_unit)
Constructs a LocationElevationUnit combining a horizontal location unit and a vertical elevation unit...
virtual const TranslatedString & abbreviation(uint01 direction=X) const override
Returns the abbreviation for this unit along the given axis direction.
virtual Ray< 3, fltp08 > convertToUnit(const Ray< 3, fltp08 > &program_space) const override
Converts a 3D ray from program space, applying location conversion to X/Y and elevation to Z.
virtual StringView getNextPreferredSeparator(const StringView &current_string, uint01 direction=X) const override
Returns the next preferred separator character for user input parsing.
virtual Unit * clone(const StringView &name, const TranslatedString &translated_id) const override
Creates a copy of this unit with a new name and display name.
virtual fltp08 fromString(const StringView &unit_string, uint01 direction=X) const override
Parses a string directly into a numeric value in this unit's space.
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
Writes a formatted display string for a program-space scalar into the given string.
virtual fltp08 convertFromUnit(const fltp08 &program_space, uint01 direction=X) const override
Converts a scalar from this unit back to program space, selecting location or elevation based on dire...
virtual Vertex< 3, fltp08 > convertFromUnit(const Vertex< 3, fltp08 > &program_space) const override
Converts a 3D vertex from this unit back to program space.
fltp08 epsilon(fltp08 value, uint01 direction) const override
Returns the smallest meaningful difference for a value in this unit.
virtual Matrix< fltp08 > matrix() const override
Returns the transformation matrix for this unit.
virtual const Unit * subUnit(uint01 direction) const override
Returns the sub-unit for the given axis direction (location or elevation).
virtual Vertex< 3, fltp08 > convertToUnit(const Vertex< 3, fltp08 > &program_space) const override
Converts a 3D vertex from program space, applying location conversion to X/Y and elevation to Z.
virtual Ray< 3, fltp08 > convertFromUnit(const Ray< 3, fltp08 > &program_space) const override
Converts a 3D ray from this unit back to program space.
const Unit * elevation_unit
The unit used for the vertical elevation axis (Z).
Definition UnitTypes.h:1237
virtual void toFormula(StringAllocatingView &unit_string, uint01 direction=X) const override
Writes the conversion formula for this unit into the given string.
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
Converts a program-space scalar to a formatted display string using the appropriate sub-unit.
virtual fltp08 convertToUnit(const fltp08 &program_space, const uint01 direction=X) const override
Converts a scalar from program space to this unit using the matrix transformation.
virtual Ray< 3, fltp08 > convertToUnit(const Ray< 3, fltp08 > &program_space) const override
Converts a 3D ray from program space to this unit using the matrix transformation.
virtual fltp08 convertFromUnit(const fltp08 &program_space, const uint01 direction=X) const override
Converts a scalar from this unit back to program space using the inverse matrix transformation.
virtual Ray< 3, fltp08 > convertFromUnit(const Ray< 3, fltp08 > &program_space) const override
Converts a 3D ray from this unit back to program space using the inverse matrix transformation.
virtual Vertex< 3, fltp08 > convertFromUnit(const Vertex< 3, fltp08 > &program_space) const override
Converts a 3D vertex from this unit back to program space using the inverse matrix transformation.
virtual Matrix< fltp08 > matrix() const override
Returns the combined transformation matrix for this unit.
Definition UnitTypes.h:619
virtual Unit * clone(const StringView &name, const TranslatedString &translated_id) const override
Creates a copy of this unit with a new name and display name.
virtual const Unit * subUnit(uint01) const override
Returns the sub-unit for the given axis direction.
Definition UnitTypes.h:629
virtual fltp08 epsilon(fltp08 value, uint01 direction=X) const override
Returns the smallest meaningful difference for a value in this unit.
MatrixUnit(StringView name, const TranslatedString &translated_id, const Matrix< fltp08 > &mat, const Unit &base)
Constructs a MatrixUnit with a rotational transformation applied to a base unit.
Definition UnitTypes.h:558
const Matrix< fltp08 > local_matrix
The combined transformation matrix (rotation * base matrix).
Definition UnitTypes.h:549
virtual Vertex< 3, fltp08 > convertToUnit(const Vertex< 3, fltp08 > &program_space) const override
Converts a 3D vertex from program space to this unit using the matrix transformation.
virtual fltp08 convertToUnit(const fltp08 &program_space, const uint01 direction=X) const override
Converts a scalar from program space to this unit using scale and offset.
Definition UnitTypes.h:437
ScaledOffsetUnit(StringView name, TranslatedString translated_id, TranslatedString abbreviation, fltp08 scale, fltp08 offset)
Constructs a ScaledOffsetUnit with the given scale, offset, and abbreviation.
Definition UnitTypes.h:424
virtual const TranslatedString & abbreviation(uint01 direction=X) const override
Returns the translated abbreviation for this unit.
Definition UnitTypes.h:502
virtual Matrix< fltp08 > matrix() const override
Returns the transformation matrix representing this unit's scale.
Definition UnitTypes.h:522
const fltp08 offset
The additive offset applied after scaling during conversion.
Definition UnitTypes.h:413
virtual fltp08 convertFromUnit(const fltp08 &program_space, const uint01 direction=X) const override
Converts a scalar from this unit back to program space by reversing scale and offset.
Definition UnitTypes.h:450
virtual Vertex< 3, fltp08 > convertToUnit(const Vertex< 3, fltp08 > &program_space) const override
Converts a 3D vertex from program space to this unit using scale and offset.
Definition UnitTypes.h:462
const fltp08 scale
The multiplicative scale factor for conversion.
Definition UnitTypes.h:412
virtual const Unit * subUnit(uint01) const override
Returns the sub-unit for the given axis direction.
Definition UnitTypes.h:513
const TranslatedString core_abbreviation
The translated abbreviation displayed for this unit.
Definition UnitTypes.h:414
virtual Ray< 3, fltp08 > convertFromUnit(const Ray< 3, fltp08 > &program_space) const override
Converts a 3D ray from this unit back to program space.
Definition UnitTypes.h:492
virtual Ray< 3, fltp08 > convertToUnit(const Ray< 3, fltp08 > &program_space) const override
Converts a 3D ray from program space to this unit using scale and offset.
Definition UnitTypes.h:482
virtual Vertex< 3, fltp08 > convertFromUnit(const Vertex< 3, fltp08 > &program_space) const override
Converts a 3D vertex from this unit back to program space.
Definition UnitTypes.h:472
virtual Unit * clone(const StringView &new_name, const TranslatedString &new_display_name) const override
Creates a copy of this unit with a new name and display name.
Definition UnitTypes.h:533
virtual Matrix< fltp08 > matrix() const override
Returns the transformation matrix representing this unit's scale.
Definition UnitTypes.h:393
virtual Ray< 3, fltp08 > convertFromUnit(const Ray< 3, fltp08 > &program_space) const override
Converts a 3D ray from this unit back to program space by dividing by the scale.
Definition UnitTypes.h:324
ScaledUnit(StringView name, TranslatedString translated_id, TranslatedString abbreviation, fltp08 scale)
Constructs a ScaledUnit with the given scale factor and abbreviation.
Definition UnitTypes.h:257
virtual fltp08 convertFromUnit(const fltp08 &program_space, const uint01 direction=X) const override
Converts a scalar from this unit back to program space by dividing by the scale.
Definition UnitTypes.h:282
virtual const TranslatedString & abbreviation(uint01 direction=X) const override
Returns the translated abbreviation for this unit.
Definition UnitTypes.h:373
const TranslatedString core_abbreviation
The translated abbreviation displayed for this unit.
Definition UnitTypes.h:248
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
Converts a program-space scalar to a formatted display string.
Definition UnitTypes.h:340
virtual fltp08 convertFromString(const StringView &unit_string, uint01 direction=X) const override
Converts a unit-formatted string to a program-space value.
Definition UnitTypes.h:351
virtual fltp08 convertToUnit(const fltp08 &program_space, const uint01 direction=X) const override
Converts a scalar from program space to this unit by multiplying by the scale.
Definition UnitTypes.h:269
virtual Vertex< 3, fltp08 > convertToUnit(const Vertex< 3, fltp08 > &program_space) const override
Converts a 3D vertex from program space to this unit by multiplying by the scale.
Definition UnitTypes.h:294
virtual Unit * clone(const StringView &name, const TranslatedString &translated_id) const override
Creates a copy of this unit with a new name and display name.
virtual const Unit * subUnit(uint01) const override
Returns the sub-unit for the given axis direction.
Definition UnitTypes.h:384
virtual Vertex< 3, fltp08 > convertFromUnit(const Vertex< 3, fltp08 > &program_space) const override
Converts a 3D vertex from this unit back to program space by dividing by the scale.
Definition UnitTypes.h:304
const fltp08 scale
The multiplicative scale factor used for conversion to this unit.
Definition UnitTypes.h:247
virtual fltp08 fromString(const StringView &unit_string, uint01 direction=X) const override
Parses a string directly into a numeric value in this unit's space.
Definition UnitTypes.h:362
virtual Ray< 3, fltp08 > convertToUnit(const Ray< 3, fltp08 > &program_space) const override
Converts a 3D ray from program space to this unit by multiplying by the scale.
Definition UnitTypes.h:314
const TranslatedString abr_major
The abbreviation for the major part (e.g., degrees symbol).
Definition UnitTypes.h:993
uint04 max_decimal_digits
The maximum number of decimal digits allowed for the smallest part.
Definition UnitTypes.h:998
const fltp08 sub_unit_a
The number of first minor units per major unit (e.g., 60 minutes per degree).
Definition UnitTypes.h:996
fltp08 epsilon(fltp08 value, uint01 direction=X) const override
Returns the smallest meaningful angular difference for a value in this unit.
const TranslatedString abr_minor_a
The abbreviation for the first minor part (e.g., minutes symbol).
Definition UnitTypes.h:994
virtual Unit * clone(const StringView &name, const TranslatedString &translated_id) const override
Creates a copy of this unit with a new name and display name.
fltp08 fromString(const StringView &unit_string, uint01 direction=X) const override
Parses a three-part angle formatted string into a numeric value in this unit's space.
const fltp08 sub_unit_b
The number of second minor units per first minor unit (e.g., 60 seconds per minute).
Definition UnitTypes.h:997
ThreePartAngleUnit(const StringView &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)
Constructs a ThreePartAngleUnit with full configuration.
StringView getNextPreferredSeparator(const StringView &current_string, uint01 direction=X) const override
Returns the next preferred separator character for user input parsing.
const TranslatedString abr_minor_b
The abbreviation for the second minor part (e.g., seconds symbol).
Definition UnitTypes.h:995
ThreePartAngleUnit(const StringView &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)
Constructs a ThreePartAngleUnit from an existing AngleUnit configuration.
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
Writes a formatted three-part angle string (e.g., degrees, minutes, seconds) into the given string.
fltp08 fromString(const StringView &unit_string, uint01 direction=X) const override
Parses a two-part angle formatted string into a numeric value in this unit's space.
const fltp08 sub_unit
The number of minor units per major unit (e.g., 60 minutes per degree).
Definition UnitTypes.h:907
virtual Unit * clone(const StringView &name, const TranslatedString &translated_id) const override
Creates a copy of this unit with a new name and display name.
const TranslatedString abr_major
The abbreviation for the major part (e.g., degrees symbol).
Definition UnitTypes.h:905
StringView getNextPreferredSeparator(const StringView &string, uint01 direction=X) const override
Returns the next preferred separator character for user input parsing.
TwoPartAngleUnit(const StringView &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)
Constructs a TwoPartAngleUnit with full configuration.
const TranslatedString abr_minor
The abbreviation for the minor part (e.g., minutes symbol).
Definition UnitTypes.h:906
TwoPartAngleUnit(const StringView &name, const TranslatedString &translated_name, const TranslatedString &abr_major, const TranslatedString &abr_minor, fltp08 sub_unit, const AngleUnit &angle_unit)
Constructs a TwoPartAngleUnit from an existing AngleUnit configuration.
fltp08 epsilon(fltp08 value, uint01 direction=X) const override
Returns the smallest meaningful angular difference for a value in this unit.
uint04 max_decimal_digits
The maximum number of decimal digits allowed for the minor part.
Definition UnitTypes.h:908
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
Writes a formatted two-part angle string (e.g., degrees and minutes) into the given string.
const fltp08 sub_unit
The number of minor units per major unit (e.g., 12 inches per foot).
Definition UnitTypes.h:707
TwoPartUnit(const StringView &name, const TranslatedString &translated_id, const TranslatedString &abr_major, const TranslatedString &abr_minor, fltp08 scale, fltp08 sub_unit)
Constructs a TwoPartUnit with major and minor subdivisions.
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
Writes a formatted two-part display string into the given string.
virtual StringView getNextPreferredSeparator(const StringView &string, uint01 direction) const override
Returns the next preferred separator character for user input parsing.
virtual fltp08 epsilon(fltp08 value, uint01 direction) const override
Returns the smallest meaningful difference for a value in this unit.
const TranslatedString abr_minor
The abbreviation for the minor part (e.g., inches symbol).
Definition UnitTypes.h:706
const TranslatedString abr_major
The abbreviation for the major part (e.g., feet symbol).
Definition UnitTypes.h:705
virtual Unit * clone(const StringView &name, const TranslatedString &translated_id) const override
Creates a copy of this unit with a new name and display name.
virtual fltp08 fromString(const StringView &unit_string, uint01 direction=X) const override
Parses a two-part formatted string into a numeric value in this unit's space.
uint04 max_decimal_digits
The maximum number of decimal digits allowed for the minor part.
Definition UnitTypes.h:708
Defines a unit of measurement for converting and displaying data values.
Definition Unit.h:39
Unit(StringView name, TranslatedString translated_id)
Constructs a Unit with the given internal name and translated display name.
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
Formats a value already in this unit's space into a display string.
Definition Unit.h:176
TranslatedString axis_name_ids[4]
Translated axis names for up to four axes.
Definition Unit.h:42
const String name
Internal identifier name for this unit.
Definition Unit.h:40
TranslatedString axis_abbreviations[4]
Translated axis abbreviations for up to four axes.
Definition Unit.h:43
const TranslatedString translated_id
Translated display name for this unit.
Definition Unit.h:41