Comparing version
@@ -0,1 +1,6 @@ | ||
## 0.1.6 | ||
* add distance squared (thanks @TheDudeFromCI) | ||
* fix typings (thanks @iczero) | ||
## 0.1.5 | ||
@@ -2,0 +7,0 @@ |
@@ -1,2 +0,2 @@ | ||
declare class Vec3 { | ||
export class Vec3 { | ||
constructor(x: number, y: number, z: number); | ||
@@ -38,2 +38,4 @@ | ||
distanceSquared(other: Vec3): number; | ||
equals(other: Vec3): boolean; | ||
@@ -73,8 +75,7 @@ | ||
} | ||
declare function v(x: null | Array<number | string> | {x: number | string, y: number | string, z: number | string} | string, y?: number | string, z?: number | string): Vec3; | ||
type Vec3Constructor = typeof Vec3; | ||
declare namespace v { | ||
const Vec3: Vec3Constructor; | ||
export type Vec3 = Vec3Constructor; | ||
} | ||
export = v; | ||
export default function v( | ||
x: null | Array<number | string> | {x: number | string, y: number | string, z: number | string} | string, | ||
y?: number | string, | ||
z?: number | string | ||
): Vec3; |
@@ -94,2 +94,9 @@ const re = /\((-?[.\d]+), (-?[.\d]+), (-?[.\d]+)\)/ | ||
distanceSquared (other) { | ||
var dx = other.x - this.x | ||
var dy = other.y - this.y | ||
var dz = other.z - this.z | ||
return dx * dx + dy * dy + dz * dz | ||
} | ||
equals (other) { | ||
@@ -96,0 +103,0 @@ return this.x === other.x && this.y === other.y && this.z === other.z |
{ | ||
"name": "vec3", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "3d vector math with good unit tests", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -141,2 +141,11 @@ /* eslint-env mocha */ | ||
}) | ||
it('distanceSquared', function () { | ||
var v1 = new Vec3(1, 1, 1) | ||
var v2 = new Vec3(2, 2, 2) | ||
var dist1 = v1.distanceSquared(v2) | ||
var dist2 = v2.distanceSquared(v1) | ||
var expected = 3 | ||
assert.strictEqual(dist1, dist2) | ||
assert.strictEqual(Math.round(dist1 * 100000), Math.round(expected * 100000)) | ||
}) | ||
it('equals', function () { | ||
@@ -143,0 +152,0 @@ var v1 = new Vec3(1, 2, 3) |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
22695
5.55%8
14.29%562
2.74%0
-100%