reergymerej-vectors

1.1.0 • Public • Published

vectors

2d vectors for the whole family

v1.1.0 Build Status

Installation

yarn add reergymerej-vectors

Usage

import Vector from 'reergymerej-vectors';
const vector = new Vector(3, 4);
console.log(vector.magnitude); // 5

API

Properties

The following examples use

const vector = new Vector(3, 4);

x

vector.x;  // 3

y

vector.y;  // 4

magnitude

vector.magnitude; // 5

length

vector.length;  // 5

unit

vector.unit;  // Vector { x: 0.6, y: 0.8 }

Methods/Functions

The following examples use

const vectorA = new Vector(3, 4);
const vectorB = new Vector(5, 6);

add

add(vectorA, vectorB);  // Vector { x: 8, y: 10 }
vectorA.add(vectorB);  // Vector { x: 8, y: 10 }

subtract

subtract(vectorA, vectorB);  // Vector { x: -2, y: -2 }
vectorA.subtract(vectorB);  // Vector { x: -2, y: -2 }

multiply

multiply(vectorA, vectorB);  // Vector { x: 15, y: 24 }
vectorA.multiply(vectorB);  // Vector { x: 15, y: 24 }

dotProduct

dotProduct(vectorA, vectorB);  // 39
vectorA.dotProduct(vectorB);  // 39

kickstarted by npm-boom

Readme

Keywords

Package Sidebar

Install

npm i reergymerej-vectors

Weekly Downloads

0

Version

1.1.0

License

ISC

Unpacked Size

77.6 kB

Total Files

17

Last publish

Collaborators

  • reergymerej