Added Vector.equals methods.

This commit is contained in:
Richard Davey 2017-09-21 17:11:56 +01:00
parent a89c6a872a
commit 3d09a834b7
3 changed files with 16 additions and 1 deletions

View file

@ -50,8 +50,13 @@ var Vector2 = new Class({
return this;
},
angle: function () {
equals: function (v)
{
return ((this.x === v.x) && (this.y === v.y));
},
angle: function ()
{
// computes the angle in radians with respect to the positive x-axis
var angle = Math.atan2(this.y, this.x);

View file

@ -44,6 +44,11 @@ var Vector3 = new Class({
return this;
},
equals: function (v)
{
return ((this.x === v.x) && (this.y === v.y) && (this.z === v.z));
},
copy: function (src)
{
this.x = src.x;

View file

@ -40,6 +40,11 @@ var Vector4 = new Class({
return this;
},
equals: function (v)
{
return ((this.x === v.x) && (this.y === v.y) && (this.z === v.z) && (this.w === v.w));
},
set: function (x, y, z, w)
{
if (typeof x === 'object')