work in progress
git-svn-id: http://skia.googlecode.com/svn/trunk@3702 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/experimental/Intersection/LineParameterization.cpp b/experimental/Intersection/LineParameterization.cpp
index 4455cf2..1611a31 100644
--- a/experimental/Intersection/LineParameterization.cpp
+++ b/experimental/Intersection/LineParameterization.cpp
@@ -28,6 +28,29 @@
return true;
}
+bool implicit_matches_ulps(const _Line& one, const _Line& two, int ulps) {
+ _Point oneD, twoD;
+ tangent(one, oneD);
+ tangent(two, twoD);
+ /* See if the slopes match, i.e.
+ dx1 / dy1 == dx2 / dy2
+ (dy1 * dy2) * dx1 / dy1 == (dy1 * dy2) * dx2 / dy2
+ dy2 * dx1 == dy1 * dx2
+ */
+ int diff = UlpsDiff(oneD.x * twoD.y, twoD.x * oneD.y);
+ if (diff < 0 || diff > ulps) {
+ return false;
+ }
+ /* See if the axis intercepts match, i.e.
+ y0 - x0 * dy / dx == y1 - x1 * dy / dx
+ dx * (y0 - x0 * dy / dx) == dx * (y1 - x1 * dy / dx)
+ dx * y0 - x0 * dy == dx * y1 - x1 * dy
+ */
+ diff = UlpsDiff(oneD.x * one[0].y - oneD.y * one[0].x,
+ oneD.x * two[0].y - oneD.y * two[0].x);
+ return diff >= 0 && diff <= ulps;
+}
+
void tangent(const _Line& line, _Point& result) {
result.x = line[0].x - line[1].x;
result.y = line[0].y - line[1].y;