# Math3d
A small header-only math library for vectors and matrices
## Build Status
| Build | Status
| ------- | ------------------------------
| Ubuntu | [![ci-linux][0]][1] |
| Windows | [![ci-windows][2]][3] |
| MacOS | [![ci-macos][4]][5] |
## Yet another math library
This library is designed to be a potential replacement to various other great
libraries like `Eigen` and `glm`, but with a narrow focus on 2, 3, and 4
dimensional vectors and matrices. These appear commonly when using spatial
algebra in robotics, which is the main application area this library was
initially developed for.
## Setup
### C++ setup
Clone this package into your `third_party` dependencies:
```bash
# Replace "third_party" with your own dependencies-folder name
git clone https://github.com/wpumacay/math3d.git third_party/math3d
```
There's a `CMake` target called `math::math`. Just add the source directory in
your `CMake` workflow, and use the given target as follows:
```CMake
# Add the Math3d subdirectory
add(third_party/math3d)
# Link against the exposed math::math target
target_link_library(MY_LIBRARY PRIVATE math::math)
```
### Python setup
Use the provided `setup.py` file:
```bash
python setup.py install
```
And import the types from the `math3d` package:
```python
import math3d as m3d
```
## Usage
### C++
```c++
#include <vec3_t.h>
#include <mat3_t.h>
int main()
{
// Create a vec3-float32 and show it on the console
::math::Vector3f vec = { 1.0f, 2.0f, 3.0f };
std::cout << "vec: " << vec << std::endl;
// Create a mat3 float32, show its entries and its inverse
auto mat = ::math::Matrix3f( 3.0f, 9.0f, 3.0f,
9.0f, 0.0f, 3.0f,
2.0f, 3.0f, 8.0f );
std::cout << "mat:" << std::endl;
std::cout << mat << std::endl;
std::cout << "mat.inverse():" << std::endl;
std::cout << ::math::inverse( mat ) << std::endl;
return 0;
}
```
### Python
```python
import numpy as np
from math3d import Vector3f, Matrix3f
# Create a vec3-float32 and show it on the console
vec = Vector3f(np.array([1.0, 2.0, 3.0], dtype=np.float32))
print(vec)
# Create a mat3 float32, show its entries and its inverse
mat = Matrix3f(np.array([[ 3.0, 9.0, 3.0 ],
[ 9.0, 0.0, 3.0 ],
[ 2.0, 3.0, 8.0 ]], dtype=np.float32))
print(mat)
print("inverse(): \n\r{}".format(mat.inverse()))
```
---
[0]: <https://github.com/wpumacay/math3d/actions/workflows/ci-linux.yml/badge.svg> (ci-linux-badge)
[1]: <https://github.com/wpumacay/math3d/actions/workflows/ci-linux.yml> (ci-linux-status)
[2]: <https://github.com/wpumacay/math3d/actions/workflows/ci-windows.yml/badge.svg> (ci-windows-badge)
[3]: <https://github.com/wpumacay/math3d/actions/workflows/ci-windows.yml> (ci-windows-status)
[4]: <https://github.com/wpumacay/math3d/actions/workflows/ci-macos.yml/badge.svg> (ci-macos-badge)
[5]: <https://github.com/wpumacay/math3d/actions/workflows/ci-macos.yml> (ci-macos-status)
Raw data
{
"_id": null,
"home_page": "https://github.com/wpumacay/loco-math",
"name": "wp-math3d",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "math",
"author": "Wilbert Santos Pumacay Huallpa",
"author_email": "wpumacay@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/e2/84/0536ca3d9b73dd43550354dd528c40ae1e7b794a3d763d6303ae8e603952/wp-math3d-0.6.10.tar.gz",
"platform": null,
"description": "# Math3d\n\nA small header-only math library for vectors and matrices\n\n## Build Status\n\n| Build | Status\n| ------- | ------------------------------\n| Ubuntu | [![ci-linux][0]][1] |\n| Windows | [![ci-windows][2]][3] |\n| MacOS | [![ci-macos][4]][5] |\n\n## Yet another math library\n\nThis library is designed to be a potential replacement to various other great\nlibraries like `Eigen` and `glm`, but with a narrow focus on 2, 3, and 4\ndimensional vectors and matrices. These appear commonly when using spatial\nalgebra in robotics, which is the main application area this library was\ninitially developed for.\n\n## Setup\n\n### C++ setup\n\nClone this package into your `third_party` dependencies:\n\n```bash\n# Replace \"third_party\" with your own dependencies-folder name\ngit clone https://github.com/wpumacay/math3d.git third_party/math3d\n```\n\nThere's a `CMake` target called `math::math`. Just add the source directory in\nyour `CMake` workflow, and use the given target as follows:\n\n```CMake\n# Add the Math3d subdirectory\nadd(third_party/math3d)\n\n# Link against the exposed math::math target\ntarget_link_library(MY_LIBRARY PRIVATE math::math)\n```\n\n### Python setup\n\nUse the provided `setup.py` file:\n\n```bash\npython setup.py install\n```\n\nAnd import the types from the `math3d` package:\n\n```python\nimport math3d as m3d\n```\n\n## Usage\n\n### C++\n\n```c++\n\n#include <vec3_t.h>\n#include <mat3_t.h>\n\nint main()\n{\n // Create a vec3-float32 and show it on the console\n ::math::Vector3f vec = { 1.0f, 2.0f, 3.0f };\n std::cout << \"vec: \" << vec << std::endl;\n\n // Create a mat3 float32, show its entries and its inverse\n auto mat = ::math::Matrix3f( 3.0f, 9.0f, 3.0f,\n 9.0f, 0.0f, 3.0f,\n 2.0f, 3.0f, 8.0f );\n\n std::cout << \"mat:\" << std::endl;\n std::cout << mat << std::endl;\n std::cout << \"mat.inverse():\" << std::endl;\n std::cout << ::math::inverse( mat ) << std::endl;\n\n return 0;\n}\n```\n\n### Python\n\n```python\nimport numpy as np\nfrom math3d import Vector3f, Matrix3f\n\n# Create a vec3-float32 and show it on the console\nvec = Vector3f(np.array([1.0, 2.0, 3.0], dtype=np.float32))\nprint(vec)\n\n# Create a mat3 float32, show its entries and its inverse\nmat = Matrix3f(np.array([[ 3.0, 9.0, 3.0 ],\n [ 9.0, 0.0, 3.0 ],\n [ 2.0, 3.0, 8.0 ]], dtype=np.float32))\n\nprint(mat)\nprint(\"inverse(): \\n\\r{}\".format(mat.inverse()))\n```\n\n---\n\n[0]: <https://github.com/wpumacay/math3d/actions/workflows/ci-linux.yml/badge.svg> (ci-linux-badge)\n[1]: <https://github.com/wpumacay/math3d/actions/workflows/ci-linux.yml> (ci-linux-status)\n[2]: <https://github.com/wpumacay/math3d/actions/workflows/ci-windows.yml/badge.svg> (ci-windows-badge)\n[3]: <https://github.com/wpumacay/math3d/actions/workflows/ci-windows.yml> (ci-windows-status)\n[4]: <https://github.com/wpumacay/math3d/actions/workflows/ci-macos.yml/badge.svg> (ci-macos-badge)\n[5]: <https://github.com/wpumacay/math3d/actions/workflows/ci-macos.yml> (ci-macos-status)\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "A basic math library for spatial algebra",
"version": "0.6.10",
"project_urls": {
"Homepage": "https://github.com/wpumacay/loco-math"
},
"split_keywords": [
"math"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "05fe7148f86c977900672d11e151322c4c17f1c9f8c8fb11361e61dafa310c61",
"md5": "cd62c5dec165185fe678b77ded833389",
"sha256": "8d6abbd28d3722f62369084abdf424a07e598f177e12b456921548265bca2482"
},
"downloads": -1,
"filename": "wp_math3d-0.6.10-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "cd62c5dec165185fe678b77ded833389",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.7",
"size": 341875,
"upload_time": "2023-12-30T23:36:37",
"upload_time_iso_8601": "2023-12-30T23:36:37.337708Z",
"url": "https://files.pythonhosted.org/packages/05/fe/7148f86c977900672d11e151322c4c17f1c9f8c8fb11361e61dafa310c61/wp_math3d-0.6.10-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "83631ba8c445c3adcf045cc4ac338a4a0664e97587eb8d25caf662be4eaf65d0",
"md5": "c3f89daf4f0a6d337b1437f1581e03ec",
"sha256": "824b59bd4f9bb0600a3cd88d21c8e4f0ea32c9457a594d7b61e176ed64393c74"
},
"downloads": -1,
"filename": "wp_math3d-0.6.10-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "c3f89daf4f0a6d337b1437f1581e03ec",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.7",
"size": 340831,
"upload_time": "2023-12-30T23:36:39",
"upload_time_iso_8601": "2023-12-30T23:36:39.723244Z",
"url": "https://files.pythonhosted.org/packages/83/63/1ba8c445c3adcf045cc4ac338a4a0664e97587eb8d25caf662be4eaf65d0/wp_math3d-0.6.10-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e07150d1df996b5932966612100ce9cf2340f8848b018682bc4246473f1048a8",
"md5": "7192e4235f7f8741b2b29c2e1d4461d6",
"sha256": "fa8f0ad71253eff192d1f1596b7d58a3d465a864aead56670d021bba3764c2e3"
},
"downloads": -1,
"filename": "wp_math3d-0.6.10-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "7192e4235f7f8741b2b29c2e1d4461d6",
"packagetype": "bdist_wheel",
"python_version": "cp312",
"requires_python": ">=3.7",
"size": 344475,
"upload_time": "2023-12-30T23:36:37",
"upload_time_iso_8601": "2023-12-30T23:36:37.995503Z",
"url": "https://files.pythonhosted.org/packages/e0/71/50d1df996b5932966612100ce9cf2340f8848b018682bc4246473f1048a8/wp_math3d-0.6.10-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c2970aab2e57845da15eae61e5d7e788807cde3ad375c88831cae7bbdebe71c7",
"md5": "b785dcc1ecb3cc825ef269f418a453b0",
"sha256": "e93d13f0f7b34790a8407c161ecbb52550d718c83ad778c5ff5ff3e24584877e"
},
"downloads": -1,
"filename": "wp_math3d-0.6.10-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "b785dcc1ecb3cc825ef269f418a453b0",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": ">=3.7",
"size": 340213,
"upload_time": "2023-12-30T23:36:41",
"upload_time_iso_8601": "2023-12-30T23:36:41.379461Z",
"url": "https://files.pythonhosted.org/packages/c2/97/0aab2e57845da15eae61e5d7e788807cde3ad375c88831cae7bbdebe71c7/wp_math3d-0.6.10-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "4761cd29be170acdd2f937edbd28c504009b8a97fc743638d276f1f5faa03459",
"md5": "2979e457866504de179fa9893be9409f",
"sha256": "7ba5203066fee0c8e6666ef48ca70a37339f524b6258d0876655669f3eb09266"
},
"downloads": -1,
"filename": "wp_math3d-0.6.10-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "2979e457866504de179fa9893be9409f",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": ">=3.7",
"size": 340762,
"upload_time": "2023-12-30T23:36:37",
"upload_time_iso_8601": "2023-12-30T23:36:37.926304Z",
"url": "https://files.pythonhosted.org/packages/47/61/cd29be170acdd2f937edbd28c504009b8a97fc743638d276f1f5faa03459/wp_math3d-0.6.10-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e2840536ca3d9b73dd43550354dd528c40ae1e7b794a3d763d6303ae8e603952",
"md5": "b5961501dfc07a5395f65a8e952f9f66",
"sha256": "fa500c792d86cc96b63bcaddfeec0518bf4a92292ae5a913b12e04bd212324b9"
},
"downloads": -1,
"filename": "wp-math3d-0.6.10.tar.gz",
"has_sig": false,
"md5_digest": "b5961501dfc07a5395f65a8e952f9f66",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 90810,
"upload_time": "2023-12-30T23:35:30",
"upload_time_iso_8601": "2023-12-30T23:35:30.099376Z",
"url": "https://files.pythonhosted.org/packages/e2/84/0536ca3d9b73dd43550354dd528c40ae1e7b794a3d763d6303ae8e603952/wp-math3d-0.6.10.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-30 23:35:30",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "wpumacay",
"github_project": "loco-math",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "wp-math3d"
}