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

File metadata

  • Download URL: wp_math3d-0.6.13.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.13.tar.gz
Algorithm Hash digest
SHA256 77593856bbeeb1c5075158bbce16a3b5dbfacd28701e41606d6efccfea5bc869
MD5 2d0562fa2ca72e26e8d0c75afe5f04cb
BLAKE2b-256 27936cb98491ab69203e85ac352ea638134be2e357f37bb396c8c02e36751f79

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wp_math3d-0.6.13-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5373e584467c5251b8c6223813aae1b24390c958469e016abc97534afbd18da6
MD5 1e48b446ee0928ee71a210a9c9507010
BLAKE2b-256 334cfd997621409a526e6b0b86ccb575ebe8a94c172a3d26574b2dbf33b19af9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wp_math3d-0.6.13-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bb04040d018ea048257dc5d30b5f5fe2a6a7795de31bb80d5da7e64d7abf0391
MD5 089df2a4d524c47e0183e7b35a38bd22
BLAKE2b-256 8533c89e7b8465bb351ad0c500055f912c48fe94a54bcad5aced03ff4a9021cd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wp_math3d-0.6.13-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1f0dc0f0a146ac2f00eb7cc2bb45d5a2383654db49ae8b4c91a5cef1ebb261c7
MD5 9caef0eb16f93431ec041a4989ed8f6c
BLAKE2b-256 c060472237fa151007a8f39e8d2a728fce01fe6fc1ec5ebbba157404aa047324

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wp_math3d-0.6.13-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4c09edb30297adedb77e80b042c6778d3141ea1de2e4c0d6a6925d4cd888395b
MD5 177e555e337c80177ffe1308446c3833
BLAKE2b-256 ae494bfa80b3af64a224a258d6bafc3d5ff0c78b536f86c1107de39f3f15c9be

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wp_math3d-0.6.13-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 75279222deb042aae298019ab68c725bd0d1e5b499b9f2131807d6d54965e87a
MD5 f7de7e1d84b90f3ce98654a671cea5da
BLAKE2b-256 fd12d330c86c9c0b028237aaf705c26e0ecb94388814ad2d88d71dd9f8adb56b

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