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