Skip to content

mp_units::frame_projection

Customization point: the projection of a point from the absolute origin From to the absolute origin To

Synopsis

Declared in <mp-units/framework/quantity_point_concepts.h>

template<
  /* implementation-defined */ auto From,
  /* implementation-defined */ auto To>
  requires(From != To)
inline constexpr utility::unspecified_t frame_projection;

Description

Two absolute origins are unrelated until a specialization connects them with a callable that takes a point measured from From, and any extra arguments, and returns the point measured from To. It covers what the fixed offset of a relative origin can't, such as an axis that flips, a formula, or calibration data known only at runtime. point_for then converts between the two:

inline constexpr struct sea_level final :
  absolute_point_origin<isq::altitude> {} sea_level;
inline constexpr struct ocean_surface final :
  absolute_point_origin<isq::altitude> {} ocean_surface;

// the ocean-surface frame counts downwards, as a depth does
template<>
inline constexpr auto mp_units::frame_projection<sea_level, ocean_surface> =
  [](QuantityPointOf<isq::altitude> auto qp) {
    return ocean_surface - qp.delta_from(sea_level);
  };

quantity_point altitude = sea_level + isq::altitude(-100. * m);
quantity_point depth = altitude.point_for(ocean_surface);  // 100 m from ocean_surface

The library never derives the inverse, so each direction is specialized on its own.

Template Parameters

NameDescription
Fromthe absolute origin the point is measured from
Tothe absolute origin the point is projected to

See Also