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.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba7cd016747a552cc21d0cdd3614998d6ceb4b9f5b94d49686c6db553dc94889 |
|
MD5 | f90c828a1094b8c8db6fb5404b21f6fb |
|
BLAKE2b-256 | 4febf6e7748070ee277e3df20d284ff83115e31f65d8008556f6f7bd670533e6 |
Hashes for wp_math3d-0.6.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b489d99ca8ace087c523ab6b50264f7ef93395c6a85b570ca56213257b52dbb |
|
MD5 | 9c5d8e1dbc836852bb54e3e92e26b7e9 |
|
BLAKE2b-256 | 069556fad95248d4a0e81ce67321ba2daa20a0ce5c0279be339f623cd4b15a38 |
Hashes for wp_math3d-0.6.6-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 750dd8f1829d282dc95c3f5c5462f36c65d845524ac7ce08570d5ba105fef5e3 |
|
MD5 | d0821342595c0f9d6e324011c2a990b1 |
|
BLAKE2b-256 | 9d24dcffce70bc0647011198a9620a1d479cac5ab0a424a0d733c1172246d3fd |
Hashes for wp_math3d-0.6.6-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77beadaff85c1e20e27385bace229988e08457ca13f630c0767f0fe4d493a892 |
|
MD5 | 9c5d3800819d02650c1fab1e80e833b0 |
|
BLAKE2b-256 | 799e4845e7a9d075f27b5c783a8efd75f1c43b2b809aa22c7d1f96d4caa3ef11 |
Hashes for wp_math3d-0.6.6-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 133b687f6ba3cd59dc6da6c66e1187e446951a32bcf2c16216d7f9cbccf14a55 |
|
MD5 | 5bfc1acc761281cf642a426f5d021b75 |
|
BLAKE2b-256 | 001a2f53809473d9aec496285f26657b8d59bf379a66893b85299278531b5872 |