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.15.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.15-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.15-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.15-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.15-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.15-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.15.tar.gz.

File metadata

  • Download URL: wp_math3d-0.6.15.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.15.tar.gz
Algorithm Hash digest
SHA256 4599011c291ca7a3f166be27c50e7c6a9484b672e73296c610002d7cf6e65038
MD5 5c9b95c999ffb1f6dc8c8756b5b75d3c
BLAKE2b-256 33bc5bb1eb5525d270ed8efa74e5c84fa2596d375c5abf2a2bf13272045d63d0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wp_math3d-0.6.15-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7e37eaa64c68485593fa6b5cb1661f9bff0116939181e252f2cb587145a5ef5a
MD5 b645e6ba5443619108c25aeb6cbdc46c
BLAKE2b-256 6a18361799f6181aa0dc158cc27c1178f8db3f0ef4af83e1a9e06ad8f861bbff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wp_math3d-0.6.15-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1fff0cbb1b25382e8046f64bd19ab4f9af288dbefa484184736b4f962ec049b4
MD5 9c0c75ac4a2f8a34a867ee73b400286f
BLAKE2b-256 27cd4d2fc276772674010199c79bb9c1c6065f6ac1ea8044b10567c99158a964

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wp_math3d-0.6.15-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6e2a8bf35e37b3a90ddc81ae0fc43a50d13524de9c2a7c56e222b28bde601a15
MD5 efba356fb6f14b517e7fc25bb2f5e2de
BLAKE2b-256 1d0a057f3d9aee0e38726d8d0f6c0ea8376266d6de601c1e2f5340c96f966742

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wp_math3d-0.6.15-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4f39e73a608d34242c0a9c63ffa11e447a49de2e157c20b81efdd088e0f0c4de
MD5 88011cbca64d560a8d7c804f1501eb45
BLAKE2b-256 63ed5ee2792eaca5248e7a41062f2590035b7d3c31bbef70d8f2c32711559eb0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wp_math3d-0.6.15-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 10d1d37f960917ab4f0a76d2ee263f0aaed38945408ad7081f23a8d38ff8fec0
MD5 b81ee6884fa09e10c0c8423aec2fc388
BLAKE2b-256 a7d6b3b9755254638172a36a9b52484dd5829a07aa86582d4bc14670ba456385

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