NDEVR
API Documentation

A unit that has both a scale and an offset (think degrees celcius vs fahrenheit). More...

Inheritance diagram for ScaledOffsetUnit:
[legend]
Collaboration diagram for ScaledOffsetUnit:
[legend]

Public Member Functions

 ScaledOffsetUnit (StringView name, TranslatedString translated_id, TranslatedString abbreviation, fltp08 scale, fltp08 offset)
 Constructs a ScaledOffsetUnit with the given scale, offset, and abbreviation.
virtual const TranslatedStringabbreviation (uint01 direction=X) const override
 Returns the translated abbreviation for this unit.
virtual Unitclone (const StringView &new_name, const TranslatedString &new_display_name) const override
 Creates a copy of this unit with a new name and display name.
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.
virtual Ray< 3, fltp08convertFromUnit (const Ray< 3, fltp08 > &program_space) const override
 Converts a 3D ray from this unit back to program space.
virtual Vertex< 3, fltp08convertFromUnit (const Vertex< 3, fltp08 > &program_space) const override
 Converts a 3D vertex from this unit back to program space.
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.
virtual Ray< 3, fltp08convertToUnit (const Ray< 3, fltp08 > &program_space) const override
 Converts a 3D ray from program space to this unit using scale and offset.
virtual Vertex< 3, fltp08convertToUnit (const Vertex< 3, fltp08 > &program_space) const override
 Converts a 3D vertex from program space to this unit using scale and offset.
virtual Matrix< fltp08matrix () const override
 Returns the transformation matrix representing this unit's scale.
virtual const UnitsubUnit (uint01) const override
 Returns the sub-unit for the given axis direction.
Public Member Functions inherited from Unit
 Unit (StringView name, TranslatedString translated_id)
 Constructs a Unit with the given internal name and translated display name.
virtual ~Unit ()=default
 Virtual destructor.
virtual Unitclone () const
 Creates a deep copy of this unit.
template<class t_angle_type>
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 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.
template<class t_angle_type>
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 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.
template<class t_angle_type>
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 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 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 StringView getNextPreferredSeparator (const StringView &current_string, uint01 direction=X) const
 Returns the next preferred separator character sequence based on the current input string.
bool operator== (const Unit &other) const
 Checks equality between two units by comparing their matrices and names.
virtual void toFormula (StringAllocatingView &unit_string, uint01 direction=X) const
 Writes the unit conversion as a formula into the given string.
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 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 TranslatedString translatedAxisName (uint04 index) const
 Returns the translated axis name for a given axis index.
TranslatedString translatedName () const
 Returns the translated display name of this unit.

Public Attributes

const TranslatedString core_abbreviation
 The translated abbreviation displayed for this unit.
const fltp08 offset
 The additive offset applied after scaling during conversion.
const fltp08 scale
 The multiplicative scale factor for conversion.
Public Attributes inherited from Unit
TranslatedString axis_abbreviations [4]
 Translated axis abbreviations for up to four axes.
TranslatedString axis_name_ids [4]
 Translated axis names for up to four axes.
const String name
 Internal identifier name for this unit.
const TranslatedString translated_id
 Translated display name for this unit.

Additional Inherited Members

Static Protected Member Functions inherited from Unit
static Buffer< StringViewOperatorSplit (const StringView &string)
 Splits a string by operator characters for formula parsing.

Detailed Description

A unit that has both a scale and an offset (think degrees celcius vs fahrenheit).


Definition at line 410 of file UnitTypes.h.

Constructor & Destructor Documentation

◆ ScaledOffsetUnit()

ScaledOffsetUnit::ScaledOffsetUnit ( StringView name,
TranslatedString translated_id,
TranslatedString abbreviation,
fltp08 scale,
fltp08 offset )
inline

Constructs a ScaledOffsetUnit with the given scale, offset, and abbreviation.

Parameters
[in]nameThe internal identifier for this unit.
[in]translated_idThe translated display name for this unit.
[in]abbreviationThe translated abbreviation for this unit.
[in]scaleThe multiplicative scale factor.
[in]offsetThe additive offset applied after scaling.

Definition at line 424 of file UnitTypes.h.

References Unit::Unit(), abbreviation(), core_abbreviation, Unit::name, offset, scale, and Unit::translated_id.

Referenced by clone().

Member Function Documentation

◆ abbreviation()

virtual const TranslatedString & ScaledOffsetUnit::abbreviation ( uint01 direction = X) const
inlinenodiscardoverridevirtual

Returns the translated abbreviation for this unit.

Parameters
[in]directionThe axis direction.
Returns
The translated abbreviation string.

Implements Unit.

Definition at line 502 of file UnitTypes.h.

References core_abbreviation.

Referenced by ScaledOffsetUnit(), and clone().

◆ clone()

virtual Unit * ScaledOffsetUnit::clone ( const StringView & new_name,
const TranslatedString & new_display_name ) const
inlinenodiscardoverridevirtual

Creates a copy of this unit with a new name and display name.

Parameters
[in]new_nameThe internal identifier for the cloned unit.
[in]new_display_nameThe translated display name for the cloned unit.
Returns
A newly allocated clone of this unit.

Implements Unit.

Definition at line 533 of file UnitTypes.h.

References ScaledOffsetUnit(), Unit::Unit(), abbreviation(), Unit::axis_abbreviations, Unit::axis_name_ids, offset, and scale.

◆ convertFromUnit() [1/3]

virtual fltp08 ScaledOffsetUnit::convertFromUnit ( const fltp08 & program_space,
const uint01 direction = X ) const
inlinenodiscardoverridevirtual

Converts a scalar from this unit back to program space by reversing scale and offset.

Parameters
[in]program_spaceThe value in this unit's space.
[in]directionThe axis direction for the conversion.
Returns
The value converted back to program space ((value - offset) / scale).

Implements Unit.

Definition at line 450 of file UnitTypes.h.

References offset, and scale.

◆ convertFromUnit() [2/3]

virtual Ray< 3, fltp08 > ScaledOffsetUnit::convertFromUnit ( const Ray< 3, fltp08 > & program_space) const
inlinenodiscardoverridevirtual

Converts a 3D ray from this unit back to program space.

Parameters
[in]program_spaceThe ray in this unit's space.
Returns
The ray converted back to program space.

Implements Unit.

Definition at line 492 of file UnitTypes.h.

References offset, and scale.

◆ convertFromUnit() [3/3]

virtual Vertex< 3, fltp08 > ScaledOffsetUnit::convertFromUnit ( const Vertex< 3, fltp08 > & program_space) const
inlinenodiscardoverridevirtual

Converts a 3D vertex from this unit back to program space.

Parameters
[in]program_spaceThe vertex in this unit's space.
Returns
The vertex converted back to program space.

Implements Unit.

Definition at line 472 of file UnitTypes.h.

References offset, and scale.

◆ convertToUnit() [1/3]

virtual fltp08 ScaledOffsetUnit::convertToUnit ( const fltp08 & program_space,
const uint01 direction = X ) const
inlinenodiscardoverridevirtual

Converts a scalar from program space to this unit using scale and offset.

Parameters
[in]program_spaceThe value in program space.
[in]directionThe axis direction for the conversion.
Returns
The value converted to this unit's space (value * scale + offset).

Implements Unit.

Definition at line 437 of file UnitTypes.h.

References offset, and scale.

◆ convertToUnit() [2/3]

virtual Ray< 3, fltp08 > ScaledOffsetUnit::convertToUnit ( const Ray< 3, fltp08 > & program_space) const
inlinenodiscardoverridevirtual

Converts a 3D ray from program space to this unit using scale and offset.

Parameters
[in]program_spaceThe ray in program space.
Returns
The ray converted to this unit's space.

Implements Unit.

Definition at line 482 of file UnitTypes.h.

References offset, and scale.

◆ convertToUnit() [3/3]

virtual Vertex< 3, fltp08 > ScaledOffsetUnit::convertToUnit ( const Vertex< 3, fltp08 > & program_space) const
inlinenodiscardoverridevirtual

Converts a 3D vertex from program space to this unit using scale and offset.

Parameters
[in]program_spaceThe vertex in program space.
Returns
The vertex converted to this unit's space.

Implements Unit.

Definition at line 462 of file UnitTypes.h.

References offset, and scale.

◆ matrix()

virtual Matrix< fltp08 > ScaledOffsetUnit::matrix ( ) const
inlinenodiscardoverridevirtual

Returns the transformation matrix representing this unit's scale.

Returns
A diagonal scale matrix with this unit's scale factor.

Implements Unit.

Definition at line 522 of file UnitTypes.h.

References scale.

◆ subUnit()

virtual const Unit * ScaledOffsetUnit::subUnit ( uint01 ) const
inlinenodiscardoverridevirtual

Returns the sub-unit for the given axis direction.

Parameters
[in]directionThe axis direction.
Returns
A pointer to this unit, since a scaled-offset unit has no distinct sub-units.

Implements Unit.

Definition at line 513 of file UnitTypes.h.

References Unit::Unit().


The documentation for this struct was generated from the following file: