LSSTApplications  12.1-5-gbdcc3ab+2,15.0+13,15.0+26,15.0-1-g19261fa+17,15.0-1-g60afb23+26,15.0-1-g615e0bb+18,15.0-1-g788a293+26,15.0-1-ga91101e+26,15.0-1-gae1598d+12,15.0-1-gd076f1f+24,15.0-1-gdf18595+5,15.0-1-gf4f1c34+12,15.0-11-g7db6e543+4,15.0-12-g3681e7a+4,15.0-15-gc15de322,15.0-16-g83b84f4,15.0-2-g100d730+19,15.0-2-g1f9c9cf+4,15.0-2-g8aea5f4+1,15.0-2-gf38729e+21,15.0-29-ga12a2b06e,15.0-3-g11fe1a0+14,15.0-3-g707930d+3,15.0-3-g9103c06+12,15.0-3-gd3cbb57+3,15.0-4-g2d82b59,15.0-4-g535e784+10,15.0-4-g92ca6c3+4,15.0-4-gf906033+2,15.0-5-g23e394c+14,15.0-5-g4be42a9,15.0-6-g69628aa,15.0-6-g86e3f3d+1,15.0-6-gfa9b38f+4,15.0-7-g949993c+3,15.0-8-g67a62d3+1,15.0-8-gcf05001+1,15.0-9-g1e7c341+1,w.2018.21
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Related Functions | List of all members
lsst::afw::geom::CoordinateBase< Derived, T, N > Class Template Reference

A CRTP base class for coordinate objects. More...

#include <CoordinateBase.h>

Public Types

typedef T Element
 
typedef Eigen::Matrix< T, N, 1, Eigen::DontAlign > EigenVector
 

Public Member Functions

 CoordinateBase (CoordinateBase const &)=default
 
 CoordinateBase (CoordinateBase &&)=default
 
CoordinateBaseoperator= (CoordinateBase const &)=default
 
CoordinateBaseoperator= (CoordinateBase &&)=default
 
 ~CoordinateBase ()=default
 
T & operator[] (int n)
 
T const & operator[] (int n) const
 
T & coeffRef (int n)
 
T const & coeffRef (int n) const
 
EigenVector const & asEigen () const
 Return a fixed-size Eigen representation of the coordinate object. More...
 

Static Public Attributes

static int const dimensions = N
 

Protected Member Functions

 CoordinateBase (T val=static_cast< T >(0))
 Initialize all elements to a scalar. More...
 
template<typename Vector >
 CoordinateBase (Eigen::MatrixBase< Vector > const &vector)
 Initialize all elements from an N-d Eigen vector. More...
 
void _swap (CoordinateBase &other)
 

Protected Attributes

EigenVector _vector
 

Related Functions

(Note that these are not member functions.)

template<typename Derived , typename T , int N>
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. More...
 

Detailed Description

template<typename Derived, typename T, int N>
class lsst::afw::geom::CoordinateBase< Derived, T, N >

A CRTP base class for coordinate objects.

CoordinateBase has partial specializations for 2 and 3 dimensions so its subclasses don't have to.

Definition at line 52 of file CoordinateBase.h.

Member Typedef Documentation

◆ EigenVector

template<typename Derived, typename T, int N>
typedef Eigen::Matrix<T, N, 1, Eigen::DontAlign> lsst::afw::geom::CoordinateBase< Derived, T, N >::EigenVector

Definition at line 56 of file CoordinateBase.h.

◆ Element

template<typename Derived, typename T, int N>
typedef T lsst::afw::geom::CoordinateBase< Derived, T, N >::Element

Definition at line 54 of file CoordinateBase.h.

Constructor & Destructor Documentation

◆ CoordinateBase() [1/4]

template<typename Derived, typename T, int N>
lsst::afw::geom::CoordinateBase< Derived, T, N >::CoordinateBase ( CoordinateBase< Derived, T, N > const &  )
default

◆ CoordinateBase() [2/4]

template<typename Derived, typename T, int N>
lsst::afw::geom::CoordinateBase< Derived, T, N >::CoordinateBase ( CoordinateBase< Derived, T, N > &&  )
default

◆ ~CoordinateBase()

template<typename Derived, typename T, int N>
lsst::afw::geom::CoordinateBase< Derived, T, N >::~CoordinateBase ( )
default

◆ CoordinateBase() [3/4]

template<typename Derived, typename T, int N>
lsst::afw::geom::CoordinateBase< Derived, T, N >::CoordinateBase ( val = static_cast<T>(0))
inlineexplicitprotected

Initialize all elements to a scalar.

A public constructor with the same signature is expected for subclasses.

Definition at line 83 of file CoordinateBase.h.

83 : _vector(EigenVector::Constant(val)) {}
ImageT val
Definition: CR.cc:158

◆ CoordinateBase() [4/4]

template<typename Derived, typename T, int N>
template<typename Vector >
lsst::afw::geom::CoordinateBase< Derived, T, N >::CoordinateBase ( Eigen::MatrixBase< Vector > const &  vector)
inlineexplicitprotected

Initialize all elements from an N-d Eigen vector.

A public constructor with the same signature is expected for subclasses.

Definition at line 91 of file CoordinateBase.h.

91 : _vector(vector) {}

Member Function Documentation

◆ _swap()

template<typename Derived, typename T, int N>
void lsst::afw::geom::CoordinateBase< Derived, T, N >::_swap ( CoordinateBase< Derived, T, N > &  other)
inlineprotected

Definition at line 93 of file CoordinateBase.h.

93 { _vector.swap(other._vector); }
ItemVariant const * other
Definition: Schema.cc:55

◆ asEigen()

template<typename Derived, typename T, int N>
EigenVector const& lsst::afw::geom::CoordinateBase< Derived, T, N >::asEigen ( ) const
inline

Return a fixed-size Eigen representation of the coordinate object.

The fact that this returns by const reference rather than by value should not be considered part of the API; this is merely an optimization enabled by the implementation.

Definition at line 75 of file CoordinateBase.h.

75 { return _vector; }

◆ coeffRef() [1/2]

template<typename Derived, typename T, int N>
T& lsst::afw::geom::CoordinateBase< Derived, T, N >::coeffRef ( int  n)
inline

Definition at line 66 of file CoordinateBase.h.

66 { return _vector.coeffRef(n); }

◆ coeffRef() [2/2]

template<typename Derived, typename T, int N>
T const& lsst::afw::geom::CoordinateBase< Derived, T, N >::coeffRef ( int  n) const
inline

Definition at line 67 of file CoordinateBase.h.

67 { return const_cast<EigenVector&>(_vector).coeffRef(n); }
Eigen::Matrix< T, N, 1, Eigen::DontAlign > EigenVector

◆ operator=() [1/2]

template<typename Derived, typename T, int N>
CoordinateBase& lsst::afw::geom::CoordinateBase< Derived, T, N >::operator= ( CoordinateBase< Derived, T, N > const &  )
default

◆ operator=() [2/2]

template<typename Derived, typename T, int N>
CoordinateBase& lsst::afw::geom::CoordinateBase< Derived, T, N >::operator= ( CoordinateBase< Derived, T, N > &&  )
default

◆ operator[]() [1/2]

template<typename Derived, typename T, int N>
T& lsst::afw::geom::CoordinateBase< Derived, T, N >::operator[] ( int  n)
inline

Definition at line 64 of file CoordinateBase.h.

64 { return _vector[n]; }

◆ operator[]() [2/2]

template<typename Derived, typename T, int N>
T const& lsst::afw::geom::CoordinateBase< Derived, T, N >::operator[] ( int  n) const
inline

Definition at line 65 of file CoordinateBase.h.

65 { return const_cast<EigenVector&>(_vector)[n]; }
Eigen::Matrix< T, N, 1, Eigen::DontAlign > EigenVector

Friends And Related Function Documentation

◆ allclose()

template<typename Derived , typename T , int N>
bool allclose ( CoordinateBase< Derived, T, N > const &  a,
CoordinateBase< Derived, T, N > const &  b,
rtol = static_cast< T >(1E-5),
atol = static_cast< T >(1E-8) 
)
related

Floating-point comparison with tolerance.

Interface, naming, and default tolerances matches Numpy.

Definition at line 32 of file CoordinateBase.cc.

33  {
34  Eigen::Array<T, N, 1> diff = (a.asEigen().array() - b.asEigen().array()).abs();
35  Eigen::Array<T, N, 1> rhs = (0.5 * (a.asEigen().array() + b.asEigen().array())).abs();
36  rhs *= rtol;
37  rhs += atol;
38  return (diff <= rhs).all();
39 }
T atol(T... args)
Angle abs(Angle const &a)
Definition: Angle.h:106
table::Key< int > b
table::Key< int > a

Member Data Documentation

◆ _vector

template<typename Derived, typename T, int N>
EigenVector lsst::afw::geom::CoordinateBase< Derived, T, N >::_vector
protected

Definition at line 94 of file CoordinateBase.h.

◆ dimensions

template<typename Derived, typename T, int N>
int const lsst::afw::geom::CoordinateBase< Derived, T, N >::dimensions = N
static

Definition at line 55 of file CoordinateBase.h.


The documentation for this class was generated from the following file: