Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ngraph.physics.primitives

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ngraph.physics.primitives - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

31

index.js

@@ -10,2 +10,3 @@ module.exports = {

this.pos = new Vector2d(x, y);
this.prevPos = new Vector2d(x, y);
this.force = new Vector2d();

@@ -17,4 +18,10 @@ this.velocity = new Vector2d();

function Vector2d(x, y) {
this.x = typeof x === 'number' ? x : 0;
this.y = typeof y === 'number' ? y : 0;
if (x && typeof x !== 'number') {
// could be another vector
this.x = typeof x.x === 'number' ? x.x : 0;
this.y = typeof x.y === 'number' ? x.y : 0;
} else {
this.x = typeof x === 'number' ? x : 0;
this.y = typeof y === 'number' ? y : 0;
}
}

@@ -24,6 +31,7 @@

this.x = this.y = 0;
}
};
function Body3d(x, y, z) {
this.pos = new Vector3d(x, y, z);
this.prevPos = new Vector3d(x, y, z);
this.force = new Vector3d();

@@ -35,9 +43,16 @@ this.velocity = new Vector3d();

function Vector3d(x, y, z) {
this.x = typeof x === 'number' ? x : 0;
this.y = typeof y === 'number' ? y : 0;
this.z = typeof z === 'number' ? z : 0;
}
if (x && typeof x !== 'number') {
// could be another vector
this.x = typeof x.x === 'number' ? x.x : 0;
this.y = typeof x.y === 'number' ? x.y : 0;
this.z = typeof x.z === 'number' ? x.z : 0;
} else {
this.x = typeof x === 'number' ? x : 0;
this.y = typeof y === 'number' ? y : 0;
this.z = typeof z === 'number' ? z : 0;
}
};
Vector3d.prototype.reset = function () {
this.x = this.y = this.z = 0;
}
};
{
"name": "ngraph.physics.primitives",
"version": "0.0.5",
"version": "0.0.6",
"description": "Physics primitives for ngraph.* libraries",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -66,2 +66,11 @@ var test = require('tap').test,

t.end();
})
});
test('vector can use copy constructor', function(t) {
var a = new primitives.Vector3d(1, 2, 3);
var b = new primitives.Vector3d(a);
t.equal(b.x, a.x, 'Value copied');
t.equal(b.y, a.y, 'Value copied');
t.equal(b.z, a.z, 'Value copied');
t.end();
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc