25 #ifndef LSST_GEOM_COORDINATEBASE_H 26 #define LSST_GEOM_COORDINATEBASE_H 29 #include <type_traits> 38 template <
typename T,
int N = 2>
40 template <
typename T,
int N = 2>
44 template <
typename T,
typename U>
53 template <
typename Derived,
typename T,
int N>
56 static_assert(N > 0,
"CoordinateBase must have a positive length.");
89 EigenVector
const&
asEigen() const noexcept(IS_ELEMENT_NOTHROW_COPYABLE) {
return _vector; }
105 template <
typename Vector>
119 template <
typename Derived,
typename T,
int N>
121 T rtol = static_cast<T>(1E-5),
122 T atol = static_cast<T>(1E-8)) noexcept(
std::is_nothrow_copy_constructible<
T>::value&&
123 std::is_nothrow_copy_assignable<
T>::value);
128 template <typename Derived, typename
T>
132 static int const dimensions = 2;
163 EigenVector
const&
asEigen() const noexcept(IS_ELEMENT_NOTHROW_COPYABLE) {
return _vector; }
186 template <
typename Vector>
195 template <
typename Derived,
typename T>
199 static int const dimensions = 3;
230 EigenVector
const&
asEigen() const noexcept(IS_ELEMENT_NOTHROW_COPYABLE) {
return _vector; }
251 template <
typename Vector>
257 template <
typename Derived,
typename T,
int N>
258 std::ostream& operator<<(std::ostream& os, CoordinateBase<Derived, T, N>
const& coordinate) {
259 os <<
"(" << coordinate[0];
260 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.
T const & getX() const noexcept
std::tuple< T, T, T > asTuple() const noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
Return a std::tuple representation of the coordinate object.
CoordinateBase(Eigen::MatrixBase< Vector > const &vector)
void setY(T y) noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
T const & coeffRef(int n) const
A coordinate class intended to represent absolute positions.
T const & getY() const noexcept
T const & getZ() const noexcept
T const & operator[](int n) const
CoordinateBase & operator=(CoordinateBase const &other) noexcept(IS_ELEMENT_NOTHROW_ASSIGNABLE)
T const & coeffRef(int n) const
CoordinateBase & operator=(CoordinateBase &&other) noexcept(IS_ELEMENT_NOTHROW_ASSIGNABLE)
ItemVariant const * other
void _swap(CoordinateBase &other) noexcept
Eigen::Matrix< T, 2, 1, Eigen::DontAlign > EigenVector
CoordinateBase(Eigen::MatrixBase< Vector > const &vector)
CoordinateBase & operator=(CoordinateBase &&other) noexcept(IS_ELEMENT_NOTHROW_ASSIGNABLE)
void _swap(CoordinateBase &other) noexcept
EigenVector const & asEigen() const noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
Return a fixed-size Eigen representation of the coordinate object.
void setX(T x) noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
CoordinateBase(T val=static_cast< T >(0)) noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
T const & coeffRef(int n) const
T const & getX() const noexcept
Eigen::Matrix< T, N, 1, Eigen::DontAlign > EigenVector
std::tuple< T, T > asTuple() const noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
Return a std::tuple representation of the coordinate object.
A base class for image defects.
CoordinateBase(Eigen::MatrixBase< Vector > const &vector)
Initialize all elements from an N-d Eigen vector.
CoordinateBase(CoordinateBase const &other) noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
T const & getY() const noexcept
static bool constexpr IS_ELEMENT_NOTHROW_COPYABLE
A coordinate class intended to represent offsets and 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)) noexcept(std::is_nothrow_copy_constructible< T >::value &&std::is_nothrow_copy_assignable< T >::value)
Floating-point comparison with tolerance.
bool constexpr IS_NOTHROW_CONVERTIBLE
Test that a type is nothrow-copy-convertible from U to T.
static bool constexpr IS_ELEMENT_NOTHROW_ASSIGNABLE
CoordinateBase & operator=(CoordinateBase &&other) noexcept(IS_ELEMENT_NOTHROW_ASSIGNABLE)
CoordinateBase(CoordinateBase const &other) noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
CoordinateBase(T val=static_cast< T >(0)) noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
Initialize all elements to a scalar.
T const & operator[](int n) const
static int const dimensions
CoordinateBase(CoordinateBase const &other) noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
EigenVector const & asEigen() const noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
Return a fixed-size Eigen representation of the coordinate object.
void _swap(CoordinateBase &other) noexcept
void setX(T x) noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
~CoordinateBase() noexcept=default
void setY(T y) noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
CoordinateBase(T val=static_cast< T >(0)) noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
std::pair< T, T > asPair() const noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
Return a std::pair representation of the coordinate object.
CoordinateBase(CoordinateBase &&other) noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
void setZ(T z) noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
EigenVector const & asEigen() const noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
Return a fixed-size Eigen representation of the coordinate object.
CoordinateBase(CoordinateBase &&other) noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
CoordinateBase & operator=(CoordinateBase const &other) noexcept(IS_ELEMENT_NOTHROW_ASSIGNABLE)
T const & operator[](int n) const
CoordinateBase(CoordinateBase &&other) noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
CoordinateBase & operator=(CoordinateBase const &other) noexcept(IS_ELEMENT_NOTHROW_ASSIGNABLE)