npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vector_functions

v1.0.2

Published

A set of functions to manipulate vectors in javascript ## Functions

Downloads

8

Readme

vector_functions.js

A set of functions to manipulate vectors in javascript

Functions

add(vector)

this function can take multiple vectors and add them

Kind: global function

| Param | Type | Description | | --- | --- | --- | | vector | Array | This is an array of components of a vector |

Example

add([5, 15], [15, 5])

Example

add([5, 5], [10, 10], [5, 5])

sub(Vector)

This function subtracts all the given vectors

Kind: global function

| Param | Type | Description | | --- | --- | --- | | Vector | Array | takes multiple vectors and subtracts them |

mult(vector, scalar)

This function multiplies the vector given by the scalar give

Kind: global function

| Param | Type | Description | | --- | --- | --- | | vector | Array | This is an array of components of a vector | | scalar | Number | This is a number |

inverse(vector)

This function returns the inverse of the vector

Kind: global function

| Param | Type | Description | | --- | --- | --- | | vector | array | This is an array of components of a vector |

normalize(vector)

This function normalise the vector

Kind: global function

| Param | Type | Description | | --- | --- | --- | | vector | array | This is an array of components of a vector |

distance(vector1, vector2)

Returns the magnitude of the distance between the two vectors given

Kind: global function

| Param | Type | Description | | --- | --- | --- | | vector1 | array | This is an array of components of a vector | | vector2 | array | This is an array of components of a vector |

copy(vector)

Returns a copy of the given vector

Kind: global function

| Param | Type | Description | | --- | --- | --- | | vector | array | This is an array of components of a vector |

limit(vector, scalar)

Limits the magnitud of the given vector

Kind: global function

| Param | Type | Description | | --- | --- | --- | | vector | array | This is an array of components of a vector | | scalar | array | This is the maximun length of the vector |

dot(vector1, vector2)

This function returns the dot product of the two vectors given

Kind: global function

| Param | Type | Description | | --- | --- | --- | | vector1 | array | This is an array of components of a vector | | vector2 | array | This is an array of components of a vector |

mag(vector)

This functions returns the margnitud of the given vector

Kind: global function

| Param | Type | Description | | --- | --- | --- | | vector | array | This is an array of components of a vector |

moveTowards(start, end, speed, stop)

smaller than the stop parameter.ve if the magnitude of the distance is

Kind: global function

| Param | Type | Default | Description | | --- | --- | --- | --- | | start | array | | This is an array of components of a vector | | end | array | | This is an array of components of a vector | | speed | number | 1 | This is the speed in wich the first vector will move towards the second | | stop | number | 1 | This is the distance in wich the start vector will not move to the end vector |

angleBetween(vector1, vector2)

Returns the angle between 2 vectors

Kind: global function

| Param | Type | Description | | --- | --- | --- | | vector1 | array | This is an array of components of a vector | | vector2 | array | This is an array of components of a vector |

setMag(vector, scalar)

Sets the magnitud of the vector to the length of the scalar given

Kind: global function

| Param | Type | Description | | --- | --- | --- | | vector | array | This is an array of components of a vector | | scalar | number | This will be the length of the vector |

toDegree(radian)

Converts a number from radian to degree

Kind: global function

| Param | Type | Description | | --- | --- | --- | | radian | number | This number represents the radian that you want to convert |

toRadian(degree)

Converts a number from degree to radian

Kind: global function

| Param | Type | Description | | --- | --- | --- | | degree | number | This number represents the degree that you want to convert |

cross3d(vector1, vector2)

Returns the cross product of 2 vectors with 3 components

Kind: global function

| Param | Type | Description | | --- | --- | --- | | vector1 | array | This is an array of components of a vector | | vector2 | array | This is an array of components of a vector |

cross2d(vector1, vector2)

Returns the cross product of 2 vectors with 2 components

Kind: global function

| Param | Type | Description | | --- | --- | --- | | vector1 | array | This is an array of components of a vector | | vector2 | array | This is an array of components of a vector |

angle(vector)

Returns the angle of the vector

Kind: global function

| Param | Type | Description | | --- | --- | --- | | vector | array | This is an array of components of a vector |

angleMagnitude(direction, magnitud)

Creates a vector from a magnitud and a direction

Kind: global function

| Param | Type | Description | | --- | --- | --- | | direction | number | This is the direction of the vector that will be created | | magnitud | number | This is the magnitud of the vector that will be created |

linearIntersect(vector, angle)

Sets the angle of the given vector to the given angle

Kind: global function

| Param | Type | Description | | --- | --- | --- | | vector | array | This is the vector that will be changed | | angle | number | This will be the angle of the given vector in radians |

addAngle(vector, angle, piv)

Adds the angle of the given vector to the given angle

Kind: global function

| Param | Type | Description | | --- | --- | --- | | vector | array | This is the vector that will be changed | | angle | number | This will be the angle that will be added to the given vector in radians | | piv | array | This is the center of rotation |

setAngle(vector, angle)

Sets the angle of the given vector to the given angle

Kind: global function

| Param | Type | Description | | --- | --- | --- | | vector | array | This is the vector that will be changed | | angle | number | This will be the angle of the given vector in radians |