Comparing version 0.0.8 to 0.1.0
10
index.js
@@ -76,3 +76,6 @@ var util = require('util'); | ||
Vec3.prototype.modulus = function(other) { | ||
return new Vec3(this.x % other.x , this.y % other.y, this.z % other.z); | ||
return new Vec3( | ||
euclideanMod(this.x, other.x), | ||
euclideanMod(this.y, other.y), | ||
euclideanMod(this.z, other.z)); | ||
}; | ||
@@ -94,1 +97,6 @@ Vec3.prototype.distanceTo = function(other) { | ||
}; | ||
function euclideanMod(numerator, denominator) { | ||
var result = numerator % denominator; | ||
return result < 0 ? result + denominator : result; | ||
} |
{ | ||
"name": "vec3", | ||
"version": "0.0.8", | ||
"version": "0.1.0", | ||
"description": "3d vector math with good unit tests", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -165,14 +165,14 @@ var v = require('../') | ||
it("modulus", function() { | ||
var v1 = new Vec3(12, 32, 46); | ||
var v2 = new Vec3(14, 32, 44); | ||
var v1 = new Vec3(12, 32, -1); | ||
var v2 = new Vec3(14, 32, 16); | ||
var v3 = v1.modulus(v2); | ||
assert.strictEqual(v1.x, 12); | ||
assert.strictEqual(v1.y, 32); | ||
assert.strictEqual(v1.z, 46); | ||
assert.strictEqual(v1.z, -1); | ||
assert.strictEqual(v2.x, 14); | ||
assert.strictEqual(v2.y, 32); | ||
assert.strictEqual(v2.z, 44); | ||
assert.strictEqual(v2.z, 16); | ||
assert.strictEqual(v3.x, 12); | ||
assert.strictEqual(v3.y, 0); | ||
assert.strictEqual(v3.z, 2); | ||
assert.strictEqual(v3.z, 15); | ||
}); | ||
@@ -179,0 +179,0 @@ it("volume", function() { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8795
273