coordsys_traits

namespace nin {
    template <typename CT>
    concept coordsys_traits;
}

Any space of coordinate systems must satisfy the coordsys_traits concept. A traits type defines three things: what coordinates look like, what transformations look like, and how to apply and compose those transformations. This is the extension point for defining entirely new kinds of coordinate systems — R2, R3, or any user-defined space.

Requirements

A type CT satisfies coordsys_traits if it provides:

Requirement Description

CT::quantity_type

The generalized coordinate type. Must be std::semiregular with noexcept default construction and move.

CT::tf_data_type

The transformation data type. Must be std::semiregular with noexcept default construction and move. Must be a different type from quantity_type.

CT::invert_tf(tf_data_type tf) → tf_data_type

Static function. Returns the inverse of a transformation.

CT::compose_tf(tf_data_type after, tf_data_type first) → tf_data_type

Static function. Composes two transformations so that applying the result is equivalent to applying first then after.

CT::transform_coords(tf_data_type tf, quantity_type qty) → quantity_type

Static function (noexcept). Applies a transformation to coordinates, returning the transformed coordinates.

quantity_type and tf_data_type must be distinct types to prevent accidental misuse — a transformation is not a coordinate and vice versa.

Example

The R2 and R3 namespaces each define a struct that satisfies coordsys_traits. A minimal custom traits type might look like:

struct my_traits
{
    using quantity_type = my_position;
    using tf_data_type  = my_transform;

    static tf_data_type  invert_tf(tf_data_type tf);
    static tf_data_type  compose_tf(tf_data_type after, tf_data_type first);
    static quantity_type transform_coords(tf_data_type tf, quantity_type qty) noexcept;
};

Once my_traits satisfies the concept, coordsys<my_traits> becomes a valid coordinate system type, and all the generic infrastructure — coord_value, coord_cloud, mapCS(), coord_tf — works with it automatically.