Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
import { v2, v3, v4, q4, m4 } from "./gmatrix.js" // or "./gmatrix.min.js"
// Create new objects
let vec = new v4(), mat = new m4();
// Chain operations
console.log( mat.multVec4( vec ).equals( new v4() ) ); // true
Create new or mutate old
let c = v4.sub( a, b ); // returns a new vector from the v4 class object
c.sub( d ); // actually mutates c
Other notable functions
let m = new m4( 3 ); // passing a scalar to the m4 constructor *scales* the identity matrix by that factor
let p = new v2().copy( anotherVector ); // copy values from other vectors
let g = p.clone(); // or clone them
let start = new v4().distanceTo( end ); // lots of useful operations, check out the source
About
Fast & simple vector and matrix math for JavaScript in 15 kb
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.
We use optional third-party analytics cookies to understand how you use GitHub.com so we can build better products.
Learn more.
We use optional third-party analytics cookies to understand how you use GitHub.com so we can build better products.
You can always update your selection by clicking Cookie Preferences at the bottom of the page.
For more information, see our Privacy Statement.
Essential cookies
We use essential cookies to perform essential website functions, e.g. they're used to log you in.
Learn more
Always active
Analytics cookies
We use analytics cookies to understand how you use our websites so we can make them better, e.g. they're used to gather information about the pages you visit and how many clicks you need to accomplish a task.
Learn more