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 |
|---|---|
|
The generalized coordinate type. Must be |
|
The transformation data type. Must be |
|
Static function. Returns the inverse of a transformation. |
|
Static function. Composes two transformations so that applying the result is equivalent to
applying |
|
Static function ( |
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.