Currently positions in space are handled with a std::pair<double, double>. I don't like this for a couple of reasons:
std::pair is designed for heterogeneous collections of objects, not for things with the same type
Doesn't generalise well to higher dimensions
I suggest adding a lightweight Vector class in the mbd:: namespace, such that a vector would be declared as mbd::Vector<int, 3>, say, for a 3-d vector of ints.
Then wherever relevant, using Coords2d = mbd::Vector<double, 2>; to provide a coordinate type. If, in the future, a linear algebra library such as Eigen was used, all that would need to change is the using type alias.
Currently positions in space are handled with a
std::pair<double, double>
. I don't like this for a couple of reasons:std::pair
is designed for heterogeneous collections of objects, not for things with the same typeI suggest adding a lightweight
Vector
class in thembd::
namespace, such that a vector would be declared asmbd::Vector<int, 3>
, say, for a 3-d vector of ints.Then wherever relevant,
using Coords2d = mbd::Vector<double, 2>;
to provide a coordinate type. If, in the future, a linear algebra library such asEigen
was used, all that would need to change is theusing
type alias.