Trax3 3.1.0
trax track library
Loading...
Searching...
No Matches
common::Interval< Valtype > Struct Template Reference

An interval describes the area between two numbers. It is understood to contain the near one and exlude the far. More...

#include <C:/Trend/Development/Trax3/Code/common/Interval.h>

Inheritance diagram for common::Interval< Valtype >:

Public Member Functions

constexpr auto Sign () const noexcept -> decltype(Valtype{}/Valtype{})
constexpr bool Normal () const noexcept
 Is m_Near <= m_Far.
IntervalNormalize () noexcept
 Make m_Near <= m_Far by flipping.
IntervalFlip () noexcept
 swap near and far.
constexpr Valtype Near () const noexcept
constexpr Valtype Far () const noexcept
IntervalNear (Valtype val) noexcept
 Sets the near value of this interval.
IntervalFar (Valtype val) noexcept
 Sets the far value of this interval.
constexpr Valtype Max () const noexcept
constexpr Valtype Min () const noexcept
constexpr Valtype Length () const noexcept
 Distance from m_Near to m_Far.
IntervalLength (Valtype length) noexcept
 Sets the length of the interval by centering it around 0.
constexpr Valtype Center () const noexcept
 gets the value centered in the interval.
IntervalUnion (const Interval &i1, const Interval &i2) noexcept
 Calculates the union of the two intervals.
IntervalUnion (const Interval &interval) noexcept
 Calculates the union of this and interval.
IntervalIntersection (const Interval &intersected, const Interval &with) noexcept
 Calculates the intersection interval of i1 and i2.
IntervalIntersection (const Interval &interval) noexcept
 Calculates the intersection interval of this and interval.
constexpr bool Includes (Valtype val) const noexcept
constexpr bool Includes (const Interval &interval) const noexcept
constexpr bool Touches (Valtype val, Valtype epsilon=Valtype{0}) const noexcept
Valtype Clip (Valtype &val) const noexcept
 Clips the value to the interval.
constexpr const Valtype & Clip (const Valtype &val) const noexcept
Valtype Wrap (Valtype &val) const noexcept
 Wraps the value to the interval.
IntervalExpand (Valtype val) noexcept
 Expands the interval so that it touches (being included or laying on border) val.
IntervalInflate (Valtype dx) noexcept
 Extends the inteval by dx at each end.
IntervalDeflate (Valtype dx) noexcept
 Shrinks the interval by dx at each end.
IntervalMove (Valtype dx) noexcept
 Moves the interval by dx.
IntervalToParent (Interval &interval) const noexcept
 Understands interval as relative to this and transforms it to parent.
IntervalFromParent (Interval &interval) const noexcept
 Understands interval as relative to parent and transforms it to this.
constexpr bool Equals (const Interval &interval, Valtype epsilon=std::numeric_limits< Valtype >::epsilon()) const noexcept
 Comparison.
IntervalRound (int toDigit) noexcept
 Rounds the inteval's values to a certain digit after the point.
Construction
Parameters
valSet the interval at val with no extention
nearvallower value of interval.
farvallower value of interval
constexpr Interval () noexcept=default
 Does not initialize the members.
constexpr Interval (Valtype val) noexcept
 Does not initialize the members.
constexpr Interval (Valtype nearval, Valtype farval) noexcept
 Does not initialize the members.
constexpr Interval (const std::pair< Valtype, Valtype > &pair) noexcept
 Does not initialize the members.
template<typename Valtype2>
constexpr Interval (const Interval< Valtype2 > &interval) noexcept
 Does not initialize the members.
Initialisation

Initializes the interval to origin.

IntervalInit () noexcept
IntervalInit (Valtype nearval, Valtype length) noexcept

Public Attributes

Valtype m_Near
 The 'left' side of the interval; usually the smaller value.
Valtype m_Far
 The 'right' side of the interval; usually the bigger value.

Detailed Description

template<typename Valtype>
struct common::Interval< Valtype >

An interval describes the area between two numbers. It is understood to contain the near one and exlude the far.

Member Function Documentation

◆ Clip()

template<typename Valtype>
Valtype common::Interval< Valtype >::Clip ( Valtype & val) const
inlinenoexcept

Clips the value to the interval.

Returns
The clipped value.

◆ Equals()

template<typename Valtype>
bool common::Interval< Valtype >::Equals ( const Interval< Valtype > & interval,
Valtype epsilon = std::numeric_limits<Valtype>::epsilon() ) const
inlineconstexprnoexcept

Comparison.

Parameters
intervalInterval to compare with.
epsilondeviation margin.
Returns
true if the two Intervals are equal inside the given margin.

◆ Expand()

template<typename Valtype>
Interval< Valtype > & common::Interval< Valtype >::Expand ( Valtype val)
inlinenoexcept

Expands the interval so that it touches (being included or laying on border) val.

If the value is allready included in the interval, no changes are made. If val becomes m_Far Includes() will not return the value as beeing included.

◆ Far()

template<typename Valtype>
Valtype common::Interval< Valtype >::Far ( ) const
inlineconstexprnoexcept
Returns
The far value of this interval.

◆ FromParent()

template<typename Valtype>
Interval< Valtype > & common::Interval< Valtype >::FromParent ( Interval< Valtype > & interval) const
inlinenoexcept

Understands interval as relative to parent and transforms it to this.

Returns
transformed interval.

◆ Includes() [1/2]

template<typename Valtype>
bool common::Interval< Valtype >::Includes ( const Interval< Valtype > & interval) const
inlineconstexprnoexcept
Returns
True if interval is completely inbetween m_Near and m_Far.

◆ Includes() [2/2]

template<typename Valtype>
bool common::Interval< Valtype >::Includes ( Valtype val) const
inlineconstexprnoexcept
Returns
True if val is inbetween m_Near and m_Far. val == m_Near will return true, val == m_Far false.

◆ Intersection() [1/2]

template<typename Valtype>
Interval< Valtype > & common::Interval< Valtype >::Intersection ( const Interval< Valtype > & intersected,
const Interval< Valtype > & with )
inlinenoexcept

Calculates the intersection interval of i1 and i2.

The normal state will be that of intersected; if these rects are not in touch, the resulting interval will be {0,0}.

◆ Intersection() [2/2]

template<typename Valtype>
Interval< Valtype > & common::Interval< Valtype >::Intersection ( const Interval< Valtype > & interval)
inlinenoexcept

Calculates the intersection interval of this and interval.

The normal state will be that of this; if these rects are not in touch, the resulting interval will be {0,0}.

◆ Max()

template<typename Valtype>
Valtype common::Interval< Valtype >::Max ( ) const
inlineconstexprnoexcept
Returns
The maximum of the two limiting values.

◆ Min()

template<typename Valtype>
Valtype common::Interval< Valtype >::Min ( ) const
inlineconstexprnoexcept
Returns
The minimum of the two limiting values.

◆ Near()

template<typename Valtype>
Valtype common::Interval< Valtype >::Near ( ) const
inlineconstexprnoexcept
Returns
The near value of this interval.

◆ Sign()

template<typename Valtype>
auto common::Interval< Valtype >::Sign ( ) const->decltype(Valtype{}/Valtype{})
inlineconstexprnoexcept
Returns
1 if the interval is normal, -1 elsewise.

◆ ToParent()

template<typename Valtype>
Interval< Valtype > & common::Interval< Valtype >::ToParent ( Interval< Valtype > & interval) const
inlinenoexcept

Understands interval as relative to this and transforms it to parent.

Returns
transformed interval.

◆ Touches()

template<typename Valtype>
bool common::Interval< Valtype >::Touches ( Valtype val,
Valtype epsilon = Valtype{0} ) const
inlineconstexprnoexcept
Returns
True if val is inbetween m_Near and m_Far. val == m_Near-epsilon and val == m_Far+epsilon will return true.

◆ Wrap()

template<typename Valtype>
Valtype common::Interval< Valtype >::Wrap ( Valtype & val) const
inlinenoexcept

Wraps the value to the interval.

Returns
The wrapped value.

The documentation for this struct was generated from the following file:
  • C:/Trend/Development/Trax3/Code/common/Interval.h