{"id":13830930,"url":"https://github.com/EricLengyel/Terathon-Math-Library","last_synced_at":"2025-07-09T13:30:41.877Z","repository":{"id":37783999,"uuid":"319206208","full_name":"EricLengyel/Terathon-Math-Library","owner":"EricLengyel","description":"C++ math library for 2D/3D/4D vector, matrix, quaternion, and geometric algebra.","archived":false,"fork":false,"pushed_at":"2025-06-25T21:36:15.000Z","size":521,"stargazers_count":968,"open_issues_count":1,"forks_count":76,"subscribers_count":25,"default_branch":"main","last_synced_at":"2025-06-25T22:33:47.558Z","etag":null,"topics":["dual-quaternions","geometric-algebra","linear-algebra","quaternions"],"latest_commit_sha":null,"homepage":"https://projectivegeometricalgebra.org/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EricLengyel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-12-07T04:44:04.000Z","updated_at":"2025-06-25T21:36:19.000Z","dependencies_parsed_at":"2022-08-19T09:50:25.504Z","dependency_job_id":"89c65438-b49e-496f-b0b5-a5533204709b","html_url":"https://github.com/EricLengyel/Terathon-Math-Library","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/EricLengyel/Terathon-Math-Library","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EricLengyel%2FTerathon-Math-Library","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EricLengyel%2FTerathon-Math-Library/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EricLengyel%2FTerathon-Math-Library/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EricLengyel%2FTerathon-Math-Library/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EricLengyel","download_url":"https://codeload.github.com/EricLengyel/Terathon-Math-Library/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EricLengyel%2FTerathon-Math-Library/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264467895,"owners_count":23612997,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dual-quaternions","geometric-algebra","linear-algebra","quaternions"],"created_at":"2024-08-04T10:01:12.823Z","updated_at":"2025-07-09T13:30:41.872Z","avatar_url":"https://github.com/EricLengyel.png","language":"C++","funding_links":[],"categories":["C++"],"sub_categories":[],"readme":"# Terathon Math Library\n\nThis is a C++ math library containing classes for vectors, matrices, quaternions, and elements of projective geometric algebra. The specific classes are the following:\n\n* **Vector2D** – A 2D vector (*x*, *y*) that extends to four dimensions as (*x*, *y*, 0, 0).\n* **Vector3D** – A 3D vector (*x*, *y*, *z*) that extends to four dimensions as (*x*, *y*, *z*, 0).\n* **Vector4D** – A 4D vector (*x*, *y*, *z*, *w*).\n* **Point2D** – A 2D point (*x*, *y*) that extends to four dimensions as (*x*, *y*, 0, 1).\n* **Point3D** – A 3D point (*x*, *y*, *z*) that extends to four dimensions as (*x*, *y*, *z*, 1).\n* **Bivector3D** – A 3D bivector *x* **e**\u003csub\u003e23\u003c/sub\u003e + *y* **e**\u003csub\u003e31\u003c/sub\u003e + *z* **e**\u003csub\u003e12\u003c/sub\u003e.\n* **Matrix2D** – A 2×2 matrix.\n* **Matrix3D** – A 3×3 matrix.\n* **Matrix4D** – A 4×4 matrix.\n* **Transform2D** – A 3×3 matrix with fourth row always (0, 0, 1).\n* **Transform3D** – A 4×4 matrix with fourth row always (0, 0, 0, 1).\n* **Quaternion** – A conventional quaternion *x***i** + *y***j** + *z***k** + *w*.\n* **DualNum** – A dual number *s* + *tε*.\n\n2D rigid geometric algebra\n* **FlatPoint2D** – A 2D flat point *x* **e**\u003csub\u003e1\u003c/sub\u003e + *y* **e**\u003csub\u003e2\u003c/sub\u003e + *z* **e**\u003csub\u003e3\u003c/sub\u003e.\n* **Line2D** – A 2D line *x* **e**\u003csub\u003e23\u003c/sub\u003e + *y* **e**\u003csub\u003e31\u003c/sub\u003e + *z* **e**\u003csub\u003e12\u003c/sub\u003e.\n* **Motor2D** – A 2D motion operator *Q\u003csub\u003ex\u003c/sub\u003e* **e**\u003csub\u003e1\u003c/sub\u003e + *Q\u003csub\u003ey\u003c/sub\u003e* **e**\u003csub\u003e2\u003c/sub\u003e + *Q\u003csub\u003ez\u003c/sub\u003e* **e**\u003csub\u003e3\u003c/sub\u003e + *Q\u003csub\u003ew\u003c/sub\u003e* 𝟙.\n* **Flector2D** - A 2D reflection operator *F\u003csub\u003ex\u003c/sub\u003e* **e**\u003csub\u003e23\u003c/sub\u003e + *F\u003csub\u003ey\u003c/sub\u003e* **e**\u003csub\u003e31\u003c/sub\u003e + *F\u003csub\u003ez\u003c/sub\u003e* **e**\u003csub\u003e12\u003c/sub\u003e + *F\u003csub\u003ew\u003c/sub\u003e* **1**.\n\n3D rigid geometric algebra\n* **FlatPoint3D** – A 3D [flat point](https://rigidgeometricalgebra.org/wiki/index.php?title=Point) *x* **e**\u003csub\u003e1\u003c/sub\u003e + *y* **e**\u003csub\u003e2\u003c/sub\u003e + *z* **e**\u003csub\u003e3\u003c/sub\u003e + *w* **e**\u003csub\u003e4\u003c/sub\u003e.\n* **Line3D** – A 3D [line](https://rigidgeometricalgebra.org/wiki/index.php?title=Line) *l\u003csub\u003evx\u003c/sub\u003e* **e**\u003csub\u003e41\u003c/sub\u003e + *l\u003csub\u003evy\u003c/sub\u003e* **e**\u003csub\u003e42\u003c/sub\u003e + *l\u003csub\u003evz\u003c/sub\u003e* **e**\u003csub\u003e43\u003c/sub\u003e + *l\u003csub\u003emx\u003c/sub\u003e* **e**\u003csub\u003e23\u003c/sub\u003e + *l\u003csub\u003emy\u003c/sub\u003e* **e**\u003csub\u003e31\u003c/sub\u003e + *l\u003csub\u003emz\u003c/sub\u003e* **e**\u003csub\u003e12\u003c/sub\u003e.\n* **Plane3D** – A 3D [plane](https://rigidgeometricalgebra.org/wiki/index.php?title=Plane) *x* **e**\u003csub\u003e234\u003c/sub\u003e + *y* **e**\u003csub\u003e314\u003c/sub\u003e + *z* **e**\u003csub\u003e124\u003c/sub\u003e + *w* **e**\u003csub\u003e321\u003c/sub\u003e.\n* **Motor3D** – A 3D [motion operator](https://rigidgeometricalgebra.org/wiki/index.php?title=Motor) *Q\u003csub\u003evx\u003c/sub\u003e* **e**\u003csub\u003e41\u003c/sub\u003e + *Q\u003csub\u003evy\u003c/sub\u003e* **e**\u003csub\u003e42\u003c/sub\u003e + *Q\u003csub\u003evz\u003c/sub\u003e* **e**\u003csub\u003e43\u003c/sub\u003e + *Q\u003csub\u003evw\u003c/sub\u003e* 𝟙 + *Q\u003csub\u003emx\u003c/sub\u003e* **e**\u003csub\u003e23\u003c/sub\u003e + *Q\u003csub\u003emy\u003c/sub\u003e* **e**\u003csub\u003e31\u003c/sub\u003e + *Q\u003csub\u003emz\u003c/sub\u003e* **e**\u003csub\u003e12\u003c/sub\u003e + *Q\u003csub\u003emw\u003c/sub\u003e* **1**.\n* **Flector3D** - A 3D [reflection operator](https://rigidgeometricalgebra.org/wiki/index.php?title=Flector) *F\u003csub\u003epx\u003c/sub\u003e* **e**\u003csub\u003e1\u003c/sub\u003e + *F\u003csub\u003epy\u003c/sub\u003e* **e**\u003csub\u003e2\u003c/sub\u003e + *F\u003csub\u003epz\u003c/sub\u003e* **e**\u003csub\u003e3\u003c/sub\u003e + *F\u003csub\u003epw\u003c/sub\u003e* **e**\u003csub\u003e4\u003c/sub\u003e + *F\u003csub\u003egx\u003c/sub\u003e* **e**\u003csub\u003e423\u003c/sub\u003e + *F\u003csub\u003egy\u003c/sub\u003e* **e**\u003csub\u003e431\u003c/sub\u003e + *F\u003csub\u003egz\u003c/sub\u003e* **e**\u003csub\u003e412\u003c/sub\u003e + *F\u003csub\u003egw\u003c/sub\u003e* **e**\u003csub\u003e321\u003c/sub\u003e.\n\n2D conformal geometric algebra\n* **RoundPoint2D** – A 2D round point *x* **e**\u003csub\u003e1\u003c/sub\u003e + *y* **e**\u003csub\u003e2\u003c/sub\u003e + *z* **e**\u003csub\u003e3\u003c/sub\u003e + *w* **e**\u003csub\u003e4\u003c/sub\u003e.\n* **Dipole2D** – A 2D dipole *d\u003csub\u003egx\u003c/sub\u003e* **e**\u003csub\u003e23\u003c/sub\u003e + *d\u003csub\u003egy\u003c/sub\u003e* **e**\u003csub\u003e31\u003c/sub\u003e + *d\u003csub\u003egz\u003c/sub\u003e* **e**\u003csub\u003e12\u003c/sub\u003e + *d\u003csub\u003epx\u003c/sub\u003e* **e**\u003csub\u003e41\u003c/sub\u003e + *d\u003csub\u003epy\u003c/sub\u003e* **e**\u003csub\u003e42\u003c/sub\u003e + *d\u003csub\u003epz\u003c/sub\u003e* **e**\u003csub\u003e43\u003c/sub\u003e.\n* **Circle2D** – A 2D circle *w* **e**\u003csub\u003e321\u003c/sub\u003e + *x* **e**\u003csub\u003e423\u003c/sub\u003e + *y* **e**\u003csub\u003e431\u003c/sub\u003e + *z* **e**\u003csub\u003e412\u003c/sub\u003e.\n\n3D conformal geometric algebra\n* **RoundPoint3D** – A 3D [round point](https://conformalgeometricalgebra.org/wiki/index.php?title=Round_point) *x* **e**\u003csub\u003e1\u003c/sub\u003e + *y* **e**\u003csub\u003e2\u003c/sub\u003e + *z* **e**\u003csub\u003e3\u003c/sub\u003e + *w* **e**\u003csub\u003e4\u003c/sub\u003e + *u* **e**\u003csub\u003e5\u003c/sub\u003e.\n* **Dipole3D** – A 3D [dipole](https://conformalgeometricalgebra.org/wiki/index.php?title=Dipole) *d\u003csub\u003evx\u003c/sub\u003e* **e**\u003csub\u003e41\u003c/sub\u003e + *d\u003csub\u003evy\u003c/sub\u003e* **e**\u003csub\u003e42\u003c/sub\u003e + *d\u003csub\u003evz\u003c/sub\u003e* **e**\u003csub\u003e43\u003c/sub\u003e + *d\u003csub\u003emx\u003c/sub\u003e* **e**\u003csub\u003e23\u003c/sub\u003e + *d\u003csub\u003emy\u003c/sub\u003e* **e**\u003csub\u003e31\u003c/sub\u003e + *d\u003csub\u003emz\u003c/sub\u003e* **e**\u003csub\u003e12\u003c/sub\u003e + *d\u003csub\u003epx\u003c/sub\u003e* **e**\u003csub\u003e15\u003c/sub\u003e + *d\u003csub\u003epy\u003c/sub\u003e* **e**\u003csub\u003e25\u003c/sub\u003e + *d\u003csub\u003epz\u003c/sub\u003e* **e**\u003csub\u003e35\u003c/sub\u003e + *d\u003csub\u003epw\u003c/sub\u003e* **e**\u003csub\u003e45\u003c/sub\u003e.\n* **Circle3D** – A 3D [circle](https://conformalgeometricalgebra.org/wiki/index.php?title=Circle) *c\u003csub\u003egx\u003c/sub\u003e* **e**\u003csub\u003e423\u003c/sub\u003e + *c\u003csub\u003egy\u003c/sub\u003e* **e**\u003csub\u003e431\u003c/sub\u003e + *c\u003csub\u003egz\u003c/sub\u003e* **e**\u003csub\u003e412\u003c/sub\u003e + *c\u003csub\u003egw\u003c/sub\u003e* **e**\u003csub\u003e321\u003c/sub\u003e + *c\u003csub\u003evx\u003c/sub\u003e* **e**\u003csub\u003e415\u003c/sub\u003e + *c\u003csub\u003evy\u003c/sub\u003e* **e**\u003csub\u003e425\u003c/sub\u003e + *c\u003csub\u003evz\u003c/sub\u003e* **e**\u003csub\u003e435\u003c/sub\u003e + *c\u003csub\u003emx\u003c/sub\u003e* **e**\u003csub\u003e235\u003c/sub\u003e + *c\u003csub\u003emy\u003c/sub\u003e* **e**\u003csub\u003e315\u003c/sub\u003e + *c\u003csub\u003emz\u003c/sub\u003e* **e**\u003csub\u003e125\u003c/sub\u003e.\n* **Sphere3D** – A 3D [sphere](https://conformalgeometricalgebra.org/wiki/index.php?title=Sphere) *u* **e**\u003csub\u003e1234\u003c/sub\u003e + *x* **e**\u003csub\u003e4235\u003c/sub\u003e + *y* **e**\u003csub\u003e4315\u003c/sub\u003e + *z* **e**\u003csub\u003e4125\u003c/sub\u003e + *w* **e**\u003csub\u003e3215\u003c/sub\u003e.\n\n## Component Swizzling\n\nVector components can be swizzled using shading-language syntax. As an example, the following expressions are all valid for a `Vector3D` object `v`:\n\n* `v.x` – The *x* component of `v`.\n* `v.xy` – A 2D vector having the *x* and *y* components of `v`.\n* `v.yzx` – A 3D vector having the components of `v` in the order (*y*, *z*, *x*).\n\nSupport for repeated components in a swizzle can be enabled by defining `TERATHON_SWIZZLE_REPEAT`. This is disabled by default because the large number of additional swizzling possibilities increases compile times substantially. Swizzles with repeated components are always `const` so that it's not possible to assign to them.\n\nRows, columns, and submatrices can be extracted from matrix objects using a similar syntax. As an example, the following expressions are all valid for a `Matrix3D` object `m`:\n\n* `m.m12` – The (1,2) entry of `m`.\n* `m.row0` – The first row of `m`.\n* `m.col1` – The second column of `m`.\n* `m.matrix2D` – The upper-left 2×2 submatrix of `m`.\n* `m.transpose` – The transpose of `m`.\n\nAll of the above are generally *free operations*, with no copying, when their results are consumed by an expression. For more information, see Eric Lengyel's 2018 GDC talk [Linear Algebra Upgraded](https://terathon.com/gdc18_lengyel.pdf).\n\n## Geometric Algebra\n\nThe `^` operator is overloaded for cases in which the wedge or antiwedge product can be applied between vectors, bivectors, flat points, lines, planes, round points, dipoles, circles, and spheres. (Note that `^` has lower precedence than just about everything else, so parentheses will be necessary.)\n\nThe library does not provide operators that directly calculate the geometric product and antiproduct because they would tend to generate inefficient code and produce intermediate results having unnecessary types when something like the sandwich product **Q** ⟇ *p* ⟇ **Q̰** appears in an expression. Instead, there are `Transform()` functions that take some object *p* for the first parameter and the motor **Q** with which to transform it for the second parameter.\n\nSee Eric Lengyel's [Projective Geometric Algebra website](https://projectivegeometricalgebra.org) for more information about operations among these types.\n\n## API Documentation\n\nThere is API documentation embedded in the header files. The formatted equivalent can be found in the [C4 Engine documentation](https://c4engine.com/docs/Math/index.html).\n\n## Mathematica Packages\n\nMathematica packages for rigid, conformal, and spacetime geometric algebras are available in the [Geometric Algebra](https://github.com/EricLengyel/Geometric-Algebra/) repository.\n\n## Licensing\n\nSeparate proprietary licenses are available from Terathon Software. Please [send an email](mailto:service@terathon.com) with details about your particular use case if you are interested.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEricLengyel%2FTerathon-Math-Library","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FEricLengyel%2FTerathon-Math-Library","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEricLengyel%2FTerathon-Math-Library/lists"}