Socket
Socket
Sign inDemoInstall

vec2d

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vec2d

2d vector math with good unit tests


Version published
Weekly downloads
2
decreased by-85.71%
Maintainers
1
Weekly downloads
 
Created
Source

vec2d

Node.js 2d vector library with robust unit tests.

Usage

var v = require('vec2d');

var v1 = v(1, 2);
console.log(v1); // prints "(1, 2)"

var v2 = v1.offset(1, 0);
console.log(v2); // prints "(2, 2)"

var v3 = v({x: -1, y: 2.2});
console.log(v3); // prints "(-1, 2.2)"

Or a faster, less convenient version:

var Vec2d = require('vec2d').Vec2d;

var v1 = new Vec2d(1, 2);
// etc...

More available functions are listed below in Test Coverage.

Test Coverage

  v()
    ✓ no args 
    ✓ x, y 
    ✓ array 
    ✓ object 
    ✓ string coords 
    ✓ deserialize 
    ✓ invalid deserialize 
    ✓ unit 

  Vec2d
    ✓ unit 
    ✓ offset 
    ✓ add 
    ✓ sub 
    ✓ plus 
    ✓ minus 
    ✓ neg 
    ✓ mult 
    ✓ times 
    ✓ div 
    ✓ divBy 
    ✓ scale 
    ✓ scaled 
    ✓ clone 
    ✓ apply 
    ✓ applied 
    ✓ equals 
    ✓ toString 
    ✓ length 
    ✓ lengthSqrd 
    ✓ angle 
    ✓ normalize 
    ✓ normalized 
    ✓ boundMin 
    ✓ boundMax 
    ✓ floor 
    ✓ floored 
    ✓ ceil 
    ✓ ceiled 
    - project
    ✓ dot 
    ✓ rotate 
    ✓ rotated 
    ✓ distance 
    ✓ distanceSqrd 
    ✓ reflect 
    ✓ reflectAboutLine 
    ✓ set 


  45 passing (14ms)
  1 pending

More functions welcome in the form of pull requests.

Keywords

FAQs

Package last updated on 30 Jul 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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