Catalog npm
Back to packageRELEASE DETAILS

1.0.2

npm

2dv

Very useful small class to perform vector calculations. Very practical as basis for all kinds of simulations and games where objects move through a two-dimensional space.

javascripttypescriptvectorvector math
Published8 Jul 2020
Direct dependencies3
Transitive dependenciesNot calculated

README

Current package documentation

2dv — Vector calculation package written in TypeScript

build npm

Very useful small class to perform vector calculations. Very practical as basis for all kinds of simulations and games where objects move through a two-dimensional space.

Get started

npm i 2dv

Use in your JavaScript/Typescript project

import { Vector } from '2dv';
// OR
const { Vector } = require('2dv');

const myVector = new Vector(10, 20);

myVector.add(100);
…

const newVector = Vector.add(myVector, 10);
…

Overview

Detailed documentation: https://wetterben.github.io/2dv/

Properties

  • x
  • y

Accessors

  • angle
  • length
  • magnitude
  • max
  • min

Methods

Instance

  • add
  • angleTo
  • clone
  • crossProduct
  • divide
  • dotProduct
  • equals
  • inverse
  • multiply
  • normalize
  • set
  • sub
  • toArray

Static

  • add
  • angleBetween
  • closestPointBetween
  • crossProduct
  • distance
  • divide
  • dotProduct
  • equals
  • fromArray
  • inverse
  • isOnLine
  • multiply
  • normalize
  • pointBetween
  • sub

Documentation

You can find a detailed documentation of all methods here: https://wetterben.github.io/2dv/

Roadmap

  • Automated tests
  • Visual Demo
  • More methods

Contribute

Feel free to add missing functions or fix things. Just do a PR.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 3

Native requirements
3 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
@types/node
Environment
{
  "local_name": "@types/node",
  "alias": false,
  "peer_metadata": null
}
^14.0.13development
typedoc
Environment
{
  "local_name": "typedoc",
  "alias": false,
  "peer_metadata": null
}
^0.17.8development
typescript
Environment
{
  "local_name": "typescript",
  "alias": false,
  "peer_metadata": null
}
^3.8.3development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "integrity": "sha512-fopvjWMpIFsaGJm9AeFgC0lMJH5HjCSMNnCHiP1aD/T7wua9oX+7IgeBG1YBXrBHj68b3Rr7UWm6e10ljZW2HA==",
  "shasum": "98ca665ea2196c54efd256f67a545dcece530458",
  "tarball": "https://registry.npmjs.org/2dv/-/2dv-1.0.2.tgz",
  "fileCount": 4,
  "unpackedSize": 14275,
  "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfBcSpCRA9TVsSAnZWagAA9CIP/2QKOfPuRrYJ3aNEDYTF\nsznmRVBFp1eCWCE8++/1Qg5kaiu/jvvgbgMqnlJ1jFL57ondFOkzIdeUaUOQ\nyHoda6WVmz7YY1SSPlVCR8HU9aNwVtfdlwga68kyQXfaOU2k7QvHdY39FfoQ\nhOIyzDED5LaO6STCFZNMhbD5GwMyi9u+o46c5HE5thRe4vTvnZK6JzFMp2SB\nSKYUa/KNF5y/NBonLKVTQG+6g4lE2uRSkD6BwUCPgYkBZLZn1Ij60YHto46Q\nraijjPxQ6reqkHpyLozXe4JqPXWePhczzoWRZCJeESGJsLkL2r5dVwn7W/Oq\nSiuRBOyCo3LZNwb/8JhBLBg45qOl8ZjyHCGxgmAWSU2nNhydVwzra/gR1jsG\nH1dHlLgFh3sZElTkwTGZD7VF+gPffQ2x05j00S1wM7/h3EvbXtCe9AAYKkAg\nC2bfouKdX1WEQ4qd0QKrv4ctYz9g9Gv5Ld5u5ZPLPOMwIkQzyLSssoWXcEka\nUVJbur3V8yTkfoA1UpFBIMeFh+LaLco9N+R2PUD+h5m7c+6DmUMlw3T7LnTc\ndDkiqpBSBDzv5J98VNcL1gkcolghin0T+E51XAw/TMghztLS0u9SNRepTkp7\nZlmDfxBZMdJdQzEGqBSpU1NvVNeXjqPG+pub7XWa9Uj8V0etskRgzSJchrKJ\nIs64\r\n=iaC7\r\n-----END PGP SIGNATURE-----\r\n",
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEUCIAsXYs1nBGudPTo0y/tuGwhEcU6cXj7rwltMJYWK6u9GAiEAlfEWbd5ATG1RW5BavagIA1o8/RRI6RWzNq4P3fPD9x4="
    }
  ]
}

Repository

MOVED
wetterben/vector2d

Shared repository data · GitHub

Repository moved · manual review pending

HTTP 301 · detected 20 Oct 2026

Reported destination
License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 19:12 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:b526a0fb6b7f618d45786ccaa46690dec57654425db65e5997a301c475511d6d

Other collected versions

1.0.38 Jul1.0.18 JulView all collected versions →