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.");
78 T& operator[](
int n) {
return _vector[n]; }
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>
139 : _vector(
other._vector) {}
141 : _vector(
std::move(
other._vector)) {}
143 _vector =
other._vector;
152 T& operator[](
int n) {
return _vector[n]; }
165 T
const&
getX() const noexcept {
return _vector.x(); }
166 T
const&
getY() const noexcept {
return _vector.y(); }
167 T&
getX() noexcept {
return _vector.x(); }
168 T&
getY() noexcept {
return _vector.y(); }
169 void setX(T
x) noexcept(IS_ELEMENT_NOTHROW_COPYABLE) { _vector.x() =
x; }
170 void setY(T
y) noexcept(IS_ELEMENT_NOTHROW_COPYABLE) { _vector.y() =
y; }
186 template <
typename Vector>
187 explicit CoordinateBase(Eigen::MatrixBase<Vector>
const& vector) : _vector(vector) {}
195 template <
typename Derived,
typename T>
251 template <
typename Vector>
257 template <
typename Derived,
typename T,
int N>
259 os <<
"(" << coordinate[0];
260 for (
int n = 1; n < N; ++n)
os <<
", " << coordinate[n];
afw::table::PointKey< int > dimensions
ItemVariant const * other
EigenVector const & asEigen() const noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
Return a fixed-size Eigen representation of the coordinate object.
T const & getX() const noexcept
void _swap(CoordinateBase &other) noexcept
T const & coeffRef(int n) const
Eigen::Matrix< T, 2, 1, Eigen::DontAlign > EigenVector
T const & getY() const noexcept
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 setX(T x) noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
CoordinateBase(Eigen::MatrixBase< Vector > const &vector)
CoordinateBase & operator=(CoordinateBase &&other) noexcept(IS_ELEMENT_NOTHROW_ASSIGNABLE)
CoordinateBase & operator=(CoordinateBase const &other) noexcept(IS_ELEMENT_NOTHROW_ASSIGNABLE)
void setY(T y) noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
T const & operator[](int n) const
~CoordinateBase() noexcept=default
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)
void setX(T x) noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
CoordinateBase & operator=(CoordinateBase const &other) noexcept(IS_ELEMENT_NOTHROW_ASSIGNABLE)
std::tuple< T, T, T > asTuple() const noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
Return a std::tuple representation of the coordinate object.
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)
CoordinateBase & operator=(CoordinateBase &&other) noexcept(IS_ELEMENT_NOTHROW_ASSIGNABLE)
CoordinateBase(CoordinateBase &&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
CoordinateBase(T val=static_cast< T >(0)) noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
~CoordinateBase() noexcept=default
T const & getY() const noexcept
T const & getZ() const noexcept
T const & operator[](int n) const
T const & coeffRef(int n) const
CoordinateBase(CoordinateBase const &other) noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
T const & getX() const noexcept
CoordinateBase(Eigen::MatrixBase< Vector > const &vector)
A CRTP base class for coordinate objects.
void _swap(CoordinateBase &other) noexcept
CoordinateBase(CoordinateBase &&other) noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
Eigen::Matrix< T, N, 1, Eigen::DontAlign > EigenVector
~CoordinateBase() noexcept=default
CoordinateBase & operator=(CoordinateBase const &other) noexcept(IS_ELEMENT_NOTHROW_ASSIGNABLE)
EigenVector const & asEigen() const noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
Return a fixed-size Eigen representation of the coordinate object.
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)
CoordinateBase & operator=(CoordinateBase &&other) noexcept(IS_ELEMENT_NOTHROW_ASSIGNABLE)
static constexpr bool IS_ELEMENT_NOTHROW_COPYABLE
T const & operator[](int n) const
static int const dimensions
T const & coeffRef(int n) const
CoordinateBase(Eigen::MatrixBase< Vector > const &vector)
Initialize all elements from an N-d Eigen vector.
static constexpr bool IS_ELEMENT_NOTHROW_ASSIGNABLE
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.
constexpr bool IS_NOTHROW_CONVERTIBLE
Test that a type is nothrow-copy-convertible from U to T.
std::ostream & operator<<(std::ostream &os, lsst::geom::AffineTransform const &transform)
A base class for image defects.