From 4f4261488e7713c70b899d23c948b4bad843b6e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Sun, 13 Feb 2011 16:24:39 +0000 Subject: [PATCH] Fix issues with _angle caching in Point. --- src/basic/Point.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/basic/Point.js b/src/basic/Point.js index f1a8ee08..ff665c68 100644 --- a/src/basic/Point.js +++ b/src/basic/Point.js @@ -11,17 +11,14 @@ var Point = Base.extend({ } else if(first.x !== undefined) { this.x = first.x; this.y = first.y; - this._angle = first.angle; } else if(first.width !== undefined) { this.x = first.width; this.y = first.height; - this._angle = null; } else if(first.length !== undefined) { this.x = first[0]; this.y = first.length > 1 ? first[1] : first[0]; } else if(typeof first === 'number') { this.x = this.y = first; - this._angle = null; } else { this.x = this.y = 0; } @@ -166,7 +163,9 @@ var Point = Base.extend({ angle = Math.acos(this.dot(point) / div); } } else { - angle = this._angle = Math.atan2(this.y, this.x); + if (this._angle == null) + this._angle = Math.atan2(this.y, this.x); + angle = this._angle; } return angle * 180 / Math.PI; }, @@ -298,4 +297,4 @@ var Point = Base.extend({ return new Point(Math.random(), Math.random()); } } -}); \ No newline at end of file +});