Skip to content

Commit aab4896

Browse files
committed
Added Vector2.angle method
1 parent 9d3c80a commit aab4896

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

v3/src/math/Vector2.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,20 @@ var Vector2 = new Class({
5050
return this;
5151
},
5252

53+
angle: function () {
54+
55+
// computes the angle in radians with respect to the positive x-axis
56+
57+
var angle = Math.atan2(this.y, this.x);
58+
59+
if (angle < 0)
60+
{
61+
angle += 2 * Math.PI;
62+
}
63+
64+
return angle;
65+
},
66+
5367
add: function (src)
5468
{
5569
this.x += src.x;

0 commit comments

Comments
 (0)