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.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4e8d52b907f70efe3c5ebaf281ab865011d1c15fac806084b2c1299a9961573 |
|
MD5 | 6673e69c753007a66ffcfbe1b1fada82 |
|
BLAKE2b-256 | 8141a160bb77d839c0b67e89ec0c6bfb1871a232744ad292afe1d8dab07ffc2f |
Hashes for wp_math3d-0.6.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ce25d922e1e1955619aa0d549a866cd5813f0e2500af623cecb6c9aab540d77 |
|
MD5 | 43b74291a557b4c40bb7b224c65f95cd |
|
BLAKE2b-256 | eca4a2d9cc62fc5239bf1c0b7d8ed9e9a1c9132397c73c2ac7d7b37d3999ec20 |
Hashes for wp_math3d-0.6.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78c6a807a55b08513787b4da554209ec2ff1c8e1a64bf701bca75579b16593a2 |
|
MD5 | e7bf15c01e68bed08e7ca51160207b3d |
|
BLAKE2b-256 | 95e03a43932bee421146b7ef379c3f330cffe015434838a5b01fd09940ee1afa |
Hashes for wp_math3d-0.6.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33b48de826a1fb04638b528f9662f64931b72485b1789d3084325da203427d85 |
|
MD5 | 44762c148d0273386fd31749169cba8a |
|
BLAKE2b-256 | 0d03fdcd44723cdb0897b9d51022cb18c7d67127dbbdb48fb4dc646d95782975 |
Hashes for wp_math3d-0.6.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6688aec325a757c71879f904f3293e69fcf61ac744df30f19a708a987d5f4035 |
|
MD5 | 595435233092e992dbdc3f70f6ee547a |
|
BLAKE2b-256 | cc8ffbc368edd9a822faa1b0b5ceee649213e5d7b14be7bd7a17d23611a584d3 |
Hashes for wp_math3d-0.6.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1cb8bb4dd1b52c6550380cb74f89d163b28ca32d6874f93eab4fe6e6c2588fa |
|
MD5 | a0a92aa71aca746eb7c59e77c2e83c02 |
|
BLAKE2b-256 | 30c0126d73ee6b94bc3859be81b8b918dd526bbe8c6cdf7d1e7f713a6225e20f |