:doc:`algorithms` are typically templated and written in a way that abstract over the actual math library.
Polymesh assumes that the type used for positions and vectors can be different (e.g. ``tg::pos3`` vs. ``tg::vec3`` in Typed Geometry) or the same (e.g. ``glm::vec3`` in GLM).
Your own math types should work as long as the following operations are provided:
* ``pos - pos -> vec``
* ``pos + vec -> pos``
* ``pos - vec -> pos``
* ``vec + vec -> vec``
* ``vec - vec -> vec``
* ``vec * scalar -> vec``
* ``vec / scalar -> vec``
* ``pos * scalar -> pos``
* ``pos / scalar -> pos``
* ``pos[int-literal] -> scalar``
* ``vec[int-literal] -> scalar``
* ``pos`` and ``vec`` default constructor
* ``pos``, ``vec``, and ``scalar`` behave like value types
(Algorithms should only use right multiplication with scalars. Violations should be reported as defects.)
Contributing Algorithms
-----------------------
Algorithms should be written such that they can be used with custom math types.
They must only rely on the previously mentioned operations.
The utility header ``fields.hh`` contains the type ``pm::field3<Pos3>`` which contains a few helper functions like ``dot``, ``cross``, and ``length``.
NOTE: this only concerns authors of new ``polymesh::`` algorithms.