Inkscape
Vector Graphics Editor
|
Range of real numbers that is never empty. More...
#include <interval.h>
Public Member Functions | |
Inspect contained values. | |
Check whether both endpoints are finite. | |
bool | isFinite () const |
constexpr Coord | valueAt (Coord t) const |
Map the interval [0,1] onto this one. | |
constexpr Coord | timeAt (Coord v) const |
Compute a time value that maps to the given value. | |
constexpr Coord | nearestTime (Coord v) const |
Find closest time in [0,1] that maps to the given value. */. | |
Test coordinates and other intervals for inclusion. | |
constexpr bool | interiorContains (Coord val) const |
Check whether the interior of the interval includes this number. | |
constexpr bool | interiorContains (Interval const &val) const |
Check whether the interior of the interval includes the given interval. | |
constexpr bool | lowerContains (Coord val) const |
Check whether the number is contained in the union of the interior and the lower boundary. | |
constexpr bool | lowerContains (Interval const &val) const |
Check whether the given interval is contained in the union of the interior and the lower boundary. | |
constexpr bool | upperContains (Coord val) |
Check whether the number is contained in the union of the interior and the upper boundary. | |
constexpr bool | upperContains (Interval const &val) const |
Check whether the given interval is contained in the union of the interior and the upper boundary. | |
constexpr bool | interiorIntersects (Interval const &val) const |
Check whether the interiors of the intervals have any common elements. | |
Operators | |
constexpr Interval & | operator*= (Coord s) |
Scale an interval. | |
constexpr Interval & | operator/= (Coord s) |
Scale an interval by the inverse of the specified value. | |
constexpr Interval & | operator*= (Interval const &o) |
Multiply two intervals. | |
constexpr bool | operator== (IntInterval const &ii) const |
constexpr bool | operator== (Interval const &other) const |
Rounding to integer values | |
IntInterval | roundOutwards () const |
Return the smallest integer interval which contains this one. | |
OptIntInterval | roundInwards () const |
Return the largest integer interval which is contained in this one. | |
![]() | |
constexpr Coord | min () const |
constexpr Coord | max () const |
constexpr Coord | extent () const |
constexpr Coord | middle () const |
constexpr bool | isSingular () const |
Coord | operator[] (unsigned i) const |
constexpr Coord | operator[] (Dim2 d) const |
constexpr Coord | clamp (Coord val) const |
Coord | nearestEnd (Coord val) const |
Return the closer end of the interval. | |
constexpr Coord | get () const |
constexpr bool | contains (Coord val) const |
Check whether the interval includes this number. | |
constexpr bool | contains (CInterval const &val) const |
Check whether the interval includes the given interval. | |
constexpr bool | intersects (CInterval const &val) const |
Check whether the intervals have any common elements. | |
constexpr void | setMin (Coord val) |
Set the lower boundary of the interval. | |
constexpr void | setMax (Coord val) |
Set the upper boundary of the interval. | |
constexpr void | setEnds (Coord a, Coord b) |
Set both ends of the interval simultaneously. | |
constexpr void | expandTo (Coord val) |
Extend the interval to include the given number. | |
constexpr void | expandBy (Coord amount) |
Expand or shrink the interval in both directions by the given amount. | |
constexpr void | unionWith (CInterval const &a) |
Union the interval with another one. | |
constexpr Self & | operator+= (Coord amnt) |
Offset the interval by a specified amount. | |
constexpr Self & | operator+= (CInterval const &o) |
Add two intervals. | |
constexpr Self & | operator-= (Coord amnt) |
Offset the interval by the negation of the specified amount. | |
constexpr Self & | operator-= (CInterval const &o) |
Subtract two intervals. | |
constexpr Self | operator- () const |
Return an interval mirrored about 0. | |
constexpr Self & | operator|= (CInterval const &o) |
Union two intervals. | |
constexpr bool | operator== (CInterval const &other) const |
Test for interval equality. | |
constexpr | GenericInterval ()=default |
Create an interval that contains only zero. | |
constexpr | GenericInterval (Coord u) |
Create an interval that contains a single point. | |
constexpr | GenericInterval (Coord u, Coord v) |
Create an interval that contains all points between u and v . | |
Private Types | |
using | Base = GenericInterval< Coord > |
Create intervals. | |
constexpr | Interval ()=default |
Create an interval that contains only zero. | |
constexpr | Interval (Coord u) |
Create an interval that contains a single point. | |
constexpr | Interval (Coord u, Coord v) |
Create an interval that contains all points between u and v . | |
constexpr | Interval (IntInterval const &i) |
Convert from integer interval. | |
constexpr | Interval (Base const &b) |
template<typename InputIterator > | |
static Interval | from_range (InputIterator start, InputIterator end) |
Create an interval containing a range of values. | |
static Interval | from_array (Coord const *c, unsigned n) |
Create an interval from a C-style array of values it should contain. | |
Additional Inherited Members | |
![]() | |
using | output_type = Coord |
![]() | |
static CInterval | from_range (InputIterator start, InputIterator end) |
Create an interval containing a range of values. | |
static CInterval | from_array (Coord const *c, unsigned n) |
Create an interval from a C-style array of values it should contain. | |
![]() | |
Coord | _b [2] |
![]() | |
GenericInterval< Coord > | unify (GenericInterval< Coord > const &a, GenericInterval< Coord > const &b) |
Union two intervals. | |
Range of real numbers that is never empty.
Intervals are closed ranges \([a, b]\), which means they include their endpoints. To use them as open ranges, you can use the interiorContains() methods.
Definition at line 57 of file interval.h.
|
private |
Definition at line 60 of file interval.h.
|
constexprdefault |
Create an interval that contains only zero.
|
inlineexplicitconstexpr |
Create an interval that contains a single point.
Definition at line 67 of file interval.h.
Create an interval that contains all points between u
and v
.
Definition at line 69 of file interval.h.
|
inlineconstexpr |
Convert from integer interval.
Definition at line 71 of file interval.h.
|
inlineconstexpr |
Definition at line 72 of file interval.h.
Create an interval from a C-style array of values it should contain.
Definition at line 86 of file interval.h.
References c, and Geom::GenericInterval< Coord >::from_array().
Referenced by wrap_interval().
|
inlinestatic |
Create an interval containing a range of values.
The resulting interval will contain all values from the given range. The return type of iterators must be convertible to Coord. The given range must not be empty. For potentially empty ranges, see OptInterval.
start | Beginning of the range |
end | End of the range |
Definition at line 82 of file interval.h.
References end, Geom::GenericInterval< Coord >::from_range(), and start.
|
inlineconstexpr |
Check whether the interior of the interval includes this number.
Interior means all numbers in the interval except its ends.
Definition at line 119 of file interval.h.
References Geom::GenericInterval< Coord >::max(), and Geom::GenericInterval< Coord >::min().
Referenced by wrap_interiorContains_coord(), and wrap_interiorContains_ivl().
|
inlineconstexpr |
Check whether the interior of the interval includes the given interval.
Interior means all numbers in the interval except its ends.
Definition at line 122 of file interval.h.
References Geom::GenericInterval< Coord >::max(), Geom::GenericInterval< C >::max(), Geom::GenericInterval< C >::min(), and Geom::GenericInterval< Coord >::min().
|
inlineconstexpr |
Check whether the interiors of the intervals have any common elements.
A single point in common is not considered an intersection.
Definition at line 133 of file interval.h.
References Geom::GenericInterval< C >::max(), Geom::GenericInterval< Coord >::max(), Geom::GenericInterval< C >::min(), and Geom::GenericInterval< Coord >::min().
|
inline |
Definition at line 94 of file interval.h.
References Geom::GenericInterval< Coord >::max(), and Geom::GenericInterval< Coord >::min().
Referenced by Geom::Line::clip().
|
inlineconstexpr |
Check whether the number is contained in the union of the interior and the lower boundary.
Definition at line 124 of file interval.h.
References Geom::GenericInterval< Coord >::max(), and Geom::GenericInterval< Coord >::min().
Referenced by Geom::EllipticalArc::winding().
|
inlineconstexpr |
Check whether the given interval is contained in the union of the interior and the lower boundary.
Definition at line 126 of file interval.h.
References Geom::GenericInterval< Coord >::max(), Geom::GenericInterval< C >::max(), Geom::GenericInterval< C >::min(), and Geom::GenericInterval< Coord >::min().
Find closest time in [0,1] that maps to the given value. */.
Definition at line 108 of file interval.h.
References Geom::GenericInterval< Coord >::max(), Geom::GenericInterval< Coord >::min(), and timeAt().
Scale an interval.
Definition at line 142 of file interval.h.
References Geom::GenericInterval< Coord >::_b.
Multiply two intervals.
Product is defined as the set of points that can be obtained by multiplying any value from the second operand by any value from the first operand: \(S = \{x \in A, y \in B: x * y\}\)
Definition at line 161 of file interval.h.
References Geom::GenericInterval< Coord >::expandTo(), Geom::GenericInterval< C >::max(), Geom::GenericInterval< Coord >::max(), Geom::GenericInterval< C >::min(), and Geom::GenericInterval< Coord >::min().
Scale an interval by the inverse of the specified value.
Definition at line 150 of file interval.h.
References Geom::GenericInterval< Coord >::_b.
|
inlineconstexpr |
Definition at line 173 of file interval.h.
References Geom::GenericInterval< Coord >::operator==().
|
inlineconstexpr |
Definition at line 170 of file interval.h.
References Geom::GenericInterval< C >::max(), Geom::GenericInterval< Coord >::max(), Geom::GenericInterval< C >::min(), and Geom::GenericInterval< Coord >::min().
|
inline |
Return the largest integer interval which is contained in this one.
Definition at line 185 of file interval.h.
References floor(), Geom::GenericInterval< Coord >::max(), and Geom::GenericInterval< Coord >::min().
|
inline |
Return the smallest integer interval which contains this one.
Definition at line 181 of file interval.h.
References floor(), Geom::GenericInterval< Coord >::max(), and Geom::GenericInterval< Coord >::min().
Compute a time value that maps to the given value.
The supplied value does not need to be in the interval for this method to work.
Definition at line 104 of file interval.h.
References Geom::GenericInterval< Coord >::extent(), and Geom::GenericInterval< Coord >::min().
Referenced by nearestTime().
|
inlineconstexpr |
Check whether the number is contained in the union of the interior and the upper boundary.
Definition at line 128 of file interval.h.
References Geom::GenericInterval< Coord >::max(), and Geom::GenericInterval< Coord >::min().
|
inlineconstexpr |
Check whether the given interval is contained in the union of the interior and the upper boundary.
Definition at line 130 of file interval.h.
References Geom::GenericInterval< Coord >::max(), Geom::GenericInterval< C >::max(), Geom::GenericInterval< C >::min(), and Geom::GenericInterval< Coord >::min().
Map the interval [0,1] onto this one.
This method simply performs 1D linear interpolation between endpoints.
Definition at line 99 of file interval.h.
References Geom::lerp(), Geom::GenericInterval< Coord >::max(), and Geom::GenericInterval< Coord >::min().
Referenced by Geom::Curve::intersectSelf(), Geom::detail::bezier_clipping::map_to(), and Geom::nearest_time().