shape ops work in progress
git-svn-id: http://skia.googlecode.com/svn/trunk@3861 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/experimental/Intersection/QuadraticReduceOrder.cpp b/experimental/Intersection/QuadraticReduceOrder.cpp
index 4eef1a7..f85cdc8 100644
--- a/experimental/Intersection/QuadraticReduceOrder.cpp
+++ b/experimental/Intersection/QuadraticReduceOrder.cpp
@@ -60,13 +60,7 @@
assert(0);
}
}
- LineParameters lineParameters;
- lineParameters.quadEndPoints(quad, startIndex, endIndex);
- double normalSquared = lineParameters.normalSquared();
- double distance = lineParameters.controlPtDistance(quad); // not normalized
- double limit = normalSquared * SquaredEpsilon;
- double distSq = distance * distance;
- if (distSq > limit) {
+ if (!isLinear(quad, startIndex, endIndex)) {
return 0;
}
// four are colinear: return line formed by outside
@@ -113,6 +107,16 @@
return 2;
}
+bool isLinear(const Quadratic& quad, int startIndex, int endIndex) {
+ LineParameters lineParameters;
+ lineParameters.quadEndPoints(quad, startIndex, endIndex);
+ double normalSquared = lineParameters.normalSquared();
+ double distance = lineParameters.controlPtDistance(quad); // not normalized
+ double limit = normalSquared * SquaredEpsilon;
+ double distSq = distance * distance;
+ return distSq <= limit;
+}
+
// reduce to a quadratic or smaller
// look for identical points
// look for all four points in a line