2.3.36 • Published 2 days ago

@thi.ng/matrices v2.3.36

Weekly downloads
339
License
Apache-2.0
Repository
github
Last release
2 days ago

matrices

npm version npm downloads Twitter Follow

This project is part of the @thi.ng/umbrella monorepo.

About

Matrix & quaternion operations for 2D/3D geometry processing.

This package provides 160+ matrix & quaternion operations for 2D/3D geometry processing and acts as companion package for @thi.ng/vectors. Like with the vectors package, most functions are defined as multi-method dispatching to optimized implementations based on matrix size (which themselves are exposed for direct use too).

Any ArrayLike type can be used as matrix containers (e.g. JS arrays, typed arrays, custom impls) and hence many other functions provided by the vectors package can also be used directly with matrices (where sensible).

Status

STABLE - used in production

Search or submit any issues for this package

Related packages

  • @thi.ng/color - Array-based color types, CSS parsing, conversions, transformations, declarative theme generation, gradients, presets
  • @thi.ng/geom - Functional, polymorphic API for 2D geometry types & SVG generation
  • @thi.ng/vector-pools - Data structures for managing & working with strided, memory mapped vectors
  • @thi.ng/vectors - Optimized 2d/3d/4d and arbitrary length vector operations

Installation

yarn add @thi.ng/matrices

ES module import:

<script type="module" src="https://cdn.skypack.dev/@thi.ng/matrices"></script>

Skypack documentation

For Node.js REPL:

# with flag only for < v16
node --experimental-repl-await

> const matrices = await import("@thi.ng/matrices");

Package sizes (gzipped, pre-treeshake): ESM: 4.92 KB

Dependencies

Usage examples

Several demos in this repo's /examples directory are using this package.

A selection:

ScreenshotDescriptionLive demoSource
Various hdom-canvas shape drawing examples & SVG conversion / exportDemoSource
2D scenegraph & shape pickingDemoSource
2D scenegraph & image map based geometry manipulationDemoSource
Minimal shader graph developed during livestream #2DemoSource
Entity Component System w/ 100k 3D particlesDemoSource
3D wireframe textmode demoDemoSource
WebGL multi-colored cube meshDemoSource
WebGL cube maps with async texture loadingDemoSource
WebGL instancing, animated gridDemoSource
WebGL MSDF text rendering & particle systemDemoSource

API

Generated API docs

Constants

  • IDENT22 / IDENT23 / IDENT33 / IDENT44

Matrix creation

  • rotation22 / rotation23
  • rotationAroundAxis33 / rotationAroundAxis44
  • rotationX33 / rotationX44
  • rotationY33 / rotationY44
  • rotationZ33 / rotationZ44
  • scale22 / scale23 / scale33 / scale44
  • scaleWithCenter23 / scaleWithCenter44
  • shearX22 / shearY22
  • shearX23 / shearY23
  • shearXY33 / shearXZ33 / shearYX33 / shearYZ33 / shearZX33 / shearZY33
  • shearXY44 / shearXZ44 / shearYX44 / shearYZ44 / shearZX44 / shearZY44
  • skewX22 / skewY22
  • skewX23 / skewY23
  • skewXY33 / skewXZ33 / skewYX33 / skewYZ33 / skewZX33 / skewZY33
  • skewXY44 / skewXZ44 / skewYX44 / skewYZ44 / skewZX44 / skewZY44
  • translation23 / translation44
  • transform23 / transform44

WebGL related

  • frustum / frustumBounds
  • lookAt
  • ortho
  • perspective
  • viewport

Matrix conversion

  • mat22to23
  • mat23to22 / mat23to44
  • mat33to44 / mat44to33
  • normal44

Setters

  • set / set22 / set23 / set33 / set44
  • identity / identity22 / identity23 / identity33 / identity44

Row & column accessors

  • column / column22 / column23 / column33 / column44
  • row / row22 / row23 / row33 / row44

Componentwise matrix - matrix

  • add / add22 / add23 / add33 / add44
  • div / div22 / div23 / div33 / div44
  • mul / mul22 / mul23 / mul33 / mul44
  • sub / sub22 / sub23 / sub33 / sub44

Componentwise matrix - scalar

  • addN / addN22 / addN23 / addN33 / addN44
  • divN / divN22 / divN23 / divN33 / divN44
  • mulN / mulN22 / mulN23 / mulN33 / mulN44
  • subN / subN22 / subN23 / subN33 / subN44

Matrix multiplication

  • mulM / mulM22 / mulM23 / mulM33 / mulM44
  • concat

Matrix - vector multiplication

  • mulV / mulV22 / mulV23 / mulV33 / mulV344 / mulV44
  • project
  • unproject

Determinant & inversion

  • det22 / det23 / det33 / det44
  • det44FromCoeffs / detCoeffs44
  • diag / diag22 / diag23 / diag33 / diag44
  • invert / invert22 / invert23 / invert33 / invert44
  • trace

Matrix transposition

  • transpose22 / transpose33 / transpose44

Quaternion

  • alignmentQuat
  • conjugateQ
  • invertQ
  • mixQ
  • mulQ
  • mulVQ
  • quatFromAxisAngle
  • quatFromEuler
  • quatToAxisAngle
  • quatToMat33
  • quatToMat44

Authors

Karsten Schmidt

If this project contributes to an academic publication, please cite it as:

@misc{thing-matrices,
  title = "@thi.ng/matrices",
  author = "Karsten Schmidt",
  note = "https://thi.ng/matrices",
  year = 2018
}

License

© 2018 - 2021 Karsten Schmidt // Apache Software License 2.0

2.3.36

2 days ago

2.3.35

5 days ago

2.3.34

7 days ago

2.3.33

16 days ago

2.3.32

19 days ago

2.3.31

29 days ago

2.3.30

1 month ago

2.3.29

1 month ago

2.3.28

1 month ago

2.3.27

1 month ago

2.3.26

1 month ago

2.3.25

1 month ago

2.3.24

2 months ago

2.3.23

2 months ago

2.3.22

2 months ago

2.3.21

2 months ago

2.3.20

2 months ago

2.3.19

2 months ago

2.3.17

2 months ago

2.3.16

2 months ago

2.3.18

2 months ago

2.3.15

2 months ago

2.3.14

2 months ago

2.3.13

2 months ago

2.3.12

3 months ago

2.3.11

3 months ago

2.3.8

3 months ago

2.3.7

3 months ago

2.3.9

3 months ago

2.3.10

3 months ago

2.3.6

3 months ago

2.3.5

3 months ago

2.3.4

4 months ago

2.3.3

4 months ago

2.3.0

4 months ago

2.3.2

4 months ago

2.3.1

4 months ago

2.2.15

4 months ago

2.2.13

5 months ago

2.2.14

5 months ago

2.2.12

5 months ago

2.2.1

6 months ago

2.2.0

6 months ago

2.2.3

6 months ago

2.2.2

6 months ago

2.2.5

6 months ago

2.2.4

6 months ago

2.2.7

6 months ago

2.2.6

6 months ago

2.2.9

6 months ago

2.2.8

6 months ago

2.2.11

5 months ago

2.2.10

5 months ago

2.1.58

10 months ago

2.1.59

9 months ago

2.1.69

8 months ago

2.1.67

8 months ago

2.1.68

8 months ago

2.1.65

8 months ago

2.1.66

8 months ago

2.1.63

9 months ago

2.1.64

9 months ago

2.1.61

9 months ago

2.1.62

9 months ago

2.1.60

9 months ago

2.1.76

7 months ago

2.1.77

6 months ago

2.1.74

7 months ago

2.1.75

7 months ago

2.1.72

7 months ago

2.1.73

7 months ago

2.1.70

8 months ago

2.1.71

8 months ago

2.1.56

11 months ago

2.1.57

11 months ago

2.1.55

12 months ago

2.1.54

1 year ago

2.1.53

1 year ago

2.1.49

1 year ago

2.1.47

1 year ago

2.1.48

1 year ago

2.1.52

1 year ago

2.1.50

1 year ago

2.1.51

1 year ago

2.1.45

1 year ago

2.1.46

1 year ago

2.1.44

1 year ago

2.1.43

1 year ago

2.1.41

1 year ago

2.1.42

1 year ago

2.1.38

1 year ago

2.1.39

1 year ago

2.1.36

1 year ago

2.1.37

1 year ago

2.1.40

1 year ago

2.1.27

2 years ago

2.1.28

2 years ago

2.1.26

2 years ago

2.1.29

2 years ago

2.1.34

1 year ago

2.1.35

1 year ago

2.1.32

1 year ago

2.1.33

1 year ago

2.1.30

1 year ago

2.1.31

1 year ago

2.1.25

2 years ago

2.1.24

2 years ago

2.1.23

2 years ago

2.1.16

2 years ago

2.1.17

2 years ago

2.1.15

2 years ago

2.1.18

2 years ago

2.1.19

2 years ago

2.1.21

2 years ago

2.1.22

2 years ago

2.1.20

2 years ago

2.1.14

2 years ago

2.1.12

2 years ago

2.1.13

2 years ago

2.1.10

2 years ago

2.1.11

2 years ago

2.1.9

2 years ago

2.1.8

2 years ago

2.0.9

2 years ago

2.1.2

2 years ago

2.1.1

2 years ago

2.1.4

2 years ago

2.1.3

2 years ago

2.1.6

2 years ago

2.1.5

2 years ago

2.1.7

2 years ago

2.1.0

2 years ago

2.0.7

2 years ago

2.0.8

2 years ago

2.0.4

3 years ago

2.0.6

3 years ago

2.0.3

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

0.6.64

3 years ago

1.0.1

3 years ago

0.6.63

3 years ago

0.6.62

3 years ago

0.6.61

3 years ago

0.6.60

3 years ago

0.6.59

3 years ago

0.6.58

3 years ago

0.6.57

3 years ago

0.6.56

3 years ago

0.6.55

3 years ago

0.6.54

3 years ago

0.6.53

3 years ago

0.6.52

3 years ago

0.6.51

3 years ago

0.6.50

3 years ago

0.6.49

3 years ago

0.6.45

3 years ago

0.6.44

3 years ago

0.6.43

3 years ago

0.6.42

3 years ago

0.6.41

3 years ago

0.6.40

3 years ago

0.6.39

3 years ago

0.6.38

3 years ago

0.6.37

3 years ago

0.6.36

3 years ago

0.6.35

3 years ago

0.6.34

4 years ago

0.6.33

4 years ago

0.6.32

4 years ago

0.6.31

4 years ago

0.6.30

4 years ago

0.6.29

4 years ago

0.6.28

4 years ago

0.6.27

4 years ago

0.6.26

4 years ago

0.6.25

4 years ago

0.6.23

4 years ago

0.6.24

4 years ago

0.6.22

4 years ago

0.6.21

4 years ago

0.6.20

4 years ago

0.6.19

4 years ago

0.6.18

4 years ago

0.6.17

4 years ago

0.6.16

4 years ago

0.6.15

4 years ago

0.6.14

4 years ago

0.6.13

4 years ago

0.6.12

4 years ago

0.6.10

4 years ago

0.6.11

4 years ago

0.6.9

4 years ago

0.6.8

4 years ago

0.6.7

4 years ago

0.6.6

4 years ago

0.6.5

4 years ago

0.6.4

4 years ago

0.6.3

4 years ago

0.6.2

4 years ago

0.5.12

4 years ago

0.5.11

4 years ago

0.5.10

4 years ago

0.5.9

4 years ago

0.5.8

5 years ago

0.5.7

5 years ago

0.5.6

5 years ago

0.5.5

5 years ago

0.5.4

5 years ago

0.5.3

5 years ago

0.5.2

5 years ago

0.5.1

5 years ago

0.5.0

5 years ago

0.4.0

5 years ago

0.3.4

5 years ago

0.3.3

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.14

5 years ago

0.1.13

5 years ago

0.1.12

5 years ago

0.1.11

5 years ago

0.1.10

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago