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>
156 std::stringstream out;
158 for (
size_t i = 0; i < N; ++i) {
174 template <
typename Vector>
186 template<
typename T,
int N>
187 class Extent :
public ExtentBase<T,N> {
252 explicit Extent(boost::tuple<T,T>
const & xy) :
298 explicit Extent(boost::tuple<T,T,T>
const & xyz) :
299 Super(
EigenVector(xyz.template get<0>(), xyz.template get<1>(), xyz.template get<2>())) {}
318 BOOST_STATIC_ASSERT( (!boost::is_same<T,U>::value && boost::is_integral<U>::value) );
319 this->setX(static_cast<T>(other.getX()));
320 this->setY(static_cast<T>(other.getY()));
327 BOOST_STATIC_ASSERT( (!boost::is_same<T,U>::value && boost::is_integral<U>::value) );
328 this->setX(static_cast<T>(other.getX()));
329 this->setY(static_cast<T>(other.getY()));
337 BOOST_STATIC_ASSERT( (!boost::is_same<T,U>::value && boost::is_integral<U>::value) );
338 this->setX(static_cast<T>(other.getX()));
339 this->setY(static_cast<T>(other.getY()));
340 this->setZ(static_cast<T>(other.getZ()));
348 BOOST_STATIC_ASSERT( (!boost::is_same<T,U>::value && boost::is_integral<U>::value) );
349 this->setX(static_cast<T>(other.getX()));
350 this->setY(static_cast<T>(other.getY()));
351 this->setZ(static_cast<T>(other.getZ()));
391 template <
typename T,
int N>
404 static_assert(N < 0,
"In-place multiplication of Extent<int,N> by double would truncate.");
415 static_assert(N < 0,
"In-place division of Extent<int,N> by double would truncate.");
Extent< T, N > operator/(T scalar) const
Extent< int, N > truncate(Extent< double, N > const &input)
Extent< double, 3 > Extent3D
Extent(std::pair< T, T > const &xy)
Construct from a std::pair.
const Angle operator/(Angle const a, int d)
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.
void operator/=(ExtentBase< int, N > &lhs, double rhs)
Include files required for standard LSST Exception handling.
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< double, N > & operator+=(Extent< double, N > &lhs, Extent< int, N > const &rhs)
Extent< T, N > operator*(T scalar) const
A boolean pair class used to express the output of spatial predicates on Point and Extent...
Extent< double, N > & operator-=(Extent< double, N > &lhs, Extent< int, N > const &rhs)
CoordinateExpr< N > gt(Extent< T, N > const &other) const
Eigen::Matrix< T, N, 1, Eigen::DontAlign > EigenVector
Extent< int, 2 > Extent2I
Extent< int, N > ceil(Extent< double, N > const &input)
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.
const Angle operator+(Angle const a, Angle const d)
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)
const Angle operator*(Angle const a, Angle const d)
void operator*=(ExtentBase< int, N > &lhs, double rhs)
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,...)
Point< T, N > asPoint() const
Cast this object to an Extent of the same numeric type and dimensionality.
CoordinateExpr< N > eq(T scalar) const
Extent< int, N > floor(Extent< double, N > const &input)
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.
const Angle operator-(Angle const a, Angle const d)
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). ...