template<UnsignedInt dimensions, class T>
Range class
N-dimensional range.
Contents
Axis-aligned line (in 1D), rectangle (in 2D) or cube (in 3D). Minimal coordinate is inclusive, maximal exclusive. See Range1D, Range2D and Range3D specializations for given dimension count.
Public types
- using VectorType = Implementation::RangeTraits<dimensions, T>::Type
- Underlying vector type.
Public static functions
- static auto fromSize(const VectorType& min, const VectorType& size) -> Range<dimensions, T>
- Create range from minimal coordinates and size.
Constructors, destructors, conversion operators
- Range(ZeroInitT = ZeroInit) constexpr noexcept
- Construct zero range.
- Range(NoInitT) explicit noexcept
- Construct without initializing the contents.
- Range(const VectorType& min, const VectorType& max) constexpr noexcept
- Construct range from minimal and maximal coordinates.
-
template<class U>Range(const Range<dimensions, U>& other) explicit constexpr noexcept
- Construct range from another of different type.
-
template<class U, class V = decltype(Implementation::RangeConverter<dimensions, T, U>::from(std::Range(const U& other) explicit constexpr
declval<U>()))> - Construct range from external representation.
- Range(const Range<dimensions, T>&) noexcept defaulted constexpr
- Copy constructor.
-
template<class U, class V = decltype(Implementation::RangeConverter<dimensions, T, U>::to(std::operator U() const explicit constexpr
declval<Range<dimensions, T>>()))> - Convert range to external representation.
Public functions
- auto operator==(const Range<dimensions, T>& other) const -> bool constexpr
- Equality comparison.
- auto operator!=(const Range<dimensions, T>& other) const -> bool constexpr
- Non-equality comparison.
- auto data() -> T*
- Raw data.
- auto data() const -> const T* constexpr
- auto min() -> VectorType&
- Minimal coordinates (inclusive)
- auto min() const -> const VectorType constexpr
- auto max() -> VectorType&
- Maximal coordinates (exclusive)
- auto max() const -> const VectorType constexpr
- auto size() const -> VectorType
- Range size.
- auto center() const -> VectorType
- Range center.
- auto translated(const VectorType& vector) const -> Range<dimensions, T>
- Translated range.
- auto padded(const VectorType& padding) const -> Range<dimensions, T>
- Padded rage.
- auto scaled(const VectorType& scaling) const -> Range<dimensions, T>
- Scaled range.
- auto contains(const VectorType& a) const -> bool constexpr
- Whether given point is contained inside the range.
Typedef documentation
template<UnsignedInt dimensions, class T>
typedef Implementation::RangeTraits<dimensions, T>::Type Magnum:: Math:: Range<dimensions, T>:: VectorType
Underlying vector type.
T
in 1D, Vector2<T> in 2D, Vector3<T> in 3D.
Function documentation
template<UnsignedInt dimensions, class T>
static Range<dimensions, T> Magnum:: Math:: Range<dimensions, T>:: fromSize(const VectorType& min,
const VectorType& size)
Create range from minimal coordinates and size.
Parameters | |
---|---|
min | Minimal coordinates |
size | Range size |
template<UnsignedInt dimensions, class T>
Magnum:: Math:: Range<dimensions, T>:: Range(ZeroInitT = ZeroInit) constexpr noexcept
Construct zero range.
Construct zero-size range positioned at origin.
template<UnsignedInt dimensions, class T>
template<class U>
Magnum:: Math:: Range<dimensions, T>:: Range(const Range<dimensions, U>& other) explicit constexpr noexcept
Construct range from another of different type.
Performs only default casting on the values, no rounding or anything else. Example usage:
Range2D<Float> floatingPoint({1.3f, 2.7f}, {-15.0f, 7.0f}); Range2D<Byte> integral(floatingPoint); // {{1, 2}, {-15, 7}}
template<UnsignedInt dimensions, class T>
T* Magnum:: Math:: Range<dimensions, T>:: data()
Raw data.
Returns | One-dimensional array of dimensions *2 length. |
---|
template<UnsignedInt dimensions, class T>
const T* Magnum:: Math:: Range<dimensions, T>:: data() 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<UnsignedInt dimensions, class T>
VectorType& Magnum:: Math:: Range<dimensions, T>:: min()
Minimal coordinates (inclusive)
template<UnsignedInt dimensions, class T>
const VectorType Magnum:: Math:: Range<dimensions, T>:: min() 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<UnsignedInt dimensions, class T>
VectorType& Magnum:: Math:: Range<dimensions, T>:: max()
Maximal coordinates (exclusive)
template<UnsignedInt dimensions, class T>
const VectorType Magnum:: Math:: Range<dimensions, T>:: max() 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<UnsignedInt dimensions, class T>
VectorType Magnum:: Math:: Range<dimensions, T>:: size() const
Range size.
template<UnsignedInt dimensions, class T>
VectorType Magnum:: Math:: Range<dimensions, T>:: center() const
Range center.
template<UnsignedInt dimensions, class T>
Range<dimensions, T> Magnum:: Math:: Range<dimensions, T>:: translated(const VectorType& vector) const
Translated range.
Translates the minimal and maximal coordinates by given amount. Size remains the same.
template<UnsignedInt dimensions, class T>
Range<dimensions, T> Magnum:: Math:: Range<dimensions, T>:: padded(const VectorType& padding) const
Padded rage.
Translates the minimal and maximal coordinates by given amount. Center remains the same.
template<UnsignedInt dimensions, class T>
Range<dimensions, T> Magnum:: Math:: Range<dimensions, T>:: scaled(const VectorType& scaling) const
Scaled range.
Multiplies the minimal and maximal coordinates by given amount.
template<UnsignedInt dimensions, class T>
template<UnsignedInt dimensions, class T>
Range<dimensions, T> join(const Range<dimensions, T>& a,
const Range<dimensions, T>& b)
Join two ranges.
Returns a range that contains both input ranges. If one of the ranges is empty, only the other is returned. Results are undefined if any range has negative size.
template<UnsignedInt dimensions, class T>
template<UnsignedInt dimensions, class T>
Corrade:: Utility:: Debug& operator<<(Corrade:: Utility:: Debug& debug,
const Range<dimensions, T>& value)
Debug output operator.