# 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.

Latest version **1.0.3** (published 2020-07-08) · ISC license · 0 weekly downloads

## Install

```sh
npm install 2dv
pnpm add 2dv
yarn add 2dv
bun add 2dv
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2020-07-08 |
| First published | 2020-07-08 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 13.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Ben Weber |
| Maintainers | wetterben |
| Keywords | vector, vector math, javascript, typescript |

## Links

- npm: https://www.npmjs.com/package/2dv
- Repository: https://github.com/wetterben/vector2d
- Homepage: https://github.com/wetterben/vector2d#readme
- Issues: https://github.com/wetterben/vector2d/issues
- npm.io page: https://npm.io/package/2dv

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2020-07-08
- 1.0.2 — 2020-07-08
- 1.0.1 — 2020-07-08

## README

# 2dv — Vector calculation package written in TypeScript

![build](https://github.com/wetterben/2dv/workflows/build/badge.svg)
![npm](https://img.shields.io/npm/v/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.

## Get started

```
npm i 2dv
```

Use in your JavaScript/Typescript project

```js
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/](https://wetterben.github.io/2dv/classes/_index_.vector.html)

### 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/](https://wetterben.github.io/2dv/classes/_index_.vector.html)

## Roadmap

- [ ] Automated tests
- [ ] Visual Demo
- [ ] More methods

## Contribute

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

---
_Source: https://npm.io/package/2dv · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
