Intersection work in progress
Review URL: https://codereview.appspot.com/5576043
git-svn-id: http://skia.googlecode.com/svn/trunk@3087 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/experimental/Intersection/QuadraticUtilities.cpp b/experimental/Intersection/QuadraticUtilities.cpp
new file mode 100644
index 0000000..aa784cb
--- /dev/null
+++ b/experimental/Intersection/QuadraticUtilities.cpp
@@ -0,0 +1,21 @@
+#include "QuadraticUtilities.h"
+
+int quadraticRoots(double A, double B, double C, double t[2]) {
+ B *= 2;
+ double square = B * B - 4 * A * C;
+ if (square < 0) {
+ return 0;
+ }
+ double squareRt = sqrt(square);
+ double Q = (B + (B < 0 ? -squareRt : squareRt)) / -2;
+ int foundRoots = 0;
+ if ((Q <= A) ^ (Q < 0)) {
+ t[foundRoots++] = Q / A;
+ }
+ if ((C <= Q) ^ (C < 0)) {
+ t[foundRoots++] = C / Q;
+ }
+ return foundRoots;
+}
+
+