aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental/Intersection/LineParameters.h
diff options
context:
space:
mode:
authorGravatar caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-05-18 20:50:33 +0000
committerGravatar caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-05-18 20:50:33 +0000
commitb45a1b46ee25e9b19800b028bb1ca925212ac7b4 (patch)
tree2a2bc0d004962519eaadd605c4b885386fc252cf /experimental/Intersection/LineParameters.h
parenta611c3ea53c02ef80baa32fbfb9cca33f999378d (diff)
shape ops work in progress
git-svn-id: http://skia.googlecode.com/svn/trunk@4006 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'experimental/Intersection/LineParameters.h')
-rw-r--r--experimental/Intersection/LineParameters.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/experimental/Intersection/LineParameters.h b/experimental/Intersection/LineParameters.h
index 188962263e..202ba46c4c 100644
--- a/experimental/Intersection/LineParameters.h
+++ b/experimental/Intersection/LineParameters.h
@@ -4,6 +4,15 @@
// computer-aided design - volume 22 number 9 november 1990 pp 538 - 549
// online at http://cagd.cs.byu.edu/~tom/papers/bezclip.pdf
+// This turns a line segment into a parameterized line, of the form
+// ax + by + c = 0
+// When a^2 + b^2 == 1, the line is normalized.
+// The distance to the line for (x, y) is d(x,y) = ax + by + c
+//
+// Note that the distances below are not necessarily normalized. To get the true
+// distance, it's necessary to either call normalize() after xxxEndPoints(), or
+// divide the result of xxxDistance() by sqrt(normalSquared())
+
class LineParameters {
public:
void cubicEndPoints(const Cubic& pts) {
@@ -42,7 +51,7 @@ public:
bool normalize() {
double normal = sqrt(normalSquared());
- if (normal < SquaredEpsilon) {
+ if (approximately_zero_squared(normal)) {
a = b = c = 0;
return false;
}
@@ -87,6 +96,7 @@ public:
double pointDistance(const _Point& pt) {
return a * pt.x + b * pt.y + c;
}
+
private:
double a;
double b;