Skip to main content

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 ci-linux
Windows ci-windows
MacOS ci-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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wp-math3d-0.6.2.tar.gz (91.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

wp_math3d-0.6.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (353.4 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

wp_math3d-0.6.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (353.6 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

wp_math3d-0.6.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (353.1 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

wp_math3d-0.6.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (353.4 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

wp_math3d-0.6.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (351.9 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

wp_math3d-0.6.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (378.2 kB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.17+ x86-64

File details

Details for the file wp-math3d-0.6.2.tar.gz.

File metadata

  • Download URL: wp-math3d-0.6.2.tar.gz
  • Upload date:
  • Size: 91.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for wp-math3d-0.6.2.tar.gz
Algorithm Hash digest
SHA256 5e54b3c9f5764d2d669e0b105716b8ff268d45c331fba7ad23ef0e01e6463325
MD5 e39c0921d58e617c26989d8681e025d3
BLAKE2b-256 92b67a89579b41c411127988269c840128058111aa37045eec03b86c7e701f19

See more details on using hashes here.

File details

Details for the file wp_math3d-0.6.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for wp_math3d-0.6.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2f24e088c1cbebd13c4f8bf47dae98227f85da6eaf8f52af64623026a28aca61
MD5 6bb431bab23807c01d98de398b68c517
BLAKE2b-256 51b07b0865f0af1c6e705b3085cd0e2e68f6b282c4c2f72e51c01745cb0bd3da

See more details on using hashes here.

File details

Details for the file wp_math3d-0.6.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for wp_math3d-0.6.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d0bc3b389bdb58e4884ff53d0dd104aeb101c7439590b7fc7fe8f619c7e25dcb
MD5 df0884da449a4012a5bf4476a0033466
BLAKE2b-256 03c0f86b2c8ce8bbab4a9dde7c51402926ba80c3c8762023d323b998bf4e811e

See more details on using hashes here.

File details

Details for the file wp_math3d-0.6.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for wp_math3d-0.6.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e249b3164d2e5849262e533aa0a060309e003f036504f3f471afdeed05b060fc
MD5 b6d975c8c0433c08364b2b07b6ddbf91
BLAKE2b-256 0cbf1cc5807f73a8839360d1c16b4b1e769f62fd109c6f8784bc98ce014bdf14

See more details on using hashes here.

File details

Details for the file wp_math3d-0.6.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for wp_math3d-0.6.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4c3f9923ef77a3b8cd8908aa20c1bfdc18e040b35cec5af66807e386510344fb
MD5 e62e5ab0b5353bf7d1ac2a5a581a1de2
BLAKE2b-256 0786f397ed954cf740cb42e2991435882f9dd0c59d02e568c16fb1e1c672de9c

See more details on using hashes here.

File details

Details for the file wp_math3d-0.6.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for wp_math3d-0.6.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 591b5178018758e66f656946c2d3170e5f61b542ada5f5581d1e925407d675ae
MD5 c8c41d441eed1833b8da605d5cdf44d6
BLAKE2b-256 41891d9782ae110621b67d4cf4e4ea3af66d2c4b4e9ad3a5d714897a6a8e9aeb

See more details on using hashes here.

File details

Details for the file wp_math3d-0.6.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for wp_math3d-0.6.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0471d4942c6d26d206944f596412084cc3092f23158087f87d47898fadfd8c50
MD5 b4acdf15402378809315c9d61e68d45f
BLAKE2b-256 a3b13fb4e7ace482064d9d306f88d2d7be43ea3dca660ae106da452784d68a59

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page