25#ifndef LSST_GEOM_EXTENT_H
26#define LSST_GEOM_EXTENT_H
55template <
typename T,
int N>
139 this->
_vector += other._vector;
143 this->
_vector -= other._vector;
182 for (
size_t i = 0; i < N; ++i) {
198 template <
typename Vector>
209template <
typename T,
int N>
226 template <
typename U>
228 template <
typename U>
270 template <
typename U>
272 template <
typename U>
273 explicit Extent(
Point<U, 2> const &other)
noexcept(IS_NOTHROW_CONVERTIBLE<T, U>);
323 template <
typename U>
325 template <
typename U>
326 explicit Extent(
Point<U, 3> const &other)
noexcept(IS_NOTHROW_CONVERTIBLE<T, U>);
338 :
Super(
EigenVector(std::get<0>(xyz), std::get<1>(xyz), std::get<2>(xyz))) {}
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()));
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()));
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()));
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()));
393template <
typename T,
int N>
431template <
typename T,
int N>
445 static_assert(N < 0,
"In-place multiplication of Extent<int,N> by double would truncate.");
456 static_assert(N < 0,
"In-place division of Extent<int,N> by double would truncate.");
498template <
typename T,
int N>
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
A CRTP base class for coordinate objects.
void _swap(CoordinateBase &other) noexcept
Eigen::Matrix< T, N, 1, Eigen::DontAlign > EigenVector
EigenVector const & asEigen() const noexcept(IS_ELEMENT_NOTHROW_COPYABLE)
Return a fixed-size Eigen representation of the coordinate object.
static bool constexpr IS_ELEMENT_NOTHROW_COPYABLE
static bool constexpr IS_ELEMENT_NOTHROW_ASSIGNABLE
void swap(Extent &other) noexcept
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 & operator=(Extent const &other)=default
Super::EigenVector EigenVector
Extent(Extent const &other)=default
Extent(std::tuple< T, T > const &xy) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
Construct from std::tuple.
Extent & operator=(Extent &&other)=default
Extent(T const xy[2]) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
Construct from a two-element array.
Extent(Extent &&other)=default
Extent(std::pair< T, T > const &xy) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
Construct from a std::pair.
Extent(EigenVector const &vector) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
Construct an Extent from an Eigen vector.
Extent(Point< T, 2 > const &other) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
Explicit constructor from Point.
Extent(T x, T y) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
Construct from two scalars.
Extent(Extent const &other)=default
Extent(Extent &&other)=default
Extent(Point< T, 3 > const &other) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
Explicit constructor from Point.
Super::EigenVector EigenVector
Extent(T const xyz[3]) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
Construct from a three-element array.
Extent & operator=(Extent &&other)=default
Extent & operator=(Extent const &other)=default
Extent(T x, T y, T z) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
Construct from three scalars.
Extent(EigenVector const &vector) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
Construct an Extent from an Eigen vector.
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.
void swap(Extent &other) noexcept
Extent(std::tuple< T, T, T > const &xyz) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
Construct from std::tuple.
Extent< T, N > operator/(T scalar) const noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
Cast this object to an Extent of the same numeric type and dimensionality.
ExtentBase & operator=(ExtentBase &&)=default
CoordinateExpr< N > lt(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< T, N > & operator-=(Extent< T, N > const &other) noexcept(Super::IS_ELEMENT_NOTHROW_ASSIGNABLE)
CoordinateExpr< N > gt(T scalar) const noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
CoordinateExpr< N > eq(Extent< T, N > const &other) const noexcept
CoordinateExpr< N > ne(T scalar) const noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
ExtentBase & operator=(ExtentBase const &)=default
CoordinateExpr< N > eq(T scalar) const noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
CoordinateExpr< N > le(Extent< T, N > const &other) const noexcept
Extent< T, N > & operator/=(T scalar) noexcept(Super::IS_ELEMENT_NOTHROW_ASSIGNABLE)
Cast this object to an Extent of the same numeric type and dimensionality.
bool operator==(Extent< T, N > const &other) const noexcept
Standard equality comparison.
CoordinateExpr< N > lt(Extent< T, N > const &other) const noexcept
ExtentBase(Eigen::MatrixBase< Vector > const &vector)
Construct an Extent from an Eigen vector.
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.
T computeNorm() const
Return the L2 norm of the Extent (sqrt(x^2 + y^2 + ...)).
CoordinateExpr< N > ge(T scalar) const noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
bool operator!=(Extent< T, N > const &other) const noexcept
Standard inequality comparison.
std::string toString() const
Cast this object to an Extent of the same numeric type and dimensionality.
CoordinateExpr< N > ne(Extent< T, N > const &other) const noexcept
Point< T, N > asPoint() const noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
Cast this object to an Extent of the same numeric type and dimensionality.
CoordinateExpr< N > le(T scalar) const noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
CoordinateExpr< N > gt(Extent< T, N > const &other) const noexcept
Extent< T, N > & operator*=(T scalar) noexcept(Super::IS_ELEMENT_NOTHROW_ASSIGNABLE)
Cast this object to an Extent of the same numeric type and dimensionality.
ExtentBase(ExtentBase const &)=default
Extent< T, N > & operator+=(Extent< T, N > const &other) noexcept(Super::IS_ELEMENT_NOTHROW_ASSIGNABLE)
T computeSquaredNorm() const
Return the squared L2 norm of the Extent (x^2 + y^2 + ...).
Extent< T, N > operator*(T scalar) const noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
Cast this object to an Extent of the same numeric type and dimensionality.
Extent< T, N > operator-(Extent< T, N > const &other) const noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
Extent< T, N > operator+() const noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
CoordinateExpr< N > ge(Extent< T, N > const &other) const noexcept
ExtentBase(ExtentBase &&)=default
Extent< T, N > operator-() const noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
A coordinate class intended to represent offsets and dimensions.
Extent(EigenVector const &vector) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
Construct an Extent from an Eigen vector.
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(Point< U, N > const &other) noexcept(IS_NOTHROW_CONVERTIBLE< T, U >)
Extent(Extent const &other)=default
T computeSquaredNorm() const
Return the squared L2 norm of the Extent (x^2 + y^2 + ...).
Extent(Extent< U, N > const &other) noexcept(IS_NOTHROW_CONVERTIBLE< T, U >)
Explicit constructor from Extent of different type (if allowed)
Extent(Extent &&other)=default
void swap(Extent &other) noexcept
Super::EigenVector EigenVector
T computeNorm() const
Return the L2 norm of the Extent (sqrt(x^2 + y^2 + ...)).
Extent & operator=(Extent const &other)=default
Extent & operator=(Extent &&other)=default
A coordinate class intended to represent absolute positions.
Reports errors in the logical structure of the program.
double computeExtentNorm(Extent< double, N > const &s)
constexpr Angle operator*(Angle a, Angle d) noexcept
Product of two angles.
Extent< double, N > & operator+=(Extent< double, N > &lhs, Extent< int, N > const &rhs) noexcept
Extent< int, N > floor(Extent< double, N > const &input) noexcept
Return the component-wise floor (round towards more negative).
Extent< double, 2 > ExtentD
void operator/=(ExtentBase< int, N > &lhs, double rhs) noexcept
constexpr Angle operator+(Angle a, Angle d) noexcept
Sum of two angles.
std::size_t hash_value(Extent< T, N > const &extent) noexcept
constexpr Angle operator/(Angle a, int d) noexcept
Ratio of an angle and a scalar.
bool any(CoordinateExpr< N > const &expr) noexcept
Return true if any elements are true.
constexpr Angle operator-(Angle a, Angle d) noexcept
Difference of two angles.
Extent< int, N > truncate(Extent< double, N > const &input) noexcept
Return the component-wise truncation (round towards zero).
bool all(CoordinateExpr< N > const &expr) noexcept
Return true if all elements are true.
Extent< double, 2 > Extent2D
void operator*=(ExtentBase< int, N > &lhs, double rhs) noexcept
Extent< double, N > & operator-=(Extent< double, N > &lhs, Extent< int, N > const &rhs) noexcept
Extent< int, 3 > Extent3I
Extent< int, 2 > Extent2I
Extent< double, 3 > Extent3D
result_type operator()(argument_type const &x) const noexcept