shape ops work in progress
add quartic solution for intersecting quadratics

git-svn-id: http://skia.googlecode.com/svn/trunk@5541 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/experimental/Intersection/QuadraticParameterization.cpp b/experimental/Intersection/QuadraticParameterization.cpp
index 7d86f7f..8e7f1a2 100644
--- a/experimental/Intersection/QuadraticParameterization.cpp
+++ b/experimental/Intersection/QuadraticParameterization.cpp
@@ -5,6 +5,7 @@
  * found in the LICENSE file.
  */
 #include "CurveIntersection.h"
+#include "QuadraticParameterization.h"
 #include "QuadraticUtilities.h"
 
 /* from http://tom.cs.byu.edu/~tom/papers/cvgip84.pdf 4.1
@@ -49,19 +50,10 @@
  *
  */
 
-enum {
-    xx_coeff,
-    xy_coeff,
-    yy_coeff,
-    x_coeff,
-    y_coeff,
-    c_coeff,
-    coeff_count
-};
 
 static bool straight_forward = true;
 
-static void implicit_coefficients(const Quadratic& q, double p[coeff_count]) {
+QuadImplicitForm::QuadImplicitForm(const Quadratic& q) {
     double a, b, c;
     set_abc(&q[0].x, a, b, c);
     double d, e, f;
@@ -103,28 +95,30 @@
   * lazily compute the coefficients, comparing the easiest to compute first.
   * xx and yy first; then xy; and so on.
   */
-bool implicit_matches(const Quadratic& one, const Quadratic& two) {
-    double p1[coeff_count]; // a'xx , b'xy , c'yy , d'x , e'y , f
-    double p2[coeff_count];
-    implicit_coefficients(one, p1);
-    implicit_coefficients(two, p2);
+bool QuadImplicitForm::implicit_match(const QuadImplicitForm& p2) const {
     int first = 0;
     for (int index = 0; index < coeff_count; ++index) {
-        if (approximately_zero(p1[index]) || approximately_zero(p2[index])) {
+        if (approximately_zero(p[index]) && approximately_zero(p2.p[index])) {
             first += first == index;
             continue;
         }
         if (first == index) {
             continue;
         }
-        if (!approximately_equal(p1[index] * p2[first],
-                p1[first] * p2[index])) {
+        if (!approximately_equal(p[index] * p2.p[first],
+                p[first] * p2.p[index])) {
             return false;
         }
     }
     return true;
 }
 
+bool implicit_matches(const Quadratic& quad1, const Quadratic& quad2) {
+    QuadImplicitForm i1(quad1);  // a'xx , b'xy , c'yy , d'x , e'y , f
+    QuadImplicitForm i2(quad2);
+    return i1.implicit_match(i2);
+}
+
 static double tangent(const double* quadratic, double t) {
     double a, b, c;
     set_abc(quadratic, a, b, c);
@@ -136,5 +130,7 @@
     result.y = tangent(&quadratic[0].y, t);
 }
 
+
+
 // unit test to return and validate parametric coefficients
 #include "QuadraticParameterization_TestUtility.cpp"