From Wikipedia:
In an affine space, there is no distinguished point that serves as an origin. Hence, no vector has a fixed origin and no vector can be uniquely associated to a point. In an affine space, there are instead displacement vectors [...] between two points of the space.
Thus it makes sense to subtract two points of the space, giving a translation vector, but it does not make sense to add two points of the space. Likewise, it makes sense to add a displacement vector to a point of an affine space, resulting in a new point translated from the starting point by that vector.
Type or category theoretically (or API design-wise), a displacement vector is conceptually of a different type than than the points in the space (despite both being representable as vectors), and operators/operations exist such that they take an return arguments of different types.
C++ has several examples of of such types and associated algebras:
- The most basic: Pointers (addresses in the memory address space) are distinct types from integers, they cannot be added together, but can be subtracted to give an integer or incremented by integers.
- The standard
<chrono>
time header definestime_point
s andduration
s.
Other examples include geometry primitives like 2D, 3D...ND points or physical measurements like distances, time (see above), or any SI units.
Interestingly this aspect is orthogonal to aspects of unit-types.
I'm looking for literature and discussion of Affine Spaces in the context of Type-Theory (or Abstract Algebra). Specifically any formal definition of an algebra or specifications of the axioms or properties.
(I am not a mathematician so please forgive (and correct) any erroneous terminology).