Skip to content

Commit 08a2c1f

Browse files
committed
Vector2.setToPolar implemented.
1 parent 3c91bbf commit 08a2c1f

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

v3/src/math/Vector2.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,19 @@ var Vector2 = new Class({
5454
return this;
5555
},
5656

57+
// Sets the `x` and `y` values of this object from a given polar coordinate.
58+
// @param {number} azimuth - The angular coordinate, in radians.
59+
// @param {number} [radius=1] - The radial coordinate (length).
60+
setToPolar: function (azimuth, radius)
61+
{
62+
if (radius == null) { radius = 1; }
63+
64+
this.x = Math.cos(azimuth) * radius;
65+
this.y = Math.sin(azimuth) * radius;
66+
67+
return this;
68+
},
69+
5770
equals: function (v)
5871
{
5972
return ((this.x === v.x) && (this.y === v.y));

0 commit comments

Comments
 (0)