0.1.0 • Published 6 years ago
vector_math.js v0.1.0
vector_math.js
A Node.js vector math library for 3D and 2D applications
Javascript version of vector_math.dart with SIMD implementation from glMatrix
Features
- 2D, 3D, and 4D vector and matrix types.
- Quaternion type for animating rotations.
- Collision detection: AABB, rays, spheres, ...
- Fully documented.
Missing features
- Utilities like color and common rendering related operations
- Flexible getters and setters, for example, position.xwz = color.grb;.
Npm install
"dependencies": {
"vector_math.js": "https://github.com/Tezirg/vector_math.js"
}
Example
This sample code shows how to manipulate matrices :
var m1 = Matrix4.identity();
var m2 = new Matrix4(0.0, 1.0, 2.0, 3.0,
0,0, 1.0, 2.0, 3.0
0.0, 1.0, 2.0, 3.0);
var scale_mul = m1.scaled(0.5).mult(m2);
This sample code shows how to manipulate vectors :
var v1 = Vector3.zero();
var v2 = new Vector3(1.0, 0.0, 2.0);
console.log("Dot product = ") + v1.dot(v2));
console.log("v1 + v2 = " + v1.added(v2).toString());
0.1.0
6 years ago