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
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.7.tar.gz (90.6 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.7-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (316.8 kB view details)

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

wp_math3d-0.6.7-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (315.4 kB view details)

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

wp_math3d-0.6.7-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (315.1 kB view details)

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

wp_math3d-0.6.7-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (316.2 kB view details)

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

wp_math3d-0.6.7-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (315.6 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.7.tar.gz.

File metadata

  • Download URL: wp-math3d-0.6.7.tar.gz
  • Upload date:
  • Size: 90.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for wp-math3d-0.6.7.tar.gz
Algorithm Hash digest
SHA256 e48e484bf993e1e9dc19a5891e9bf4fc790ad157d02cfaa36c2573bf55f47fa6
MD5 3e2aa65011134641ba8b30f8e8e05ad9
BLAKE2b-256 19b396c222946cb279c8ea6daae85bf6300e90277a0d44cb3b62fe1ba246c43a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wp_math3d-0.6.7-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3f780837329b497d764b8d67acad1225a89ed2977e95100aa86e3e1dd7ba022e
MD5 205bee3bc9458bc1967dfdcfd4e9faba
BLAKE2b-256 82a69cbcaeb4806d065b8b2641672d345a835fcb5fb2ae375e199320e6691eb7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wp_math3d-0.6.7-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ab1b4b411607d88ba0d7bfc7ae14223cce46ba621f9dcb1f2c5824a5dd438e74
MD5 54417929b39613252d699c4379ab0adb
BLAKE2b-256 9a893db47161d34d734e4037109815217938acbfff9353f06ebd367db99b9fbd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wp_math3d-0.6.7-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a22476724b48f68fffe5bb0beb2047730e030680fd00e3c5c2aea7933a5bafb0
MD5 83db181f61fd3db4ba4d89ea43bae7dc
BLAKE2b-256 6f0330b283dec090f9e59d4f24a006a01eaa5b26396a80effe023ce3e6480c5b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wp_math3d-0.6.7-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 11e82ca5713ad1bb1d7f42dcec115e306b84c3470f03d2ec3c69d63fa48c1164
MD5 6fcdcf1b349f42d77087cdc14698181b
BLAKE2b-256 b9d8183867699312114ef38ad45163c349ab6ddfd9ad2c3efbd1b85160d9541a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wp_math3d-0.6.7-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2e0c00ebba9f6b2e2ec76d55e7f834b7e0cc86699b1219e7124ab75a505ab96b
MD5 39ba7035a89534573e566b03fe227f64
BLAKE2b-256 25156d3ca05e0b96bf376034440cd9a8e2bd49e264add393ad3a0326204d73c0

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