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.3 to 0.0.4

18

index.js
module.exports = {
Body: Body,
Vector2d: Vector2d
// that's it for now
Vector2d: Vector2d,
Body3d: Body3d,
Vector3d: Vector3d
};

@@ -18,1 +19,14 @@

}
function Body3d(x, y, z) {
this.pos = new Vector3d(x, y, z);
this.force = new Vector3d();
this.velocity = new Vector3d();
this.mass = 1;
}
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;
}

2

package.json
{
"name": "ngraph.physics.primitives",
"version": "0.0.3",
"version": "0.0.4",
"description": "Physics primitives for ngraph.* libraries",

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

ngraph.physics.primitives
=========================
Module with basic 2d physics primitives for ngraph. It defines interface for physical bodies, used in [n-body](https://github.com/anvaka/ngraph.quadtreebh) simulation.
Module with basic 2d and 3d physics primitives for ngraph. It defines interface for physical bodies, used in [n-body](https://github.com/anvaka/ngraph.quadtreebh) simulation.

@@ -20,2 +20,5 @@ [![build status](https://secure.travis-ci.org/anvaka/ngraph.physics.primitives.png)](http://travis-ci.org/anvaka/ngraph.physics.primitives)

console.log(direction.x, direction.y); // prints 0, 0
var spaceDirection = new physics.Vector3d(); // create a 3d vector
console.log(spaceDirection.x, spaceDirection.y, spaceDirection.z); // prints 0, 0, 0
```

@@ -22,0 +25,0 @@

@@ -27,1 +27,28 @@ var test = require('tap').test,

});
test('Body3d has properties force, pos and mass', function(t) {
var body = new primitives.Body3d();
t.ok(body.force, 'Force attribute is missing on body');
t.ok(body.pos, 'Pos attribute is missing on body');
t.ok(body.velocity, 'Velocity attribute is missing on body');
t.ok(typeof body.mass === 'number' && body.mass !== 0, 'Body should have a mass');
t.end();
});
test('Vector3d has x and y and z', function(t) {
var vector = new primitives.Vector3d();
t.ok(typeof vector.x === 'number', 'Vector has x coordinates');
t.ok(typeof vector.y === 'number', 'Vector has y coordinates');
t.ok(typeof vector.z === 'number', 'Vector has z coordinates');
var initialized = new primitives.Vector3d(1, 2, 3);
t.equal(initialized.x, 1, 'Vector initialized imporperly');
t.equal(initialized.y, 2, 'Vector initialized imporperly');
t.equal(initialized.z, 3, 'Vector initialized imporperly');
var badInput = new primitives.Vector3d('hello world');
t.equal(badInput.x, 0, 'Vector should be resilient to bed input');
t.equal(badInput.y, 0, 'Vector should be resilient to bed input');
t.equal(badInput.z, 0, 'Vector should be resilient to bed input');
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