I am trying to build a small geometrical library in C++, that is mathematically consistent (not so false). The goal here is to construct two concepts: vectors and points. I am not sure that the following formulation is consistent (and if not, how to modify it).
First, the vectors. To construct a vector, one need two elements:
a vector space
vector_space<class Field, unsigned int Dimension>
is defined by:- a field (e.g. $\mathbb{R}$)
- a dimension (e.g. $3$)
- a basis of N vectors if the vector space has N dimensions
Having that, when one calls my_vector[0]
, or my_vector[1]
, the returned number corresponds to the components of the vector according to the given basis.
Now points (and here I am not sure of what I am saying) (you can add vectors, add a vector to a point, but not add two points). As for vector, one need two elements:
an affine space
affine_space<class VectorSpace>
that can be defined from:- a vector space
- a coordinate system
Having that, when one call my_point[0]
, or my_point[1]
, the returned number corresponds to the coordinate of the point in the provided coordinate system.
Here are my questions:
- Does it make sense (mathematically speaking) ?
- Is there a better approach (mathematically speaking) ?
- Is it correct to say that a coordinate system is for a point, what a basis is for a vector?
What is the problem domain you have in mind?
– Mark Ping Feb 28 '14 at 17:26char* + char*
to compile, even thoughchar* + std::ptrdiff_t
is fine. It is Haskell rather than C++, but are you aware of Conal Elliot's vector-space package ? I think that it is a good theoretical match for what you are doing. – Paul Delhanty Apr 23 '14 at 14:28