25 #ifndef LSST_GEOM_COORDINATEBASE_H 26 #define LSST_GEOM_COORDINATEBASE_H 37 template <
typename T,
int N = 2>
39 template <
typename T,
int N = 2>
47 template <
typename Derived,
typename T,
int N>
86 template <
typename Vector>
100 template <
typename Derived,
typename T,
int N>
102 T rtol = static_cast<T>(1E-5), T atol = static_cast<T>(1E-8));
107 template <
typename Derived,
typename T>
111 static int const dimensions = 2;
149 template <
typename Vector>
158 template <
typename Derived,
typename T>
162 static int const dimensions = 3;
200 template <
typename Vector>
206 template <
typename Derived,
typename T,
int N>
207 std::ostream& operator<<(std::ostream& os, CoordinateBase<Derived, T, N>
const& coordinate) {
208 os <<
"(" << coordinate[0];
209 for (
int n = 1; n < N; ++n) os <<
", " << coordinate[n];
Eigen::Matrix< T, 3, 1, Eigen::DontAlign > EigenVector
A CRTP base class for coordinate objects.
std::tuple< T, T, T > asTuple() const
Return a std::tuple representation of the coordinate object.
CoordinateBase(Eigen::MatrixBase< Vector > const &vector)
EigenVector const & asEigen() const
Return a fixed-size Eigen representation of the coordinate object.
T const & coeffRef(int n) const
A coordinate class intended to represent absolute positions.
std::pair< T, T > asPair() const
Return a std::pair representation of the coordinate object.
T const & operator[](int n) const
EigenVector const & asEigen() const
Return a fixed-size Eigen representation of the coordinate object.
T const & coeffRef(int n) const
Eigen::Matrix< T, 2, 1, Eigen::DontAlign > EigenVector
CoordinateBase(Eigen::MatrixBase< Vector > const &vector)
CoordinateBase(CoordinateBase const &)=default
T const & coeffRef(int n) const
Eigen::Matrix< T, N, 1, Eigen::DontAlign > EigenVector
void _swap(CoordinateBase &other)
CoordinateBase(Eigen::MatrixBase< Vector > const &vector)
Initialize all elements from an N-d Eigen vector.
CoordinateBase(T val=static_cast< T >(0))
~CoordinateBase()=default
void _swap(CoordinateBase &other)
A coordinate class intended to represent offsets and dimensions.
T const & operator[](int n) const
void _swap(CoordinateBase &other)
static int const dimensions
bool allclose(CoordinateBase< Derived, T, N > const &a, CoordinateBase< Derived, T, N > const &b, T rtol=static_cast< T >(1E-5), T atol=static_cast< T >(1E-8))
Floating-point comparison with tolerance.
CoordinateBase(T val=static_cast< T >(0))
std::tuple< T, T > asTuple() const
Return a std::tuple representation of the coordinate object.
CoordinateBase(T val=static_cast< T >(0))
Initialize all elements to a scalar.
EigenVector const & asEigen() const
Return a fixed-size Eigen representation of the coordinate object.
T const & operator[](int n) const
CoordinateBase & operator=(CoordinateBase const &)=default