shape ops work in progress
git-svn-id: http://skia.googlecode.com/svn/trunk@7788 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/experimental/Intersection/QuarticRoot.cpp b/experimental/Intersection/QuarticRoot.cpp
index 50f85b5..ea786e4 100644
--- a/experimental/Intersection/QuarticRoot.cpp
+++ b/experimental/Intersection/QuarticRoot.cpp
@@ -40,17 +40,22 @@
bzero(str, sizeof(str));
sprintf(str, "Solve[%1.19g x^4 + %1.19g x^3 + %1.19g x^2 + %1.19g x + %1.19g == 0, x]",
t4, t3, t2, t1, t0);
+ mathematica_ize(str, sizeof(str));
+#if ONE_OFF_DEBUG
+ SkDebugf("%s\n", str);
+#endif
#endif
if (approximately_zero_when_compared_to(t4, t0) // 0 is one root
&& approximately_zero_when_compared_to(t4, t1)
- && approximately_zero_when_compared_to(t4, t2)
- && approximately_zero_when_compared_to(t4, t3)) {
+ && approximately_zero_when_compared_to(t4, t2)) {
if (approximately_zero_when_compared_to(t3, t0)
&& approximately_zero_when_compared_to(t3, t1)
&& approximately_zero_when_compared_to(t3, t2)) {
return quadraticRootsReal(t2, t1, t0, roots);
}
- return cubicRootsReal(t3, t2, t1, t0, roots);
+ if (approximately_zero_when_compared_to(t4, t3)) {
+ return cubicRootsReal(t3, t2, t1, t0, roots);
+ }
}
if (approximately_zero_when_compared_to(t0, t1) // 0 is one root
&& approximately_zero_when_compared_to(t0, t2)
@@ -79,8 +84,8 @@
return -1;
}
-int quarticRootsReal(const double A, const double B, const double C, const double D,
- const double E, double s[4]) {
+int quarticRootsReal(int firstCubicRoot, const double A, const double B, const double C,
+ const double D, const double E, double s[4]) {
double u, v;
/* normal form: x^4 + Ax^3 + Bx^2 + Cx + D = 0 */
const double invA = 1 / A;
@@ -149,7 +154,7 @@
double z;
num = 0;
int num2 = 0;
- for (index = 0; index < roots; ++index) {
+ for (index = firstCubicRoot; index < roots; ++index) {
z = cubicRoots[index];
/* ... to build two quadric equations */
u = z * z - r;