29 #ifndef LSST_AFW_GEOM_EXTENT_H
30 #define LSST_AFW_GEOM_EXTENT_H
33 #include <type_traits>
38 namespace lsst {
namespace afw {
namespace geom {
51 pex::exceptions::LogicError,
52 "Cannot compute norm of integer extent"
54 #if 1 // make compilers happy in non-void function
62 template<
typename T,
int N>
155 std::stringstream out;
157 for (
size_t i = 0; i < N; ++i) {
173 template <
typename Vector>
185 template<
typename T,
int N>
186 class Extent :
public ExtentBase<T,N> {
251 explicit Extent(std::tuple<T,T>
const & xy) :
297 explicit Extent(std::tuple<T,T,T>
const & xyz) :
317 static_assert((!std::is_same<T,U>::value && std::is_integral<U>::value),
318 "can only construct from Extent of different but integral type");
319 this->setX(static_cast<T>(other.getX()));
320 this->setY(static_cast<T>(other.getY()));
327 static_assert((!std::is_same<T,U>::value && std::is_integral<U>::value),
328 "can only construct from Extent of different but integral type");
329 this->setX(static_cast<T>(other.getX()));
330 this->setY(static_cast<T>(other.getY()));
338 static_assert((!std::is_same<T,U>::value && std::is_integral<U>::value),
339 "can only construct from Extent of different but integral type");
340 this->setX(static_cast<T>(other.getX()));
341 this->setY(static_cast<T>(other.getY()));
342 this->setZ(static_cast<T>(other.getZ()));
350 static_assert((!std::is_same<T,U>::value && std::is_integral<U>::value),
351 "can only construct from Extent of different but integral type");
352 this->setX(static_cast<T>(other.getX()));
353 this->setY(static_cast<T>(other.getY()));
354 this->setZ(static_cast<T>(other.getZ()));
394 template <
typename T,
int N>
407 static_assert(N < 0,
"In-place multiplication of Extent<int,N> by double would truncate.");
418 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::tuple< T, T > const &xy)
Construct from std::tuple.
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(T val=static_cast< T >(0))
Construct an Extent with all elements set to the same scalar value.
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.
Extent(std::tuple< T, T, T > const &xyz)
Construct from std::tuple.
void operator/=(ExtentBase< int, N > &lhs, double rhs)
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.
Include files required for standard LSST Exception handling.
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). ...