aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental/Intersection/LineCubicIntersection.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'experimental/Intersection/LineCubicIntersection.cpp')
-rw-r--r--experimental/Intersection/LineCubicIntersection.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/experimental/Intersection/LineCubicIntersection.cpp b/experimental/Intersection/LineCubicIntersection.cpp
index 500a91e053..8517b7e0f8 100644
--- a/experimental/Intersection/LineCubicIntersection.cpp
+++ b/experimental/Intersection/LineCubicIntersection.cpp
@@ -139,7 +139,25 @@ int horizontalIntersect(const Cubic& cubic, double y, double tRange[3]) {
LineCubicIntersections c(cubic, *((_Line*) 0), tRange);
return c.horizontalIntersect(y);
}
-
+
+int horizontalIntersect(const Cubic& cubic, double left, double right, double y,
+ double tRange[3]) {
+ LineCubicIntersections c(cubic, *((_Line*) 0), tRange);
+ int result = c.horizontalIntersect(y);
+ for (int index = 0; index < result; ) {
+ double x, y;
+ xy_at_t(cubic, tRange[index], x, y);
+ if (x < left || x > right) {
+ if (--result > index) {
+ tRange[index] = tRange[result];
+ }
+ continue;
+ }
+ ++index;
+ }
+ return result;
+}
+
int intersect(const Cubic& cubic, const _Line& line, double cRange[3], double lRange[3]) {
LineCubicIntersections c(cubic, line, cRange);
int roots;