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

File metadata

  • Download URL: wp_math3d-0.6.12.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.12.tar.gz
Algorithm Hash digest
SHA256 33391519288c66d6f2c740933dd7c7595969f9bc344c46700f5053becff50afe
MD5 30d413c4ef48460be65b134a42d8763f
BLAKE2b-256 69ac8d5032369a31f807b2aacfc863cf2da71887c4220f8254b6508d32c46e0a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wp_math3d-0.6.12-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0af1fe343396db2fb385627b3974b34a06c8b1303acf917324a0f715ae9cf947
MD5 a4a5ca3ebd3cd06c0f772777a0a4fe5b
BLAKE2b-256 86ded3924b890a63eed9e02a312b932b9bdb5aa5728da23e4861a5acc0d079d7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wp_math3d-0.6.12-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5573bd72247b1ed5bbee8942f0e1291c788bfe372f2071305434be67fa7865aa
MD5 c07ec2ca0bf2f33b9f029d89b23a2c61
BLAKE2b-256 287f2b983496e00bf14e231956480d29e0bb15e8b66ed82aec9b48489390f87e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wp_math3d-0.6.12-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9a13b941394c01d0a1988d01b796fcb31a0e9dacaa3182727e3c4e192290ec0d
MD5 ac2fedb9a7be09a12755590af9a46246
BLAKE2b-256 627c3e53f17f79a76afdc9d1c7445b18db446b0a101d76f13d456933e2093420

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wp_math3d-0.6.12-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 db4077f753210e037a8c582fe8abef6d346b686d505665b7d093a15f032c9686
MD5 5cf92ff38000120d7be572bc74235682
BLAKE2b-256 0b807a063b291a43d85af158e35d6a5b819398118bee0819b7dc442acd907665

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wp_math3d-0.6.12-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0efb425a323a544d01f9681cc3a5327a16b915fc58440d9cebd63f542b408e44
MD5 8dcf891ed31c2223b66883c0b0a13091
BLAKE2b-256 8446425bb8d8804128e6cb3e095110d3e9d7238ed65cb6eb6011f1f87389a81d

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