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.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1418481afe3707bf3113bea364a12e4c66a55444020640b8eefca4d27768f94d |
|
MD5 | 002c042bc1b88df765caadbba7153f76 |
|
BLAKE2b-256 | 743eed2aec7441b81ad10ad96fd8b222e325fc72dbeac49e6afb35f885a65144 |
Hashes for wp_math3d-0.6.3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 419c932e855b8dd276eb61c2108a106165a50ea2c53a1791baaadd442b23471a |
|
MD5 | 841a131f5881efb733f0e7e939de1749 |
|
BLAKE2b-256 | ef1a40e2af9ce1f3dc0d81af94a452109500c195bd2dd9062f82a99c4db68447 |
Hashes for wp_math3d-0.6.3-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b6b7a99f4d0f018b2b4f58548f4e4517921ee7fce07401f0a19e29033998968 |
|
MD5 | ce0d1b2bc73db65d2336b3131a14a080 |
|
BLAKE2b-256 | 2574b9248b5baf82d5c2da1c1e656d08bb3713c6f3ccbd629ff3c802fbd8f171 |
Hashes for wp_math3d-0.6.3-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | de817a5458e6b0b4c3e02e8b6dbd002b76857bfa83a5578efc77ea21761e027d |
|
MD5 | 4997efd452b971e6420055b0602eaaf0 |
|
BLAKE2b-256 | a043461933dc767dbae6c22b22872169990addd91a41635d0e87fb85f1c20457 |
Hashes for wp_math3d-0.6.3-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ced77f084f759dfc313eb64008684f1e32f5308fe85254b2b5e4e790f3802302 |
|
MD5 | e083f584bb870e0f4a498698cba645dc |
|
BLAKE2b-256 | 1d36ef3afa053b16e033da251d265babf3dd593c54aec66e44670b3edcc510fb |
Hashes for wp_math3d-0.6.3-cp37-cp37m-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ef7e7e8281d2ce1ee1e626ef4f51dc4bd3c30aa66e1f95e294c8c5259248be1 |
|
MD5 | d696846f031251dc6241c85bd6aa5b48 |
|
BLAKE2b-256 | 3243632878a4913df56cf669b62f5853cf050a04a55ad87d98e78041af8b4c1b |