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< int, N > truncate(Extent< double, N > const &input)
Extent< T, N > operator+(Extent< T, N > const &other) const
Extent< T, N > operator-(Extent< T, N > const &other) const
const Angle operator/(Angle const a, int d)
A coordinate class intended to represent absolute positions (2-d specialization). ...
Super::EigenVector EigenVector
bool all(CoordinateExpr< N > const &expr)
Return true if all elements are true.
CoordinateExpr< N > gt(Extent< T, N > const &other) const
void operator/=(ExtentBase< int, N > &lhs, double rhs)
A coordinate class intended to represent offsets and dimensions.
Extent< double, 2 > Extent2D
CoordinateExpr< N > ge(T scalar) const
ExtentBase(T val=static_cast< T >(0))
Construct an Extent<T,N> with all elements set to the same scalar value.
Extent< T, N > & operator*=(T scalar)
bool operator!=(Extent< T, N > const &other) const
Standard inequality comparison.
T computeSquaredNorm() const
Return the squared L2 norm of the Extent (x^2 + y^2 + ...).
bool operator==(Extent< T, N > const &other) const
Standard equality comparison.
Extent< double, N > & operator+=(Extent< double, N > &lhs, Extent< int, N > const &rhs)
ExtentBase(Eigen::MatrixBase< Vector > const &vector)
Construct an Extent from an Eigen vector.
A boolean pair class used to express the output of spatial predicates on Point and Extent...
void _swap(CoordinateBase &other)
Extent< T, N > & operator/=(T scalar)
Extent< double, N > & operator-=(Extent< double, N > &lhs, Extent< int, N > const &rhs)
Extent< int, N > ceil(Extent< double, N > const &input)
Extent< double, 2 > ExtentD
CoordinateExpr< N > gt(T scalar) const
Extent< T, N > & operator+=(Extent< T, N > const &other)
CoordinateExpr< N > eq(T scalar) const
A CRTP base class for coordinate objects.
Extent< double, 3 > Extent3D
CoordinateExpr< N > eq(Extent< T, N > const &other) const
A coordinate class intended to represent absolute positions.
Point< T, N > asPoint() const
Cast this object to an Extent of the same numeric type and dimensionality.
CoordinateExpr< N > le(Extent< T, N > const &other) const
Extent(boost::tuple< T, T > const &xy)
Construct from boost::tuple.
Extent(T const xyz[3])
Construct from a two-element array.
const Angle operator+(Angle const a, Angle const d)
Extent< T, N > operator/(T scalar) const
T computeNorm() const
Return the L2 norm of the Extent (sqrt(x^2 + y^2 + ...)).
T computeSquaredNorm() const
Return the squared L2 norm of the Extent (x^2 + y^2 + ...).
bool any(CoordinateExpr< N > const &expr)
Return true if any elements are true.
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.
const Angle operator*(Angle const a, Angle const d)
void operator*=(ExtentBase< int, N > &lhs, double rhs)
Extent< T, N > operator+() const
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.
std::string toString() const
EigenVector const & asEigen() const
Return a fixed-size Eigen representation of the coordinate object.
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.
CoordinateExpr< N > lt(Extent< T, N > const &other) const
double computeExtentNorm(Extent< double, N > const &s)
Extent(std::pair< T, T > const &xy)
Construct from a std::pair.
Extent< T, N > & operator-=(Extent< T, N > const &other)
Extent(T x, T y)
Construct from two scalars.
Extent(boost::tuple< T, T, T > const &xyz)
Construct from boost::tuple.
#define LSST_EXCEPT(type,...)
Extent< T, N > operator*(T scalar) const
Extent(T const xy[2])
Construct from a two-element array.
Extent(EigenVector const &vector)
Construct an Extent from an Eigen vector.
T computeNorm() const
Return the L2 norm of the Extent (sqrt(x^2 + y^2 + ...)).
Extent< int, N > floor(Extent< double, N > const &input)
CoordinateExpr< N > ge(Extent< T, N > const &other) const
Extent< int, 3 > Extent3I
Extent(T x, T y, T z)
Construct from three scalars.
Eigen::Matrix< T, N, 1, Eigen::DontAlign > EigenVector
Super::EigenVector EigenVector
Super::EigenVector EigenVector
const Angle operator-(Angle const a, Angle const d)
Extent< int, 2 > Extent2I
CoordinateExpr< N > ne(T scalar) const
CoordinateExpr< N > le(T scalar) const
CoordinateBase< Extent< T, N >, T, N > Super
CoordinateExpr< N > lt(T scalar) const
Include files required for standard LSST Exception handling.
Extent< T, N > operator-() const
A coordinate class intended to represent absolute positions (3-d specialization). ...