31#ifndef MJR_INCLUDE_MRpoint2d
44 template <
class coordT>
45 requires (std::is_arithmetic<coordT>::value)
56 point2d(std::initializer_list<coordT> iList) {
auto p=iList.begin(); x=*p; y=*(++p); }
60 point2d(coordT newX, coordT newY) { x=newX; y=newY; }
62 point2d(std::complex<coordT> aComplex) { x=aComplex.real(); y=aComplex.imag(); }
64 point2d(std::tuple<coordT, coordT> aTuple) { x=std::get<0>(aTuple); y=std::get<1>(aTuple); }
66 point2d(std::vector<coordT> aVector) { x=aVector[0]; y=aVector[1]; }
68 point2d(coordT* aPtr) { x=aPtr[0]; y=aPtr[1]; }
73 operator std::complex<coordT>() {
return std::complex<coordT>(x, y); }
80#define MJR_INCLUDE_MRpoint2d
Handy class to hold a point in 2D (integer or real)
point2d(std::complex< coordT > aComplex)
Construct from a complex number.
point2d(std::initializer_list< coordT > iList)
Construct from an initializer_list.
point2d(coordT *aPtr)
Construct from a C-style array.
point2d(std::tuple< coordT, coordT > aTuple)
Construct from a tuple.
point2d()=default
Default constructor.
point2d(std::vector< coordT > aVector)
Construct from a vector.
point2d(const point2d &aPoint)
Construct from a point2d object – copy constructor.
point2d(coordT newX, coordT newY)
Construct from coordinates.