25 #ifndef LSST_GEOM_EXTENT_H 26 #define LSST_GEOM_EXTENT_H 29 #include <type_traits> 48 #if 1 // make compilers happy in non-void function 55 template <
typename T,
int N>
127 this->_vector += other.
_vector;
131 this->_vector -= other.
_vector;
146 this->_vector *= scalar;
151 this->_vector /= scalar;
162 for (
size_t i = 0; i < N; ++i) {
177 template <
typename Vector>
178 explicit ExtentBase(Eigen::MatrixBase<Vector>
const &vector) : Super(vector) {}
188 template <
typename T,
int N>
199 explicit Extent(EigenVector
const &vector) : Super(vector) {}
205 template <
typename U>
207 template <
typename U>
231 template <
typename T>
242 explicit Extent(EigenVector
const &vector) : Super(vector) {}
248 template <
typename U>
250 template <
typename U>
254 explicit Extent(T
x, T
y) : Super(EigenVector(x, y)) {}
257 explicit Extent(T
const xy[2]) : Super(EigenVector(xy[0], xy[1])) {}
280 template <
typename T>
291 explicit Extent(EigenVector
const &vector) : Super(vector) {}
297 template <
typename U>
299 template <
typename U>
303 explicit Extent(T
x, T
y, T
z) : Super(EigenVector(x, y, z)) {}
306 explicit Extent(T
const xyz[3]) : Super(EigenVector(xyz[0], xyz[1], xyz[2])) {}
310 : Super(EigenVector(
std::get<0>(xyz),
std::get<1>(xyz),
std::get<2>(xyz))) {}
323 template <
typename T>
324 template <
typename U>
327 "can only construct from Extent of different but integral type");
328 this->setX(static_cast<T>(other.getX()));
329 this->setY(static_cast<T>(other.getY()));
333 template <
typename T>
335 template <
typename T>
338 template <
typename T>
339 template <
typename U>
342 "can only construct from Extent of different but integral type");
343 this->setX(static_cast<T>(other.getX()));
344 this->setY(static_cast<T>(other.getY()));
348 template <
typename T>
349 template <
typename U>
352 "can only construct from Extent of different but integral type");
353 this->setX(static_cast<T>(other.getX()));
354 this->setY(static_cast<T>(other.getY()));
355 this->setZ(static_cast<T>(other.getZ()));
359 template <
typename T>
361 template <
typename T>
365 template <
typename T>
366 template <
typename U>
369 "can only construct from Extent of different but integral type");
370 this->setX(static_cast<T>(other.getX()));
371 this->setY(static_cast<T>(other.getY()));
372 this->setZ(static_cast<T>(other.getZ()));
410 template <
typename T,
int N>
423 static_assert(N < 0,
"In-place multiplication of Extent<int,N> by double would truncate.");
434 static_assert(N < 0,
"In-place division of Extent<int,N> by double would truncate.");
T computeSquaredNorm() const
Return the squared L2 norm of the Extent (x^2 + y^2 + ...).
Extent(T val=static_cast< T >(0))
Construct an Extent with all elements set to the same scalar value.
A CRTP base class for coordinate objects.
Extent< T, N > & operator/=(T scalar)
Extent< double, 3 > Extent3D
Extent< T, N > & operator*=(T scalar)
Extent(T const xy[2])
Construct from a two-element array.
ExtentBase(Eigen::MatrixBase< Vector > const &vector)
Construct an Extent from an Eigen vector.
A coordinate class intended to represent absolute positions (2-d specialization). ...
A coordinate class intended to represent absolute positions (3-d specialization). ...
Extent< double, N > & operator-=(Extent< double, N > &lhs, Extent< int, N > const &rhs)
T computeSquaredNorm() const
Return the squared L2 norm of the Extent (x^2 + y^2 + ...).
A coordinate class intended to represent absolute positions.
bool operator==(Extent< T, N > const &other) const
Standard equality comparison.
constexpr Angle operator+(Angle a, Angle d) noexcept
Sum of two angles.
A coordinate class intended to represent offsets and dimensions (2-d specialization).
Extent< int, N > truncate(Extent< double, N > const &input)
Return the component-wise truncation (round towards zero).
Extent< int, N > ceil(Extent< double, N > const &input)
Return the component-wise ceil (round towards more positive).
Extent(T const xyz[3])
Construct from a two-element array.
Extent< T, N > operator-() const
Extent(EigenVector const &vector)
Construct an Extent from an Eigen vector.
CoordinateExpr< N > ge(T scalar) const
std::string toString() const
Extent< T, N > & operator+=(Extent< T, N > const &other)
bool operator!=(Extent< T, N > const &other) const
Standard inequality comparison.
A coordinate class intended to represent offsets and dimensions (3-d specialization).
Extent< T, N > operator+(Extent< T, N > const &other) const
T computeNorm() const
Return the L2 norm of the Extent (sqrt(x^2 + y^2 + ...)).
CoordinateExpr< N > le(T scalar) const
constexpr Angle operator-(Angle a, Angle d) noexcept
Difference of two angles.
bool all(CoordinateExpr< N > const &expr)
Return true if all elements are true.
Extent(T val=static_cast< T >(0))
Construct an Extent with all elements set to the same scalar value.
Eigen::Matrix< int, N, 1, Eigen::DontAlign > EigenVector
A base class for image defects.
Extent< double, N > & operator+=(Extent< double, N > &lhs, Extent< int, N > const &rhs)
Extent< T, N > & operator-=(Extent< T, N > const &other)
Eigen::Vector3d asEigen(sphgeom::Vector3d const &vector)
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.
Super::EigenVector EigenVector
double computeExtentNorm(Extent< double, N > const &s)
Extent(EigenVector const &vector)
Construct an Extent from an Eigen vector.
Extent(std::pair< T, T > const &xy)
Construct from a std::pair.
Reports errors in the logical structure of the program.
A coordinate class intended to represent offsets and dimensions.
Extent< T, N > operator+() const
void operator*=(ExtentBase< int, N > &lhs, double rhs)
T computeNorm() const
Return the L2 norm of the Extent (sqrt(x^2 + y^2 + ...)).
Extent(std::tuple< T, T > const &xy)
Construct from std::tuple.
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
constexpr Angle operator/(Angle a, int d) noexcept
Ratio of an angle and a scalar.
Extent< int, 2 > Extent2I
Extent< int, N > floor(Extent< double, N > const &input)
Return the component-wise floor (round towards more negative).
Extent(EigenVector const &vector)
Construct an Extent from an Eigen vector.
Extent(std::tuple< T, T, T > const &xyz)
Construct from std::tuple.
Extent(T x, T y)
Construct from two scalars.
Extent< T, N > operator/(T scalar) const
CoordinateExpr< N > eq(T scalar) const
Extent< double, 2 > ExtentD
Super::EigenVector EigenVector
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 x, T y, T z)
Construct from three scalars.
ItemVariant const * other
EigenVector const & asEigen() const
Return a fixed-size Eigen representation of the coordinate object.
Extent< double, 2 > Extent2D
CoordinateExpr< N > ne(T scalar) const
Extent< T, N > operator*(T scalar) const
Extent< int, 3 > Extent3I
CoordinateExpr< N > gt(T scalar) const
void operator/=(ExtentBase< int, N > &lhs, double rhs)
bool any(CoordinateExpr< N > const &expr)
Return true if any elements are true.
CoordinateExpr< N > lt(T scalar) const