projects
/
graphviz
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
490486a
)
improve arithmetic limit fix
author
ellson
<devnull@localhost>
Tue, 3 Oct 2006 20:23:35 +0000
(20:23 +0000)
committer
ellson
<devnull@localhost>
Tue, 3 Oct 2006 20:23:35 +0000
(20:23 +0000)
lib/common/geom.c
patch
|
blob
|
history
diff --git
a/lib/common/geom.c
b/lib/common/geom.c
index 0c4bb3b059b4811ff020ba9abb1d09b429be150a..a76e026862d4ea221e7bffbd3c7d64b2d5a1ad2a 100644
(file)
--- a/
lib/common/geom.c
+++ b/
lib/common/geom.c
@@
-527,6
+527,7
@@
double ptToLine2 (pointf a, pointf b, pointf p)
double dx = b.x-a.x;
double dy = b.y-a.y;
double a2 = (p.y-a.y)*dx - (p.x-a.x)*dy;
- if (a2 < .00001) return 0.;
- return (a2*a2) / (dx*dx + dy*dy);
+ a2 *= a2; /* square - ensures that it is positive */
+ if (a2 < .00001) return 0.; /* avoid 0/0 problems */
+ return a2 / (dx*dx + dy*dy);
}