mirror of
https://github.com/photonstorm/phaser
synced 2024-12-01 00:49:41 +00:00
Vector2.setToPolar implemented.
This commit is contained in:
parent
3c91bbf236
commit
08a2c1f544
1 changed files with 13 additions and 0 deletions
|
@ -54,6 +54,19 @@ var Vector2 = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
// Sets the `x` and `y` values of this object from a given polar coordinate.
|
||||
// @param {number} azimuth - The angular coordinate, in radians.
|
||||
// @param {number} [radius=1] - The radial coordinate (length).
|
||||
setToPolar: function (azimuth, radius)
|
||||
{
|
||||
if (radius == null) { radius = 1; }
|
||||
|
||||
this.x = Math.cos(azimuth) * radius;
|
||||
this.y = Math.sin(azimuth) * radius;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
equals: function (v)
|
||||
{
|
||||
return ((this.x === v.x) && (this.y === v.y));
|
||||
|
|
Loading…
Reference in a new issue