From 5a34a46cdf8cdabaa24533bd0db7e5ba4e41f5a3 Mon Sep 17 00:00:00 2001 From: Val Erastov Date: Tue, 24 May 2016 22:11:14 -0700 Subject: [PATCH] fix arc selection bug --- web/app/sketcher/shapes/arc.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/web/app/sketcher/shapes/arc.js b/web/app/sketcher/shapes/arc.js index 86874b0d..af1ec4d4 100644 --- a/web/app/sketcher/shapes/arc.js +++ b/web/app/sketcher/shapes/arc.js @@ -83,7 +83,15 @@ TCAD.TWO.Arc.prototype.drawImpl = function(ctx, scale) { TCAD.TWO.Arc.prototype.normalDistance = function(aim) { - return Math.abs(TCAD.math.distance(aim.x, aim.y, this.c.x, this.c.y) - this.radiusForDrawing()); + var aimAngle = Math.atan2(this.c.y - aim.y, this.c.x - aim.x); + if (aimAngle <= this.getStartAngle() && aimAngle >= this.getEndAngle()) { + return Math.abs(TCAD.math.distance(aim.x, aim.y, this.c.x, this.c.y) - this.radiusForDrawing()); + } else { + return Math.min( + TCAD.math.distance(aim.x, aim.y, this.a.x, this.a.y), + TCAD.math.distance(aim.x, aim.y, this.b.x, this.b.y) + ); + } }; TCAD.TWO.Arc.prototype.stabilize = function(viewer) {