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

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

wp_math3d-0.6.9-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (340.2 kB view details)

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

wp_math3d-0.6.9-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (341.1 kB view details)

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

wp_math3d-0.6.9-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (340.3 kB view details)

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

wp_math3d-0.6.9-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.9.tar.gz.

File metadata

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

File hashes

Hashes for wp-math3d-0.6.9.tar.gz
Algorithm Hash digest
SHA256 dc2c437ba3da8ee2445a1bb268583afefa10e2cbd68b9651c886384f6602f748
MD5 537787be084df99c9c52305710d4c97c
BLAKE2b-256 5a19db42aeeb9ec8cfeff9f7599f9889c8ef8a049e803cbd51ec1443a80ee60e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wp_math3d-0.6.9-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2b4073b3716c82156652c05dc1ed4065a7ac0db37df358dbbaceb6901fa51099
MD5 7088c1e9770b759103dbd15639df55f5
BLAKE2b-256 b5162e7567f28cb45a2ec9a0ca0db2c9d094ac3b7da334b180534d6a63f5b141

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wp_math3d-0.6.9-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 221d91c8ad457889a5359242b1ec1444afa83d94a5f9e6573be13f2af2bc8141
MD5 8b88d4d6e93e92eaa2a2e4950a7871c1
BLAKE2b-256 8affe7268f4078261ff9af0e81916cdedde7dde382caf20c12ee750b0487b918

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wp_math3d-0.6.9-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 147f6a3909ce416df25b338000585a33c72ab3c0246a1339cd82a257637ce713
MD5 56c2c0186ff1af5b7fac179141d05ed0
BLAKE2b-256 31f328aabeb88d34d0e83eab114a0df24c5d5f2855175b2c2d480f502cffb753

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wp_math3d-0.6.9-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c268c9dbcaeb86e2c43270c4c27f8e3fb29e5eacd8d827fea67d2dfb2f3af6cb
MD5 d91463dcc1a5fc1f49ba765dbd712e40
BLAKE2b-256 9d453b48678ce6207d3cf875f987cc572b543b032b808b608c0f120e52e53b1d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wp_math3d-0.6.9-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 faefbed64a523563f2b2144cc9706d11ca9f25b0cde2dcf063b5e07a269ddb4b
MD5 f796acbd6315a5d33bd7c6a1598eeef3
BLAKE2b-256 89633602d91b20b0de3c0fdb18ecb63cc837f778143df7fc36e51f330c6d71e8

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