shape ops work in progress
git-svn-id: http://skia.googlecode.com/svn/trunk@7738 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/experimental/Intersection/QuadraticUtilities.cpp b/experimental/Intersection/QuadraticUtilities.cpp
index a84009d..d33fda8 100644
--- a/experimental/Intersection/QuadraticUtilities.cpp
+++ b/experimental/Intersection/QuadraticUtilities.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
#include "CubicUtilities.h"
+#include "Extrema.h"
#include "QuadraticUtilities.h"
#include "TriangleUtilities.h"
@@ -45,6 +46,27 @@
return pointInTriangle((const Triangle&) quad, pt);
}
+_Point top(const Quadratic& quad, double startT, double endT) {
+ Quadratic sub;
+ sub_divide(quad, startT, endT, sub);
+ _Point topPt = sub[0];
+ if (topPt.y > sub[2].y || (topPt.y == sub[2].y && topPt.x > sub[2].x)) {
+ topPt = sub[2];
+ }
+ if (!between(sub[0].y, sub[1].y, sub[2].y)) {
+ double extremeT;
+ if (findExtrema(sub[0].y, sub[1].y, sub[2].y, &extremeT)) {
+ extremeT = startT + (endT - startT) * extremeT;
+ _Point test;
+ xy_at_t(quad, extremeT, test.x, test.y);
+ if (topPt.y > test.y || (topPt.y == test.y && topPt.x > test.x)) {
+ topPt = test;
+ }
+ }
+ }
+ return topPt;
+}
+
/*
Numeric Solutions (5.6) suggests to solve the quadratic by computing
Q = -1/2(B + sgn(B)Sqrt(B^2 - 4 A C))