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.11-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | df6ec9abb026582ddfff3e94bd1fe0695b4fe0b9ba77e83891862c90fe7df9a3 |
|
MD5 | 8a20ce066426e32808a5a9677ed7943c |
|
BLAKE2b-256 | bf8b0b27c5a26345aac892120d5fdf564f1c88f522b41c14120a08dc92bef1da |
Hashes for wp_math3d-0.6.11-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f62ca896d79b87b79cae2f96692cc93afbbd6b967482d04701cb1a0971ab3c3f |
|
MD5 | e2ddbabe29004757f4f6786a486f9742 |
|
BLAKE2b-256 | 67408ad9abf756cf1803e3fd8c24fa756f9cbc4b12a22b8681c025ac73adc0e9 |
Hashes for wp_math3d-0.6.11-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f115c1b6c6544d3b63f172fbd25fc66a3b6c0d9eed64d180a8bd7f0e5cc9c5f1 |
|
MD5 | c77ccbdfaeded031b3ed929d808b227f |
|
BLAKE2b-256 | 631cdc6170fb0e619c9811e656d96d1186134f67741db0d03b5b31bae3a9f007 |
Hashes for wp_math3d-0.6.11-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4104afa131675858c098ca21564dbcbe975dea405da7b4c5feecf83ddb513878 |
|
MD5 | dbe4d05a9500be1d9966ed7d5fd22767 |
|
BLAKE2b-256 | e23ed26c39858ad8f5e248463e05da33f2bcccbb6a17aec9e4dc20693e251525 |
Hashes for wp_math3d-0.6.11-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d0c233cea71a516c4d40658196b25d54f634db8a045adcf8551d81c4e268f736 |
|
MD5 | 8b30d33a98b8e27571627bfe91e47a68 |
|
BLAKE2b-256 | 8168b61c83c81905c68256cae59ad938631fa007a3294a1b9f89fa6a45f03942 |