@pauliclark/color-selector

0.0.1 • Public • Published

bertie.vector

The vector object as used in the bertie 3D engine. For a reference to this class, check the autogenerated documentation

Install

npm install bertie.3d

Usage

var v1 = new bertie.vector(100,100,100);

var v2 = new bertie.vector(-100,-100,100);

console.log(v1.dotProduct(v2)); // -0.3333333333333333

v1.flip();
console.log(JSON.stringify(v1.directions)); // [-100,-100,-100]
v1.flip();
console.log(JSON.stringify(v1.directions)); // [100,100,100]

console.log(JSON.stringify(v1.unitVector())); // [-0.5773502691896257,-0.5773502691896257,-0.5773502691896257]

console.log(JSON.stringify(v1.angleBetween(v2))); // 1.0471975511965979

console.log(v1.getLength()); // 173.20508075688772

v1.add(v2);
console.log(JSON.stringify(v1.directions)); // [0,0,200]

v2.rotateX(Math.PI/2);
console.log(JSON.stringify(v2.directions)); // [-100,-100,-100]

Package Sidebar

Install

npm i @pauliclark/color-selector

Weekly Downloads

1

Version

0.0.1

License

MIT

Last publish

Collaborators

  • pauliclark