diff --git a/web/app/arc.js b/web/app/arc.js index 30c60eb5..75d8da24 100644 --- a/web/app/arc.js +++ b/web/app/arc.js @@ -53,9 +53,16 @@ TCAD.TWO.Arc.prototype.distanceB = function() { TCAD.TWO.Arc.prototype.drawImpl = function(ctx, scale) { ctx.beginPath(); var r = this.radiusForDrawing(); - ctx.arc(this.c.x, this.c.y, r, - Math.atan2(this.a.y - this.c.y, this.a.x - this.c.x), - Math.atan2(this.b.y - this.c.y, this.b.x - this.c.x)); + var startAngle = Math.atan2(this.a.y - this.c.y, this.a.x - this.c.x); + var endAngle; + if ( this.a.isCoincidentTo(this.b) || + (TCAD.utils.areEqual(this.a.x, this.b.x, TCAD.utils.TOLERANCE) && + TCAD.utils.areEqual(this.a.y, this.b.y, TCAD.utils.TOLERANCE))) { + endAngle = startAngle + 2 * Math.PI; + } else { + endAngle = Math.atan2(this.b.y - this.c.y, this.b.x - this.c.x); + } + ctx.arc(this.c.x, this.c.y, r, startAngle, endAngle); ctx.stroke(); }; diff --git a/web/app/canvas.js b/web/app/canvas.js index 074ffd8a..72061097 100644 --- a/web/app/canvas.js +++ b/web/app/canvas.js @@ -274,6 +274,15 @@ TCAD.TWO.SketchObject = function() { this.linked = []; }; +TCAD.TWO.SketchObject.prototype.isCoincidentTo = function(other) { + for (var i = 0; i < this.linked.length; i++) { + var obj = this.linked[i]; + if (obj.id === other.id) { + return true; + } + } + return false; +}; TCAD.TWO.SketchObject.prototype._translate = function(dx, dy, translated) { translated[this.id] = 'x';