Skip to content

pauliclark/bertie.vector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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]

About

The vector class as used in bertie

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published