diff options
| author | Stefano Facchini <stefano.facchini@gmail.com> | 2017-10-08 10:35:03 +0000 |
|---|---|---|
| committer | Stefano Facchini <stefano.facchini@gmail.com> | 2017-10-08 10:39:30 +0000 |
| commit | 8bc47bf27b1cdb5a05a88a0600ad69a2a6bfde46 (patch) | |
| tree | d9f0e45976bcfd84dcbb0037fd8a7add5f5bd469 /src | |
| parent | Merge branch 'refactoring' of gitlab.com:shlomif/inkscape (diff) | |
| download | inkscape-8bc47bf27b1cdb5a05a88a0600ad69a2a6bfde46.tar.gz inkscape-8bc47bf27b1cdb5a05a88a0600ad69a2a6bfde46.zip | |
Circle3pts LPE: handle overlapping points
If two of the three points overlap, just draw the circle having that segment
as diameter. This is not rigorous mathematically, but it is a reasonable
behavior and avoid a crash when snapping is on.
Diffstat (limited to 'src')
| -rw-r--r-- | src/live_effects/lpe-circle_3pts.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/live_effects/lpe-circle_3pts.cpp b/src/live_effects/lpe-circle_3pts.cpp index 3410b13f2..c49d5ca4d 100644 --- a/src/live_effects/lpe-circle_3pts.cpp +++ b/src/live_effects/lpe-circle_3pts.cpp @@ -40,12 +40,18 @@ static void _circle3(Geom::Point const &A, Geom::Point const &B, Geom::Point con Point v = (B - A).ccw(); Point w = (C - B).ccw(); + double det = -v[0] * w[1] + v[1] * w[0]; - Point F = E - D; - double lambda = 1/det * (-w[1] * F[0] + w[0] * F[1]); + Point M; + if (!v.isZero()) { + Point F = E - D; + double lambda = det == 0 ? 0 : (-w[1] * F[0] + w[0] * F[1]) / det; + M = D + v * lambda; + } else { + M = E; + } - Point M = D + v * lambda; double radius = L2(M - A); Geom::Circle c(M, radius); |
