summaryrefslogtreecommitdiffstats
path: root/src/2geom/interval.h
diff options
context:
space:
mode:
authorKrzysztof Kosi??ski <tweenk.pl@gmail.com>2015-05-22 08:23:27 +0000
committerKrzysztof KosiƄski <tweenk.pl@gmail.com>2015-05-22 08:23:27 +0000
commit25fa09178b7d0d0befa708e93ea5316ef381caa0 (patch)
tree550b4d0d66d0d234b3f49e868cb747987dcc6bf8 /src/2geom/interval.h
parentMerge from trunk (diff)
downloadinkscape-25fa09178b7d0d0befa708e93ea5316ef381caa0.tar.gz
inkscape-25fa09178b7d0d0befa708e93ea5316ef381caa0.zip
Update to 2Geom revision 2396
(bzr r14059.2.16)
Diffstat (limited to 'src/2geom/interval.h')
-rw-r--r--src/2geom/interval.h17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/2geom/interval.h b/src/2geom/interval.h
index 09ea46923..fd446a1c6 100644
--- a/src/2geom/interval.h
+++ b/src/2geom/interval.h
@@ -93,7 +93,7 @@ public:
/// @name Inspect contained values.
/// @{
- /** @brief Check whether both endpoints are finite. */
+ /// Check whether both endpoints are finite.
bool isFinite() const {
return IS_FINITE(min()) && IS_FINITE(max());
}
@@ -102,11 +102,16 @@ public:
Coord valueAt(Coord t) {
return lerp(t, min(), max());
}
- /** @brief Find closest time in [0,1] that maps to the given value. */
- Coord nearestTime(Coord t) {
- if (t < min()) return 0;
- if (t > max()) return 1;
- return (t - min()) / extent();
+ /** @brief 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. */
+ Coord timeAt(Coord v) {
+ return (v - min()) / extent();
+ }
+ /// Find closest time in [0,1] that maps to the given value. */
+ Coord nearestTime(Coord v) {
+ if (v <= min()) return 0;
+ if (v >= max()) return 1;
+ return timeAt(v);
}
/// @}