🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

vec3

Package Overview
Dependencies
Maintainers
2
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vec3 - npm Package Compare versions

Comparing version

to
0.1.6

.github/workflows/node.js.yml

5

HISTORY.md

@@ -0,1 +1,6 @@

## 0.1.6
* add distance squared (thanks @TheDudeFromCI)
* fix typings (thanks @iczero)
## 0.1.5

@@ -2,0 +7,0 @@

17

index.d.ts

@@ -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)