Skip to main content

A basic math library for spatial algebra

Project description

Math3d

A small header-only math library for vectors and matrices.

Build Status

Build Status
Ubuntu ci-linux
Windows ci-windows

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.14.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.14-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (344.5 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

wp_math3d-0.6.14-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (340.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

wp_math3d-0.6.14-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (341.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

wp_math3d-0.6.14-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (340.7 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

wp_math3d-0.6.14-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (340.2 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

File details

Details for the file wp_math3d-0.6.14.tar.gz.

File metadata

  • Download URL: wp_math3d-0.6.14.tar.gz
  • Upload date:
  • Size: 91.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for wp_math3d-0.6.14.tar.gz
Algorithm Hash digest
SHA256 016e1749a1e6eec992f5f62f20e27c82f09d817918ccb847634c788e25f609ac
MD5 da39c0fd2b0726daf8737da7cb6d466b
BLAKE2b-256 88311a9aa1c3472ca2d6b3747678fa7d774e7dab9a713d8f38d96a483d9da2b6

See more details on using hashes here.

File details

Details for the file wp_math3d-0.6.14-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for wp_math3d-0.6.14-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f191fec043341371219e6ec10059c16e9a17b94506f39accd0c433e5d412b596
MD5 87e922c6d08aa19077643ba5e49cd97b
BLAKE2b-256 d95c3e2cfc579ad09dd0ba3df6eb63eeb92c51e9634703899accc3255790a1fe

See more details on using hashes here.

File details

Details for the file wp_math3d-0.6.14-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for wp_math3d-0.6.14-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 25fc44505f2efccf31359e5b22393a05c21e821cf959cd7c358463ad97c9fb11
MD5 1f1121ca1339f33a493bc0bc6d518009
BLAKE2b-256 547faecaf70e2b129f2aca9b8965aebd32dbc1e38110eebe360c03001a56edad

See more details on using hashes here.

File details

Details for the file wp_math3d-0.6.14-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for wp_math3d-0.6.14-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f449603e6b368b0005ad5dfd90244553d1a1902a770ad42b9302fcdb22b73dbd
MD5 b3c1cc5c33023af86015503db0733924
BLAKE2b-256 feb5f656f07b39f717c84a6da95d7939fda285a6caa966fb96dc1b78a42e1af9

See more details on using hashes here.

File details

Details for the file wp_math3d-0.6.14-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for wp_math3d-0.6.14-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d05e312b4e692badd4c734938044192e028fadc247869734e9e1f23a389ccfe3
MD5 f9afcd95e6039597479862673f7df469
BLAKE2b-256 08d39dd6d715ffcba1ab0f8ca3e2b27b639e3948c88652073e7a19775514bfc9

See more details on using hashes here.

File details

Details for the file wp_math3d-0.6.14-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for wp_math3d-0.6.14-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bd6a35d8ceadd674fc17ba607aede680d02fb34d47bf1173733724a8fc23c377
MD5 b5ffed359c996490fece8a70aa62a87f
BLAKE2b-256 2844f173a89068a0a918a10dde5150927c26754bb9c5271ace288f7fb19d3e1d

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