Skip to content
/ vector Public

This library provides 3D Vector in js including arithmetic operator overloading (+ - * / % **).

License

Notifications You must be signed in to change notification settings

basics/vector

Repository files navigation

GitHub package version license

OSX/Linux Build Status Windows Build status NSP Status Dependencies Status DevDependencies Status

start with why JavaScript Style Guide: Good Parts Greenkeeper badge

basics - vector

this libary provides 3D Vector in js including support for + - * / operator handling

create vector by numbers

const pos = new Vector(5, 6, 7);
const dir = new Vector(1, 0, 0);

console.log('pos:', pos, ' dir:', dir);

pos: { x: 5, y: 6, z: 7 } dir: { x: 1, y: 0, z: 0 }

or create vector by calculating other vectors and number

const offset = new Vector(() => dir * 30 + pos);

console.log('offset:', offset);

offset: { x: 35, y: 6, z: 7 }

compare length

let way = offset;
if (way > 1) {
  way = way.normalize();
}
console.log('way:', way);

way: { x: 0.96, y: 0.16, z: 0.19 }

About

This library provides 3D Vector in js including arithmetic operator overloading (+ - * / % **).

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 9