# @joshduck/vector2d

> A simple, zero-dependency, mutable 2d vector class.

Latest version **1.0.1** (published 2017-12-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install @joshduck/vector2d
pnpm add @joshduck/vector2d
yarn add @joshduck/vector2d
bun add @joshduck/vector2d
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2017-12-16 |
| First published | 2017-12-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | joshduck |

## Links

- npm: https://www.npmjs.com/package/@joshduck/vector2d
- Repository: https://github.com/joshduck/flocking
- Homepage: https://github.com/joshduck/flocking/tree/master/packages/vector2d
- Issues: https://github.com/joshduck/flocking/issues
- npm.io page: https://npm.io/package/@joshduck/vector2d

## Recent versions

- 1.0.1 (latest) — 2017-12-16
- 1.0.0 — 2017-12-14

## README

# Vector2d

A simple, zero-dependency, mutable 2d vector class.

```javascript
const v = new Vector(10, 10);
v.subtract(new Vector(1, 1)); // Vector(9, 9)
v.normalize();
v.length(); // 1
v.multiply(-1);
```

## Properties

* `x`
* `y`

## Methods

* `clone()`
  Create a new instance with same coordinates.
* `reset()`
  Reset coordinates to 0, 0.
* `subtract(other)`
  Subtract vector.
* `add(other)`
  Add vector.
* `multiply(scale)`
  Multiply by a constant length.
* `normalize(scale = 1)`
  Normalize to length provided.
* `length()`
  Length as numeric value.

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