3#include <NDEVR/TranslatedString.h>
4#include <NDEVR/StringStream.h>
5#include <NDEVR/StringView.h>
6#include <NDEVR/Angle.h>
92 [[nodiscard]]
virtual Ray<3, fltp08>
convertToUnit(
const Ray<3, fltp08>& program_space)
const = 0;
99 [[nodiscard]]
virtual Ray<3, fltp08>
convertFromUnit(
const Ray<3, fltp08>& unit_space)
const = 0;
119 template<
class t_angle_type>
122 return convertToString(program_space.template internal<false>(), add_comma, min_decimals, max_decimals, min_digits, include_abv, direction);
131 template<
class t_angle_type>
134 return convertToUnit(program_space.template internal<false>(), direction);
143 template<
class t_angle_type>
162 return toString(
convertToUnit(program_space, direction), add_comma, min_decimals, max_decimals, min_digits, include_abv, direction);
179 toString(s, unit_space, add_comma, min_decimals, max_decimals, min_digits, include_abv, direction);
196 string.append(unit_space);
197 if (add_comma || min_decimals > 0 || max_decimals <=
string.size() || min_digits > 0)
198 string =
string.formatNumberString(add_comma, min_decimals, max_decimals, min_digits);
Stores an angle in an optimized internal format with support for efficient trigonometric operations.
The equivelent of std::vector but with a bit more control.
Templated logic for doing matrix multiplication.
This class is like a string view, but may optionally store the data internally Useful if the return t...
Logic for reading or writing to a string or a user friendly, TranslatedString.
The core String View class for the NDEVR API.
t_type getAs() const
Converts a string into an object.
The core String class for the NDEVR API.
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
A point in N-dimensional space, used primarily for spatial location information.
The primary namespace for the NDEVR SDK.
UnitCategory
A category of unit describing what it relates to.
@ e_rotational_speed
Rotational speed measurement (e.g., RPM, radians per second).
@ e_time
Time measurement (e.g., seconds, hours).
@ e_coordinate
Coordinate system values (e.g., Cartesian positions).
@ e_orientation
Orientation measurement (e.g., azimuth, bearing).
@ e_distance
Linear distance measurement (e.g., meters, feet).
@ e_lat_lon
Latitude and longitude geographic coordinates.
@ e_acceleration
Acceleration measurement (e.g., meters per second squared).
@ e_weight
Weight or mass measurement (e.g., kilograms, pounds).
@ e_angle
Angular measurement (e.g., degrees, radians).
@ e_surface_area
Surface area measurement (e.g., square meters, acres).
@ e_volume
Volume measurement (e.g., cubic meters, liters).
@ e_speed
Speed measurement (e.g., meters per second, mph).
@ e_force
Force measurement (e.g., newtons, pound-force).
@ e_ratio
Dimensionless ratio (e.g., percentage, fraction).
@ e_undefined_unit
No specific unit category assigned.
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.
@ INTERNAL_ANGLE
The angle internally used by the angle class.
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
virtual fltp08 convertFromString(const StringView &unit_string, uint01 direction=X) const
Parses a string in this unit's format and converts the result to internal program space.
virtual Vertex< 3, fltp08 > convertToUnit(const Vertex< 3, fltp08 > &program_space) const =0
Converts a 3D vertex from internal program space to this unit's representation.
virtual fltp08 fromString(const StringView &unit_string, uint01 direction=X) const
Parses a string into a scalar value in this unit's space without converting to program space.
virtual Matrix< fltp08 > matrix() const =0
Returns the transformation matrix representing this unit's conversion.
virtual Unit * clone() const
Creates a deep copy of this unit.
Angle< t_angle_type > convertAngleFromUnit(const fltp08 &unit_space, uint01 direction=X) const
Converts a scalar value in this unit's space back to an Angle in program space.
virtual StringView getNextPreferredSeparator(const StringView ¤t_string, uint01 direction=X) const
Returns the next preferred separator character sequence based on the current input string.
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
Converts an angle value from program space to a formatted string in this unit.
virtual fltp08 epsilon(fltp08 value, uint01 direction=X) const
Returns a small epsilon value appropriate for comparisons in this unit at the given magnitude.
virtual fltp08 convertFromUnit(const fltp08 &unit_space, const uint01 direction=X) const =0
Converts a value from this unit's representation back to internal program space.
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
Converts a scalar value from program space to a formatted string in this unit.
TranslatedString translatedName() const
Returns the translated display name of this unit.
virtual void toString(String &string, const fltp08 &unit_space, bool add_comma, uint04 min_decimals, uint04 max_decimals, uint04 min_digits, bool include_abv=true, uint01 direction=X) const
Appends a formatted unit value to an existing string.
virtual Ray< 3, fltp08 > convertFromUnit(const Ray< 3, fltp08 > &unit_space) const =0
Converts a 3D ray from this unit's representation back to internal program space.
fltp08 convertToUnit(const Angle< t_angle_type > &program_space, uint01 direction=X) const
Converts an angle value from program space to this unit's scalar representation.
virtual Unit * clone(const StringView &new_name, const TranslatedString &new_display_name) const =0
Creates a deep copy of this unit with a new name and display name.
virtual ~Unit()=default
Virtual destructor.
Unit(StringView name, TranslatedString translated_id)
Constructs a Unit with the given internal name and translated display name.
virtual const TranslatedString & abbreviation(uint01 direction=X) const =0
Returns the abbreviated name for this unit along the given axis direction.
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.
virtual Ray< 3, fltp08 > convertToUnit(const Ray< 3, fltp08 > &program_space) const =0
Converts a 3D ray from internal program space to this unit's representation.
virtual const Unit * subUnit(uint01 direction) const =0
Returns the sub-unit for a specific axis direction, if this unit is compound.
static Buffer< StringView > OperatorSplit(const StringView &string)
Splits a string by operator characters for formula parsing.
virtual void toFormula(StringAllocatingView &unit_string, uint01 direction=X) const
Writes the unit conversion as a formula into the given string.
virtual fltp08 convertToUnit(const fltp08 &program_space, const uint01 direction=X) const =0
Converts a value from internal program space to this unit's representation.
TranslatedString axis_name_ids[4]
Translated axis names for up to four axes.
const String name
Internal identifier name for this unit.
TranslatedString axis_abbreviations[4]
Translated axis abbreviations for up to four axes.
virtual TranslatedString translatedAxisName(uint04 index) const
Returns the translated axis name for a given axis index.
virtual Vertex< 3, fltp08 > convertFromUnit(const Vertex< 3, fltp08 > &unit_space) const =0
Converts a 3D vertex from this unit's representation back to internal program space.
bool operator==(const Unit &other) const
Checks equality between two units by comparing their matrices and names.
const TranslatedString translated_id
Translated display name for this unit.