Skip to main content

units Namespace

Definition

namespace helios::core::units { ... }

Enumerations Index

enum classUnit { ... }

Enumeration of length and time units supported by helios. More...

Functions Index

constexpr floatfromCm (const float cm) noexcept

Converts centimeters to meters. More...

constexpr floatfromM (const float m) noexcept

Pass-through helper for meter values. More...

constexpr helios::math::vec3ffromM (helios::math::vec3f v) noexcept

Pass-through helper for meter vectors. More...

constexpr helios::math::aabbffromM (helios::math::aabbf v) noexcept

Pass-through helper for meter AABBs. More...

constexpr floatfromS (const float s) noexcept

Converts seconds to seconds (identity helper). More...

constexpr floatfromMs (const float ms) noexcept

Converts milliseconds to seconds. More...

constexpr floatfrom (const float v, const Unit unit) noexcept

Converts a value from a given unit to helios units. More...

constexpr helios::math::aabbffrom (helios::math::aabbf aabb, const Unit unit) noexcept

Converts an AABB from a given unit to helios units. More...

Variables Index

constexpr autoHELIOS_SPATIAL_UNIT = Unit::Meter

Default length unit used throughout helios (1 meter per helios unit). More...

constexpr autoHELIOS_TEMPORAL_UNIT = Unit::Seconds

Default time unit used for all timing APIs (seconds). More...

constexpr floatCENTIMETERS = 0.01f

Ratio of centimeters to meters. More...

constexpr floatMETERS = 1.0f

Ratio of meters to meters (identity). More...

constexpr floatMILLISECONDS = 0.001f

Ratio of milliseconds to seconds. More...

constexpr floatSECONDS = 1.0f

Ratio of seconds to seconds (identity). More...

Enumerations

Unit

enum class helios::core::units::Unit
strong

Enumeration of length and time units supported by helios.

Enumeration values
MeterBase length unit (meters) in helios. 1.0f represents 1 meter
CentimeterCentimeter helper unit for authoring convenience. Converted to meters (0.01f) when used
SecondsBase time unit (seconds) in helios. 1.0f represents 1 second
MilliSecondsMillisecond helper unit derived from seconds. Converted to seconds (0.001f) when used

Definition at line 18 of file Unit.ixx.

18 enum class Unit {
19 /**
20 * @brief Base length unit (meters) in helios.
21 * 1.0f represents 1 meter.
22 */
24
25 /**
26 * @brief Centimeter helper unit for authoring convenience.
27 * Converted to meters (0.01f) when used.
28 */
30
31 /**
32 * @brief Base time unit (seconds) in helios.
33 * 1.0f represents 1 second.
34 */
36
37 /**
38 * @brief Millisecond helper unit derived from seconds.
39 * Converted to seconds (0.001f) when used.
40 */
42 };

Functions

from()

float helios::core::units::from (const float v, const Unit unit)
nodiscard constexpr noexcept

Converts a value from a given unit to helios units.

This method takes a value in the specified unit and converts it to helios units, e.g. spatial units to METER, temporal values to SECONDS.

Parameters
v

Value to convert.

unit

Unit of the value to convert.

Returns

Value expressed in temporal or spatial helios units.

Definition at line 155 of file Unit.ixx.

155 [[nodiscard]] constexpr float from(const float v, const Unit unit) noexcept {
156 switch (unit) {
157 case Unit::Meter:
158 return fromM(v);
160 return fromCm(v);
161 case Unit::Seconds:
162 return fromS(v);
164 return fromMs(v);
165 default:
166 std::unreachable();
167 }
168 }

References Centimeter, fromCm, fromM, fromMs, fromS, Meter, MilliSeconds and Seconds.

Referenced by helios::engine::runtime::world::Level::setBounds and helios::engine::modules::spatial::transform::systems::ScaleSystem::update.

from()

helios::math::aabbf helios::core::units::from (helios::math::aabbf aabb, const Unit unit)
nodiscard constexpr noexcept

Converts an AABB from a given unit to helios units.

Parameters
aabb

AABB to convert.

unit

Unit of the AABB coordinates.

Returns

AABB expressed in helios spatial units (meters).

Definition at line 178 of file Unit.ixx.

178 [[nodiscard]] constexpr helios::math::aabbf from(helios::math::aabbf aabb, const Unit unit) noexcept {
179 switch (unit) {
180 case Unit::Meter:
181 return fromM(aabb);
182 default:
183 std::unreachable();
184 }
185 }

References fromM and Meter.

fromCm()

float helios::core::units::fromCm (const float cm)
constexpr noexcept

Converts centimeters to meters.

Parameters
cm

Value expressed in centimeters.

Returns

Converted value expressed in meters.

Definition at line 82 of file Unit.ixx.

82 constexpr float fromCm(const float cm) noexcept {
83 return cm * CENTIMETERS;
84 };

Reference CENTIMETERS.

Referenced by from.

fromM()

float helios::core::units::fromM (const float m)
constexpr noexcept

Pass-through helper for meter values.

Parameters
m

Value expressed in meters.

Returns

Same value expressed in meters.

Definition at line 93 of file Unit.ixx.

93 constexpr float fromM(const float m) noexcept {
94 return m * METERS;
95 };

Reference METERS.

Referenced by from and from.

fromM()

helios::math::vec3f helios::core::units::fromM (helios::math::vec3f v)
constexpr noexcept

Pass-through helper for meter vectors.

Parameters
v

Vector with components expressed in meters.

Returns

Vector with components expressed in meters.

Definition at line 104 of file Unit.ixx.

105 return helios::math::vec3f{v[0] * METERS, v[1] * METERS, v[2] * METERS};
106 };

Reference METERS.

fromM()

helios::math::aabbf helios::core::units::fromM (helios::math::aabbf v)
constexpr noexcept

Pass-through helper for meter AABBs.

Parameters
v

AABB with bounds expressed in meters.

Returns

AABB with bounds expressed in meters.

Definition at line 115 of file Unit.ixx.

117 v.min()[0] * METERS, v.min()[1] * METERS, v.min()[2] * METERS,
118 v.max()[0] * METERS, v.max()[1] * METERS, v.max()[2] * METERS
119 };
120 };

Reference METERS.

fromMs()

float helios::core::units::fromMs (const float ms)
constexpr noexcept

Converts milliseconds to seconds.

Parameters
ms

Value expressed in milliseconds.

Returns

Converted value expressed in seconds.

Definition at line 140 of file Unit.ixx.

140 constexpr float fromMs(const float ms) noexcept {
141 return ms * MILLISECONDS;
142 }

Reference MILLISECONDS.

Referenced by from.

fromS()

float helios::core::units::fromS (const float s)
constexpr noexcept

Converts seconds to seconds (identity helper).

Parameters
s

Value expressed in seconds.

Returns

Same value expressed in seconds.

Definition at line 129 of file Unit.ixx.

129 constexpr float fromS(const float s) noexcept {
130 return s * SECONDS;
131 }

Reference SECONDS.

Referenced by from.

Variables

CENTIMETERS

float helios::core::units::CENTIMETERS = 0.01f
constexpr

Ratio of centimeters to meters.

Definition at line 58 of file Unit.ixx.

58 constexpr float CENTIMETERS = 0.01f;

Referenced by fromCm.

HELIOS_SPATIAL_UNIT

auto helios::core::units::HELIOS_SPATIAL_UNIT = Unit::Meter
constexpr

Default length unit used throughout helios (1 meter per helios unit).

Definition at line 48 of file Unit.ixx.

HELIOS_TEMPORAL_UNIT

auto helios::core::units::HELIOS_TEMPORAL_UNIT = Unit::Seconds
constexpr

Default time unit used for all timing APIs (seconds).

Definition at line 53 of file Unit.ixx.

METERS

float helios::core::units::METERS = 1.0f
constexpr

Ratio of meters to meters (identity).

Definition at line 63 of file Unit.ixx.

63 constexpr float METERS = 1.0f;

Referenced by fromM, fromM and fromM.

MILLISECONDS

float helios::core::units::MILLISECONDS = 0.001f
constexpr

Ratio of milliseconds to seconds.

Definition at line 68 of file Unit.ixx.

68 constexpr float MILLISECONDS = 0.001f;

Referenced by fromMs.

SECONDS

float helios::core::units::SECONDS = 1.0f
constexpr

Ratio of seconds to seconds (identity).

Definition at line 73 of file Unit.ixx.

73 constexpr float SECONDS = 1.0f;

Referenced by fromS.


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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.