summaryrefslogtreecommitdiffstats
path: root/src/live_effects/lpe-circle_3pts.cpp
diff options
context:
space:
mode:
authorJabier Arraiza <jabier.arraiza@marker.es>2017-11-03 00:10:02 +0000
committerJabier Arraiza <jabier.arraiza@marker.es>2017-11-03 00:10:02 +0000
commitd2df0412f728dd5bb54537dfdfe7c35b34d40e0e (patch)
treee2703384779e83312c456399999997fcc289c5cf /src/live_effects/lpe-circle_3pts.cpp
parentMerge branch 'master' into powerpencil (diff)
parentchange assignment to equality (diff)
downloadinkscape-d2df0412f728dd5bb54537dfdfe7c35b34d40e0e.tar.gz
inkscape-d2df0412f728dd5bb54537dfdfe7c35b34d40e0e.zip
Merge branch 'master' into powerpencil
Diffstat (limited to 'src/live_effects/lpe-circle_3pts.cpp')
-rw-r--r--src/live_effects/lpe-circle_3pts.cpp12
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);