29 #ifndef LSST_AFW_GEOM_EXTENT_H
30 #define LSST_AFW_GEOM_EXTENT_H
32 #include <boost/type_traits/is_integral.hpp>
33 #include <boost/static_assert.hpp>
34 #include <boost/type_traits/is_same.hpp>
39 namespace lsst {
namespace afw {
namespace geom {
52 pex::exceptions::LogicError,
53 "Cannot compute norm of integer extent"
55 #if 1 // make compilers happy in non-void function
63 template<
typename T,
int N>
153 std::stringstream out;
155 for (
size_t i = 0; i < N; ++i) {
171 template <
typename Vector>
185 template<
typename T,
int N>
186 class Extent :
public ExtentBase<T,N> {
249 explicit Extent(boost::tuple<T,T>
const & xy) :
293 explicit Extent(boost::tuple<T,T,T>
const & xyz) :
294 Super(
EigenVector(xyz.template get<0>(), xyz.template get<1>(), xyz.template get<2>())) {}
313 BOOST_STATIC_ASSERT( (!boost::is_same<T,U>::value && boost::is_integral<U>::value) );
314 this->setX(static_cast<T>(other.getX()));
315 this->setY(static_cast<T>(other.getY()));
322 BOOST_STATIC_ASSERT( (!boost::is_same<T,U>::value && boost::is_integral<U>::value) );
323 this->setX(static_cast<T>(other.getX()));
324 this->setY(static_cast<T>(other.getY()));
332 BOOST_STATIC_ASSERT( (!boost::is_same<T,U>::value && boost::is_integral<U>::value) );
333 this->setX(static_cast<T>(other.getX()));
334 this->setY(static_cast<T>(other.getY()));
335 this->setZ(static_cast<T>(other.getZ()));
343 BOOST_STATIC_ASSERT( (!boost::is_same<T,U>::value && boost::is_integral<U>::value) );
344 this->setX(static_cast<T>(other.getX()));
345 this->setY(static_cast<T>(other.getY()));
346 this->setZ(static_cast<T>(other.getZ()));
Extent< T, N > operator/(T scalar) const
Extent< double, 3 > Extent3D
Extent(std::pair< T, T > const &xy)
Construct from a std::pair.
A coordinate class intended to represent absolute positions (2-d specialization). ...
Extent(T x, T y)
Construct from two scalars.
Extent(boost::tuple< T, T, T > const &xyz)
Construct from boost::tuple.
Extent(T val=static_cast< T >(0))
Construct an Extent with all elements set to the same scalar value.
Extent(boost::tuple< T, T > const &xy)
Construct from boost::tuple.
bool all(CoordinateExpr< N > const &expr)
Return true if all elements are true.
CoordinateExpr< N > gt(T scalar) const
Extent(T const xy[2])
Construct from a two-element array.
Super::EigenVector EigenVector
CoordinateBase< Extent< T, N >, T, N > Super
Extent(EigenVector const &vector)
Construct an Extent from an Eigen vector.
A coordinate class intended to represent offsets and dimensions.
Extent< T, N > & operator*=(T scalar)
Extent(T const xyz[3])
Construct from a two-element array.
Extent< T, N > & operator/=(T scalar)
Super::EigenVector EigenVector
Extent< T, N > operator*(T scalar) const
A boolean pair class used to express the output of spatial predicates on Point and Extent...
CoordinateExpr< N > gt(Extent< T, N > const &other) const
Eigen::Matrix< T, N, 1, Eigen::DontAlign > EigenVector
Extent< int, 2 > Extent2I
bool operator!=(Extent< T, N > const &other) const
Standard inequality comparison.
Extent< T, N > operator-(Extent< T, N > const &other) const
A CRTP base class for coordinate objects.
A coordinate class intended to represent absolute positions.
Extent< double, 2 > ExtentD
bool any(CoordinateExpr< N > const &expr)
Return true if any elements are true.
Extent< T, N > & operator+=(Extent< T, N > const &other)
Include files required for standard LSST Exception handling.
T computeSquaredNorm() const
Return the squared L2 norm of the Extent (x^2 + y^2 + ...).
Extent< T, N > operator-() const
Extent< T, N > operator+(Extent< T, N > const &other) const
CoordinateExpr< N > lt(Extent< T, N > const &other) const
T computeSquaredNorm() const
Return the squared L2 norm of the Extent (x^2 + y^2 + ...).
double computeExtentNorm(Extent< double, N > const &s)
T computeNorm() const
Return the L2 norm of the Extent (sqrt(x^2 + y^2 + ...)).
Extent(EigenVector const &vector)
Construct an Extent from an Eigen vector.
std::string toString() const
CoordinateExpr< N > ge(T scalar) const
Extent< int, 3 > Extent3I
Extent< T, N > operator+() const
bool operator==(Extent< T, N > const &other) const
Standard equality comparison.
ExtentBase(Eigen::MatrixBase< Vector > const &vector)
Construct an Extent from an Eigen vector.
void _swap(CoordinateBase &other)
#define LSST_EXCEPT(type,...)
CoordinateExpr< N > eq(T scalar) const
Super::EigenVector EigenVector
CoordinateExpr< N > le(Extent< T, N > const &other) const
EigenVector const & asEigen() const
Return a fixed-size Eigen representation of the coordinate object.
CoordinateExpr< N > ne(T scalar) const
Extent(T x, T y, T z)
Construct from three scalars.
CoordinateExpr< N > ge(Extent< T, N > const &other) const
CoordinateExpr< N > lt(T scalar) const
CoordinateExpr< N > le(T scalar) const
Extent< double, 2 > Extent2D
CoordinateExpr< N > eq(Extent< T, N > const &other) const
T computeNorm() const
Return the L2 norm of the Extent (sqrt(x^2 + y^2 + ...)).
ExtentBase(T val=static_cast< T >(0))
Construct an Extent<T,N> with all elements set to the same scalar value.
Extent(T val=static_cast< T >(0))
Construct an Extent with all elements set to the same scalar value.
Extent(EigenVector const &vector)
Construct an Extent from an Eigen vector.
Extent< T, N > & operator-=(Extent< T, N > const &other)
CoordinateExpr< N > ne(Extent< T, N > const &other) const
Extent(T val=static_cast< T >(0))
Construct an Extent with all elements set to the same scalar value.
A coordinate class intended to represent absolute positions (3-d specialization). ...