vctr

0.3.0 • Public • Published

vctr

Minimal operations for multidimensional vectors

This module assumes that a vector is an array of numbers, allowing these functions to be used on vectors of all dimensions.

install

npm install vctr

usage

const { add, subtract, ... } = require('vctr')

add(a, b)

Returns the sum of the two provided vectors.

subtract(a, b)

Returns the difference between the two provided vectors.

multiply(a, b)

Returns the product of the two provided vectors. The second argument may be a scalar quantity (a Number) if desired.

divide(a, b)

Returns the quotient of the two provided vectors. The second argument may be a scalar quantity (a Number) if desired.

dot(a, b)

Determines the dot product of the two provided vectors.

compose(vector)

Converts vector from Cartesian coordinates to spherical coordinates { direction, magnitude }.

resolve(vector)

Converts vector from spherical coordinates to Cartesian coordinates.

direction(vector)

Calculates the direction in which vector is pointing, in radians.

magnitude(vector)

Calculates the distance covered by vector.

normalize(vector)

Converts vector to a unit vector.

distance(a, b)

Determines the distance (a scalar quantity) between the two provided vectors.

see also

license

MIT © Brandon Semilla

Package Sidebar

Install

npm i vctr

Weekly Downloads

0

Version

0.3.0

License

MIT

Last publish

Collaborators

  • semibran