28 #ifndef LSST_AFW_GEOM_EXTENT_H 29 #define LSST_AFW_GEOM_EXTENT_H 32 #include <type_traits> 52 #if 1 // make compilers happy in non-void function 59 template <
typename T,
int N>
131 this->_vector += other.
_vector;
135 this->_vector -= other.
_vector;
150 this->_vector *= scalar;
155 this->_vector /= scalar;
166 for (
size_t i = 0; i < N; ++i) {
178 explicit ExtentBase(T val = static_cast<T>(0)) : Super(val) {}
181 template <
typename Vector>
182 explicit ExtentBase(Eigen::MatrixBase<Vector>
const &vector) : Super(vector) {}
192 template <
typename T,
int N>
200 explicit Extent(T val = static_cast<T>(0)) : Super(val) {}
203 explicit Extent(EigenVector
const &vector) : Super(vector) {}
209 template <
typename U>
211 template <
typename U>
235 template <
typename T>
243 explicit Extent(T val = static_cast<T>(0)) : Super(val) {}
246 explicit Extent(EigenVector
const &vector) : Super(vector) {}
252 template <
typename U>
254 template <
typename U>
258 explicit Extent(T
x, T
y) : Super(EigenVector(x, y)) {}
261 explicit Extent(T
const xy[2]) : Super(EigenVector(xy[0], xy[1])) {}
284 template <
typename T>
292 explicit Extent(T val = static_cast<T>(0)) : Super(val) {}
295 explicit Extent(EigenVector
const &vector) : Super(vector) {}
301 template <
typename U>
303 template <
typename U>
307 explicit Extent(T
x, T
y, T
z) : Super(EigenVector(x, y, z)) {}
310 explicit Extent(T
const xyz[3]) : Super(EigenVector(xyz[0], xyz[1], xyz[2])) {}
314 : Super(EigenVector(
std::get<0>(xyz),
std::get<1>(xyz),
std::get<2>(xyz))) {}
327 template <
typename T>
328 template <
typename U>
331 "can only construct from Extent of different but integral type");
332 this->setX(static_cast<T>(other.getX()));
333 this->setY(static_cast<T>(other.getY()));
337 template <
typename T>
339 template <
typename T>
342 template <
typename T>
343 template <
typename U>
346 "can only construct from Extent of different but integral type");
347 this->setX(static_cast<T>(other.getX()));
348 this->setY(static_cast<T>(other.getY()));
352 template <
typename T>
353 template <
typename U>
356 "can only construct from Extent of different but integral type");
357 this->setX(static_cast<T>(other.getX()));
358 this->setY(static_cast<T>(other.getY()));
359 this->setZ(static_cast<T>(other.getZ()));
363 template <
typename T>
365 template <
typename T>
369 template <
typename T>
370 template <
typename U>
373 "can only construct from Extent of different but integral type");
374 this->setX(static_cast<T>(other.getX()));
375 this->setY(static_cast<T>(other.getY()));
376 this->setZ(static_cast<T>(other.getZ()));
414 template <
typename T,
int N>
427 static_assert(N < 0,
"In-place multiplication of Extent<int,N> by double would truncate.");
438 static_assert(N < 0,
"In-place division of Extent<int,N> by double would truncate.");
Extent< T, N > & operator+=(Extent< T, N > const &other)
Extent(std::tuple< T, T > const &xy)
Construct from std::tuple.
CoordinateExpr< N > ge(T scalar) const
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< T, N > operator*(T scalar) const
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 > ne(T scalar) const
Extent(T const xy[2])
Construct from a two-element array.
CoordinateExpr< N > lt(T scalar) const
Extent< double, 2 > Extent2D
CoordinateExpr< N > eq(T scalar) const
Super::EigenVector EigenVector
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)
bool operator==(Extent< T, N > const &other) const
Standard equality comparison.
A coordinate class intended to represent offsets and dimensions.
Extent(T const xyz[3])
Construct from a two-element array.
Super::EigenVector EigenVector
Extent< T, N > operator+() 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 + ...).
Extent< int, 2 > Extent2I
std::string toString() const
ItemVariant const * other
constexpr Angle operator+(Angle a, Angle d) noexcept
Sum of two angles.
CoordinateExpr< N > le(T scalar) const
Extent< double, 2 > ExtentD
A CRTP base class for coordinate objects.
A coordinate class intended to represent absolute positions.
T computeSquaredNorm() const
Return the squared L2 norm of the Extent (x^2 + y^2 + ...).
Extent< T, N > operator/(T scalar) const
bool any(CoordinateExpr< N > const &expr)
Return true if any elements are true.
EigenVector const & asEigen() const
Return a fixed-size Eigen representation of the coordinate object.
constexpr Angle operator/(Angle a, int d) noexcept
Ratio of an angle and a scalar.
void operator*=(ExtentBase< int, N > &lhs, double rhs)
A base class for image defects.
Eigen::Vector3d asEigen(sphgeom::Vector3d const &vector)
T computeNorm() const
Return the L2 norm of the Extent (sqrt(x^2 + y^2 + ...)).
Extent< T, N > & operator*=(T scalar)
Extent< T, N > & operator/=(T scalar)
A coordinate class intended to represent offsets and dimensions (3-d specialization).
double computeExtentNorm(Extent< double, N > const &s)
Extent(EigenVector const &vector)
Construct an Extent from an Eigen vector.
Extent< int, N > truncate(Extent< double, N > const &input)
Return the component-wise truncation (round towards zero).
A coordinate class intended to represent offsets and dimensions (2-d specialization).
Eigen::Matrix< int, N, 1, Eigen::DontAlign > EigenVector
Extent< int, N > ceil(Extent< double, N > const &input)
Return the component-wise ceil (round towards more positive).
ExtentBase(Eigen::MatrixBase< Vector > const &vector)
Construct an Extent from an Eigen vector.
Extent< double, N > & operator+=(Extent< double, N > &lhs, Extent< int, N > const &rhs)
Extent< double, 3 > Extent3D
#define LSST_EXCEPT(type,...)
CoordinateExpr< N > gt(T scalar) const
Extent< T, N > operator-(Extent< T, N > const &other) const
Super::EigenVector EigenVector
constexpr Angle operator*(Angle a, Angle d) noexcept
Product of two angles.
constexpr Angle operator-(Angle a, Angle d) noexcept
Difference of two angles.
bool operator!=(Extent< T, N > const &other) const
Standard inequality comparison.
Extent(T x, T y, T z)
Construct from three scalars.
Extent< int, 3 > Extent3I
Extent< int, N > floor(Extent< double, N > const &input)
Return the component-wise floor (round towards more negative).
Extent< T, N > operator-() const
Extent< double, N > & operator-=(Extent< double, N > &lhs, Extent< int, N > const &rhs)
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< T, N > & operator-=(Extent< T, N > const &other)
Extent(EigenVector const &vector)
Construct an Extent from an Eigen vector.
Extent< T, N > operator+(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). ...