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.");
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>
139 : _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) {}
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];
afw::table::PointKey< int > dimensions
void _swap(CoordinateBase &other) noexcept
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)
void setX(T x) noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
CoordinateBase(Eigen::MatrixBase< Vector > const &vector)
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
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
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 constexpr bool IS_ELEMENT_NOTHROW_COPYABLE
static int const dimensions
CoordinateBase & operator=(CoordinateBase &&other) noexcept(IS_ELEMENT_NOTHROW_ASSIGNABLE)
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.