vectors
2d vectors for the whole family
Installation
yarn add reergymerej-vectors
Usage
;const vector = 3 4;console; // 5
API
Properties
The following examples use
const vector = 3 4;
x
vectorx; // 3
y
vectory; // 4
magnitude
vectormagnitude; // 5
length
vectorlength; // 5
unit
vectorunit; // Vector { x: 0.6, y: 0.8 }
Methods/Functions
The following examples use
const vectorA = 3 4;const vectorB = 5 6;
add
; // Vector { x: 8, y: 10 }vectorA; // Vector { x: 8, y: 10 }
subtract
; // Vector { x: -2, y: -2 }vectorA; // Vector { x: -2, y: -2 }
multiply
; // Vector { x: 15, y: 24 }vectorA; // Vector { x: 15, y: 24 }
dotProduct
; // 39vectorA; // 39
kickstarted by npm-boom