template<class T>
Magnum::Math::Range2D class

Two-dimensional range.

See Range for more information.

Base classes

template<UnsignedInt dimensions, class T>
class Range<2, T>
N-dimensional range.

Constructors, destructors, conversion operators

Range2D() constexpr noexcept
Default constructor.
Range2D(ZeroInitT) explicit constexpr noexcept
Construct a zero range.
Range2D(Magnum::NoInitT) explicit noexcept
Construct without initializing the contents.
Range2D(const Vector2<T>& min, const Vector2<T>& max) constexpr noexcept
Construct a range from minimal and maximal coordinates.
Range2D(const Containers::Pair<Vector2<T>, Vector2<T>>& minmax) constexpr noexcept new in 2020.06
Construct a range from a pair of minimal and maximal coordinates.
Range2D(const Containers::Pair<Vector<2, T>, Vector<2, T>>& minmax) constexpr noexcept new in 2020.06
template<class U>
Range2D(const Range2D<U>& other) explicit constexpr noexcept
Construct a range from another of different type.
template<class U, class = decltype(Implementation::RangeConverter<2, T, U>::from(std::declval<U>()))>
Range2D(const U& other) explicit constexpr
Construct a range from external representation.
Range2D(const Range<2, T>& other) constexpr noexcept
Copy constructor.

Public functions

auto bottomLeft() -> Vector2<T>&
Bottom left corner.
auto bottomLeft() const -> Vector2<T> constexpr
auto bottomRight() const -> Vector2<T> constexpr
Bottom right corner.
auto topLeft() const -> Vector2<T> constexpr
Top left corner.
auto topRight() -> Vector2<T>&
Top right corner.
auto topRight() const -> Vector2<T> constexpr
auto left() -> T&
Left edge.
auto left() const -> T constexpr
auto right() -> T&
Right edge.
auto right() const -> T constexpr
auto bottom() -> T&
Bottom edge.
auto bottom() const -> T constexpr
auto top() -> T&
Top edge.
auto top() const -> T constexpr
auto x() const -> Range<1, T> constexpr
Range in the X axis.
auto y() const -> Range<1, T> constexpr
Range in the Y axis.
auto sizeX() const -> T
Range width.
auto sizeY() const -> T
Range height.
auto centerX() const -> T
Range center on X axis.
auto centerY() const -> T
Range center on Y axis.

Function documentation

template<class T>
Magnum::Math::Range2D<T>::Range2D() constexpr noexcept

Default constructor.

Equivalent to Range2D(ZeroInitT).

template<class T>
Magnum::Math::Range2D<T>::Range2D(ZeroInitT) explicit constexpr noexcept

Construct a zero range.

Construct a zero-size range positioned at origin.

template<class T>
Magnum::Math::Range2D<T>::Range2D(const Containers::Pair<Vector2<T>, Vector2<T>>& minmax) constexpr noexcept new in 2020.06

Construct a range from a pair of minimal and maximal coordinates.

Useful in combination with e.g. minmax(), here for example to calculate texture bounds:

Vector2 texcoords[50];
Range2D bounds = Math::minmax(texcoords);

template<class T>
Magnum::Math::Range2D<T>::Range2D(const Containers::Pair<Vector<2, T>, Vector<2, T>>& minmax) constexpr noexcept new in 2020.06

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T> template<class U>
Magnum::Math::Range2D<T>::Range2D(const Range2D<U>& other) explicit constexpr noexcept

Construct a range from another of different type.

Performs only default casting on the values, no rounding or anything else. Example usage:

Range2D floatingPoint{{1.3f, 2.7f}, {-15.0f, 7.0f}};
Range2Di integral{floatingPoint}; // {{1, 2}, {-15, 7}}

template<class T>
Vector2<T>& Magnum::Math::Range2D<T>::bottomLeft()

Bottom left corner.

Equivalent to min().

template<class T>
Vector2<T> Magnum::Math::Range2D<T>::bottomLeft() const constexpr

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
Vector2<T>& Magnum::Math::Range2D<T>::topRight()

Top right corner.

Equivalent to max().

template<class T>
Vector2<T> Magnum::Math::Range2D<T>::topRight() const constexpr

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
T Magnum::Math::Range2D<T>::left() const constexpr

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
T Magnum::Math::Range2D<T>::right() const constexpr

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
T Magnum::Math::Range2D<T>::bottom() const constexpr

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
T Magnum::Math::Range2D<T>::top() const constexpr

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class T>
T Magnum::Math::Range2D<T>::sizeX() const

Range width.

template<class T>
T Magnum::Math::Range2D<T>::sizeY() const

Range height.

template<class T>
T Magnum::Math::Range2D<T>::centerX() const

Range center on X axis.

template<class T>
T Magnum::Math::Range2D<T>::centerY() const

Range center on Y axis.