SkillAgentSearch skills...

Vectory

High performant, DevTools friendly, Crankshaft tolerant 2d vectors

Install / Use

/learn @broadsw0rd/Vectory
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

<h1 align="center">Vectory</h1> <h4 align="center">High performant, DevTools friendly, Crankshaft tolerant 2d vectors</h4> <p align="center"> <a href="https://www.npmjs.com/package/vectory" target="_blank"> <img src="https://img.shields.io/npm/v/vectory.svg" alt="NPM version" target="_blank"></img> </a> <a href="https://travis-ci.org/broadsw0rd/vectory" target="_blank"> <img src="https://travis-ci.org/broadsw0rd/vectory.svg?branch=master" alt="Build Status" target="_blank"></img> </a> <a href='https://coveralls.io/github/broadsw0rd/vectory?branch=master' target="_blank"> <img src='https://coveralls.io/repos/broadsw0rd/vectory/badge.svg?branch=master&service=github' alt='Coverage Status' /> </a> <a href="https://www.bithound.io/github/broadsw0rd/vectory"> <img src="https://www.bithound.io/github/broadsw0rd/vectory/badges/score.svg" alt="bitHound Overall Score"> </a> <a href="https://github.com/feross/standard" target="_blank"> <img src="https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat" alt="js-standard-style"></img> </a> </p>

Yet another 2d vector implementation for basic motion

this.velocity.iadd(this.acceleration)
this.position.iadd(this.velocity)
this.acceleration.zero()

with rare methods such as lerp

var prev = new Vector(1, 2)
var next = new Vector(3, 4)
prev.lerp(next, 0.5) // Vector(2, 3)

and swizzling

var vector = new Vector(1 ,2)
vector.yx // Vector(2, 1)

with some ES6 support

var vector = new Vector(0, 0)
var vec3 = [...vector, 0] // [0, 0, 0]

and FP ability

// create vectors from raw data and scale them twice
var data = [[1, 2], [3, 4]/*,  ... */]
var vectors = data.map(Vector.from).map(Vector.mul.bind(null, 2))

Table of Contents

Features

Install

npm install --save vectory
import Vector from 'vectory'
var position = new Vector(0, 0)

or

<script src="https://rawgit.com/broadsw0rd/vectory/master/dist/vectory.min.js"></script>
var position = new Vector(0, 0)

Usage

Follow this link to read more about vectors' usage in the Daniel Shiffman's article

Support

  • Latest Chrome, FF, Safari
  • IE 9+
  • Node 4+

API

Creation

Addition

Substraction

Multiplication

Division

Linear interpolation

Normalization

Magnitude

Dot product

Distance

Angle computing

Rotation

Resetting

Copy

Convertion

Equality

Swizzling

Related Skills

View on GitHub
GitHub Stars7
CategoryDevelopment
Updated12mo ago
Forks0

Languages

JavaScript

Security Score

82/100

Audited on Apr 4, 2025

No findings