25#ifndef LSST_GEOM_COORDINATEBASE_H
26#define LSST_GEOM_COORDINATEBASE_H
38template <
typename T,
int N = 2>
40template <
typename T,
int N = 2>
44template <
typename T,
typename U>
53template <
typename Derived,
typename T,
int N>
56 static_assert(N > 0,
"CoordinateBase must have a positive length.");
78 T& operator[](
int n) {
return _vector[n]; }
105 template <
typename Vector>
119template <
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);
128template <typename Derived, typename T>
186 template <
typename Vector>
195template <
typename Derived,
typename T>
251 template <
typename Vector>
257template <
typename Derived,
typename T,
int N>
259 os <<
"(" << coordinate[0];
260 for (
int n = 1; n < N; ++n) os <<
", " << coordinate[n];
void _swap(CoordinateBase &other) noexcept
static bool constexpr IS_ELEMENT_NOTHROW_COPYABLE
CoordinateBase & operator=(CoordinateBase const &other) noexcept(IS_ELEMENT_NOTHROW_ASSIGNABLE)
Eigen::Matrix< T, 2, 1, Eigen::DontAlign > EigenVector
CoordinateBase(T val=static_cast< T >(0)) noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
EigenVector const & asEigen() const noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
Return a fixed-size Eigen representation of the coordinate object.
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)
static bool constexpr IS_ELEMENT_NOTHROW_ASSIGNABLE
void setX(T x) noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
CoordinateBase(Eigen::MatrixBase< Vector > const &vector)
static int const dimensions
void setY(T y) noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
T const & operator[](int n) const
~CoordinateBase() noexcept=default
T const & getY() const noexcept
CoordinateBase & operator=(CoordinateBase &&other) noexcept(IS_ELEMENT_NOTHROW_ASSIGNABLE)
std::tuple< T, T > asTuple() const noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
Return a std::tuple representation of the coordinate object.
CoordinateBase(CoordinateBase const &other) noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
T const & getX() const noexcept
T const & coeffRef(int n) const
void setX(T x) noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
void setY(T y) noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
Eigen::Matrix< T, 3, 1, Eigen::DontAlign > EigenVector
void setZ(T z) noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
T const & operator[](int n) const
T const & getX() const noexcept
CoordinateBase(CoordinateBase &&other) noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
void _swap(CoordinateBase &other) noexcept
std::tuple< T, T, T > asTuple() const noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
Return a std::tuple representation of the coordinate object.
CoordinateBase(T val=static_cast< T >(0)) noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
CoordinateBase & operator=(CoordinateBase &&other) noexcept(IS_ELEMENT_NOTHROW_ASSIGNABLE)
T const & getY() const noexcept
T const & getZ() const noexcept
~CoordinateBase() noexcept=default
static bool constexpr IS_ELEMENT_NOTHROW_ASSIGNABLE
static bool constexpr IS_ELEMENT_NOTHROW_COPYABLE
EigenVector const & asEigen() const noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
Return a fixed-size Eigen representation of the coordinate object.
CoordinateBase & operator=(CoordinateBase const &other) noexcept(IS_ELEMENT_NOTHROW_ASSIGNABLE)
CoordinateBase(CoordinateBase const &other) noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
T const & coeffRef(int n) const
static int const dimensions
CoordinateBase(Eigen::MatrixBase< Vector > const &vector)
A CRTP base class for coordinate objects.
CoordinateBase & operator=(CoordinateBase const &other) noexcept(IS_ELEMENT_NOTHROW_ASSIGNABLE)
void _swap(CoordinateBase &other) noexcept
CoordinateBase(CoordinateBase &&other) noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
Eigen::Matrix< T, N, 1, Eigen::DontAlign > EigenVector
EigenVector const & asEigen() const noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
Return a fixed-size Eigen representation of the coordinate object.
T const & coeffRef(int n) const
~CoordinateBase() noexcept=default
CoordinateBase(T val=static_cast< T >(0)) noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
Initialize all elements to a scalar.
CoordinateBase(CoordinateBase const &other) noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
T const & operator[](int n) const
static int const dimensions
CoordinateBase & operator=(CoordinateBase &&other) noexcept(IS_ELEMENT_NOTHROW_ASSIGNABLE)
static bool constexpr IS_ELEMENT_NOTHROW_COPYABLE
static bool constexpr IS_ELEMENT_NOTHROW_ASSIGNABLE
CoordinateBase(Eigen::MatrixBase< Vector > const &vector)
Initialize all elements from an N-d Eigen vector.
A coordinate class intended to represent offsets and dimensions.
A coordinate class intended to represent absolute positions.
bool constexpr IS_NOTHROW_CONVERTIBLE
Test that a type is nothrow-copy-convertible from U to T.
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.
std::ostream & operator<<(std::ostream &os, lsst::geom::AffineTransform const &transform)