A basic math library for spatial algebra
Project description
Math3d
A small header-only math library for vectors and matrices
Build Status
Build | Status |
---|---|
Ubuntu | |
Windows | |
MacOS |
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:
# 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:
# 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:
python setup.py install
And import the types from the math3d
package:
import math3d as m3d
Usage
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
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()))
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for wp_math3d-0.6.10-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa8f0ad71253eff192d1f1596b7d58a3d465a864aead56670d021bba3764c2e3 |
|
MD5 | 7192e4235f7f8741b2b29c2e1d4461d6 |
|
BLAKE2b-256 | e07150d1df996b5932966612100ce9cf2340f8848b018682bc4246473f1048a8 |
Hashes for wp_math3d-0.6.10-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 824b59bd4f9bb0600a3cd88d21c8e4f0ea32c9457a594d7b61e176ed64393c74 |
|
MD5 | c3f89daf4f0a6d337b1437f1581e03ec |
|
BLAKE2b-256 | 83631ba8c445c3adcf045cc4ac338a4a0664e97587eb8d25caf662be4eaf65d0 |
Hashes for wp_math3d-0.6.10-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d6abbd28d3722f62369084abdf424a07e598f177e12b456921548265bca2482 |
|
MD5 | cd62c5dec165185fe678b77ded833389 |
|
BLAKE2b-256 | 05fe7148f86c977900672d11e151322c4c17f1c9f8c8fb11361e61dafa310c61 |
Hashes for wp_math3d-0.6.10-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ba5203066fee0c8e6666ef48ca70a37339f524b6258d0876655669f3eb09266 |
|
MD5 | 2979e457866504de179fa9893be9409f |
|
BLAKE2b-256 | 4761cd29be170acdd2f937edbd28c504009b8a97fc743638d276f1f5faa03459 |
Hashes for wp_math3d-0.6.10-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e93d13f0f7b34790a8407c161ecbb52550d718c83ad778c5ff5ff3e24584877e |
|
MD5 | b785dcc1ecb3cc825ef269f418a453b0 |
|
BLAKE2b-256 | c2970aab2e57845da15eae61e5d7e788807cde3ad375c88831cae7bbdebe71c7 |