@julian-wasmeier-titanom/vectors
v1.1.4
Published
A simple library for creating vectors and performing operations on them.
Downloads
1
Readme
Vectors
Usage
pnpm add @julian-wasmeier-titanom/vectors
import Vector from '@julian-wasmeier-titanom/vectors'
or
const Vector = require('@julian-wasmeier-titanom/vectors')
new Vector(x, [y], [z])
Creates a new Vector
Vector.add(vector)
Takes a Vector and adds it to the Vector it has been called on. Returns a new Vector with the sum.
Vector.subtract(vector)
Takes a Vector and subtracts it from the Vector it has been called on. Returns a new Vector with the difference.
Vector.dot(vector)
Takes a Vector and returns the dot product of the passed Vector and the Vector it has been called on.
Vector.magnitude
The magnitude of the vector.
Vector.scalarMul(scalar)
Takes a number and returns a new Vector whose values have been multiplied with said scalar.
Vector.cross(vector)
Returns the cross product of the Vector it has been called on and the passed Vector.