A math library for small vectors and matrices
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.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d50427488b11b8400a56f36e0c690d77d48cdb54b3011467dcf03f374a9ca84 |
|
MD5 | 389b1d11e92e8a2821580be630d3e532 |
|
BLAKE2b-256 | 8ffca08c14e76da0a88b24a7f507921c534fc159348d261241c3270ae13ee4ed |
Hashes for wp_math3d-0.6.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3bcb3cadfb3b3f307f0718ca2e80583b2fd53284d9ecb9593d44c89b6361c8c8 |
|
MD5 | 21f08d27543347dbf332dc2b383fa5d6 |
|
BLAKE2b-256 | 004864bdf778b5a453502156524999e38c971a840d5e05553d229e7c32f74518 |
Hashes for wp_math3d-0.6.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 509cb86aebfc39f87eb269e2db2cd4dc9a0772659d3d45409b3aa160c61aa209 |
|
MD5 | 9cd8bc30fd5383202362b38eccd291b7 |
|
BLAKE2b-256 | f49930308e3903abbdb05d0a3bcbe8e1c959d0b2ace881affbc5aa3bbee13635 |
Hashes for wp_math3d-0.6.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd27fcf865d6f36bfc60cb13cedef35418a90d2fcc187e6d4dbbe3a444f0ea72 |
|
MD5 | 6708d0a92dd3a26c14e64d2a018f65dd |
|
BLAKE2b-256 | 3e25318fa20795897346f1d74a2c22f9487aaa616d96c4a002cde7341ed05a35 |
Hashes for wp_math3d-0.6.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c56854b2cc9ffb3c6875d3bd44b02402aa8b23085ba3627669ca9e6bd235e887 |
|
MD5 | 7bb837ba02c739b5442cdeb72bbfe305 |
|
BLAKE2b-256 | 209baea465aed61e4b3f1712135c5c7da00504e2adfb14d9e80c17c95c25cdb7 |
Hashes for wp_math3d-0.6.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83a9738da33900e6810bd539fd583be951229ae6a4884a27cca08cd1e3c94569 |
|
MD5 | cb0d1641abecdfe03d5fbd960cc79474 |
|
BLAKE2b-256 | 9a8edd38b90a2bb4f9a29aced1c821de04b83a8e6fcab4ff470fabdbebd64695 |