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>
139 this->_vector += other.
_vector;
143 this->_vector -= other.
_vector;
164 this->_vector *= scalar;
171 this->_vector /= scalar;
177 Point<T, N> asPoint()
const noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE);
182 for (
size_t i = 0; i < N; ++i) {
194 explicit ExtentBase(T
val = static_cast<T>(0)) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
198 template <
typename Vector>
199 explicit ExtentBase(Eigen::MatrixBase<Vector>
const &vector) : Super(vector) {}
209 template <
typename T,
int N>
217 explicit Extent(T
val = static_cast<T>(0)) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE) : Super(
val) {}
220 explicit Extent(EigenVector
const &vector) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE) : Super(vector) {}
223 explicit Extent(
Point<T, N> const &other) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE);
226 template <
typename U>
228 template <
typename U>
229 explicit Extent(
Point<U, N> const &other) noexcept(IS_NOTHROW_CONVERTIBLE<T, U>);
253 template <
typename T>
261 explicit Extent(T
val = static_cast<T>(0)) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE) : Super(
val) {}
264 explicit Extent(EigenVector
const &vector) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE) : Super(vector) {}
267 explicit Extent(
Point<T, 2> const &other) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE);
270 template <
typename U>
272 template <
typename U>
273 explicit Extent(
Point<U, 2> const &other) noexcept(IS_NOTHROW_CONVERTIBLE<T, U>);
276 explicit Extent(T
x, T
y) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE) : Super(EigenVector(
x,
y)) {}
279 explicit Extent(T
const xy[2]) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
280 : Super(EigenVector(xy[0], xy[1])) {}
288 : Super(EigenVector(
std::get<0>(xy),
std::get<1>(xy))) {}
306 template <
typename T>
314 explicit Extent(T
val = static_cast<T>(0)) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE) : Super(
val) {}
317 explicit Extent(EigenVector
const &vector) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE) : Super(vector) {}
320 explicit Extent(
Point<T, 3> const &other) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE);
323 template <
typename U>
325 template <
typename U>
326 explicit Extent(
Point<U, 3> const &other) noexcept(IS_NOTHROW_CONVERTIBLE<T, U>);
329 explicit Extent(T
x, T
y, T
z) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
330 : Super(EigenVector(
x,
y,
z)) {}
333 explicit Extent(T
const xyz[3]) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
334 : Super(EigenVector(xyz[0], xyz[1], xyz[2])) {}
338 : Super(EigenVector(
std::get<0>(xyz),
std::get<1>(xyz),
std::get<2>(xyz))) {}
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()));
361 template <
typename T>
362 template <
typename U>
365 "can only construct from Extent of different but integral type");
366 this->setX(static_cast<T>(other.getX()));
367 this->setY(static_cast<T>(other.getY()));
371 template <
typename T>
372 template <
typename U>
375 "can only construct from Extent of different but integral type");
376 this->setX(static_cast<T>(other.getX()));
377 this->setY(static_cast<T>(other.getY()));
378 this->setZ(static_cast<T>(other.getZ()));
382 template <
typename T>
383 template <
typename U>
386 "can only construct from Extent of different but integral type");
387 this->setX(static_cast<T>(other.getX()));
388 this->setY(static_cast<T>(other.getY()));
389 this->setZ(static_cast<T>(other.getZ()));
427 template <
typename T,
int N>
441 static_assert(N < 0,
"In-place multiplication of Extent<int,N> by double would truncate.");
452 static_assert(N < 0,
"In-place division of Extent<int,N> by double would truncate.");
void swap(Extent &other) noexcept
T computeSquaredNorm() const
Return the squared L2 norm of the Extent (x^2 + y^2 + ...).
Extent(T const xyz[3]) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
Construct from a three-element array.
A CRTP base class for coordinate objects.
Extent< double, 3 > Extent3D
Extent< int, N > ceil(Extent< double, N > const &input) noexcept
Return the component-wise ceil (round towards more positive).
Extent(T x, T y, T z) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
Construct from three scalars.
ExtentBase(Eigen::MatrixBase< Vector > const &vector)
Construct an Extent from an Eigen vector.
A coordinate class intended to represent absolute positions (2-d specialization). ...
void operator/=(ExtentBase< int, N > &lhs, double rhs) noexcept
CoordinateExpr< N > ge(T scalar) const noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
A coordinate class intended to represent absolute positions (3-d specialization). ...
T computeSquaredNorm() const
Return the squared L2 norm of the Extent (x^2 + y^2 + ...).
Extent(T val=static_cast< T >(0)) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
Construct an Extent with all elements set to the same scalar value.
A coordinate class intended to represent absolute positions.
Extent< T, N > & operator*=(T scalar) noexcept(Super::IS_ELEMENT_NOTHROW_ASSIGNABLE)
void operator*=(ExtentBase< int, N > &lhs, double rhs) noexcept
constexpr Angle operator+(Angle a, Angle d) noexcept
Sum of two angles.
Extent< double, N > & operator+=(Extent< double, N > &lhs, Extent< int, N > const &rhs) noexcept
CoordinateExpr< N > eq(T scalar) const noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
Extent(EigenVector const &vector) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
Construct an Extent from an Eigen vector.
std::string toString() const
Extent< T, N > & operator/=(T scalar) noexcept(Super::IS_ELEMENT_NOTHROW_ASSIGNABLE)
CoordinateExpr< N > le(T scalar) const noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
Extent< T, N > operator-() const noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
Extent(T val=static_cast< T >(0)) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
Construct an Extent with all elements set to the same scalar value.
bool any(CoordinateExpr< N > const &expr) noexcept
Return true if any elements are true.
bool operator!=(Extent< T, N > const &other) const noexcept
Standard inequality comparison.
Extent< double, N > & operator-=(Extent< double, N > &lhs, Extent< int, N > const &rhs) noexcept
Extent(std::pair< T, T > const &xy) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
Construct from a std::pair.
T computeNorm() const
Return the L2 norm of the Extent (sqrt(x^2 + y^2 + ...)).
Extent(T x, T y) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
Construct from two scalars.
Extent< T, N > operator+() const noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
constexpr Angle operator-(Angle a, Angle d) noexcept
Difference of two angles.
bool all(CoordinateExpr< N > const &expr) noexcept
Return true if all elements are true.
CoordinateExpr< N > lt(T scalar) const noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
Eigen::Matrix< int, N, 1, Eigen::DontAlign > EigenVector
A base class for image defects.
Extent< T, N > operator/(T scalar) const noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
Extent< int, N > truncate(Extent< double, N > const &input) noexcept
Return the component-wise truncation (round towards zero).
CoordinateExpr< N > ne(T scalar) const noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
Extent(T val=static_cast< T >(0)) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
Construct an Extent with all elements set to the same scalar value.
Extent< T, N > & operator+=(Extent< T, N > const &other) noexcept(Super::IS_ELEMENT_NOTHROW_ASSIGNABLE)
Super::EigenVector EigenVector
ExtentBase(T val=static_cast< T >(0)) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
Construct an Extent<T,N> with all elements set to the same scalar value.
constexpr Angle operator*(Angle a, Angle d) noexcept
Product of two angles.
Super::EigenVector EigenVector
double computeExtentNorm(Extent< double, N > const &s)
Reports errors in the logical structure of the program.
A coordinate class intended to represent offsets and dimensions.
Eigen::Vector3d asEigen(sphgeom::Vector3d const &vector) noexcept
void swap(Extent &other) noexcept
T computeNorm() const
Return the L2 norm of the Extent (sqrt(x^2 + y^2 + ...)).
#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< T, N > operator+(Extent< T, N > const &other) const noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
bool operator==(Extent< T, N > const &other) const noexcept
Standard equality comparison.
Extent< double, 2 > ExtentD
Super::EigenVector EigenVector
void swap(Extent &other) noexcept
Extent< T, N > & operator-=(Extent< T, N > const &other) noexcept(Super::IS_ELEMENT_NOTHROW_ASSIGNABLE)
Extent(T const xy[2]) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
Construct from a two-element array.
EigenVector const & asEigen() const noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
Return a fixed-size Eigen representation of the coordinate object.
Extent< int, N > floor(Extent< double, N > const &input) noexcept
Return the component-wise floor (round towards more negative).
ItemVariant const * other
Extent< double, 2 > Extent2D
Extent< T, N > operator*(T scalar) const noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
Extent< T, N > operator-(Extent< T, N > const &other) const noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
Extent< int, 3 > Extent3I
Extent(std::tuple< T, T > const &xy) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
Construct from std::tuple.
Extent(std::tuple< T, T, T > const &xyz) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
Construct from std::tuple.
Extent(EigenVector const &vector) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
Construct an Extent from an Eigen vector.
Extent(EigenVector const &vector) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
Construct an Extent from an Eigen vector.
CoordinateExpr< N > gt(T scalar) const noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)