summaryrefslogtreecommitdiffstats
path: root/src/2geom/interval.h
diff options
context:
space:
mode:
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);
}
/// @}