A basic math library for vectors and matrices
Project description
tiny_math
A basic math library for vectors and matrices (just for 2,3, and 4 dimensions)
Yet another math library
This library is intended mainly for test purposes (integration with PyPi, ReadTheDocs, CI, python-bindings, etc.). However, we currently use it as a replacement to other more complete libraries like glm and Eigen in some projects that make heavy use of C/C++ and also require Python support through bindings.
Setup
C++
Clone this package into your third_party dependencies:
# Replace "third_party" with your own dependencies-folder name
git clone https://github.com/wpumacay/tiny_math.git third_party/tiny_math
The library is a template-based header-only library, so just include the headers in the include
folder, e.g. in your own CMakeLists.txt:
include_directories( third_party/tiny_math/include )
Alternatively, you can use the CMake target tinymath_cpp_lib as a dependency in your own target:
add_library( my_own_awesome_library tinymath_cpp_lib )
Python
Use the provided setup.py file:
python setup.py install
Or via PyPi:
pip install wp-tinymath
And import the tinymath package in your python files:
import tinymath as tm
Usage
C++
#include <vector_t.h>
#include <matrix_t.h>
int main()
{
// Create a vec3-float32 and show it on the console
tinymath::Vector3f _vec = { 1.0f, 2.0f, 3.0f };
std::cout << "vec: " << tinymath::toString( vec ) << std::endl;
// Create a mat3 float32, show its entries and its inverse
auto mat = tinymath::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 << tinymath::toString( mat ) << std::endl;
std::cout << "mat.inverse():" << std::endl;
std::cout << tinymath::toString( mat.inverse() ) << std::endl;
return 0;
}
Python
import tinymath as tm
# Create a vec3-float32 and show it on the console
vec = tm.Vector3f( [1.0, 2.0, 3.0] )
print( 'vec: {}'.format( vec ) )
# Create a mat3 float32, show its entries and its inverse
mat = tm.Matrix3f( [ [ 3.0, 9.0, 3.0 ],
[ 9.0, 0.0, 3.0 ],
[ 2.0, 3.0, 8.0 ] ] );
print( "mat:" )
print( mat )
print( "mat.inverse():" )
print( mat.inverse() )
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file wp-tinymath-0.0.3.tar.gz.
File metadata
- Download URL: wp-tinymath-0.0.3.tar.gz
- Upload date:
- Size: 198.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2.post20191203 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
939e2a1f230f6fedaf17cc8018a080d632fb9d5a073f57abb30a4c647837db43
|
|
| MD5 |
d2a4400958dcfffc146b6c8b6b68f50a
|
|
| BLAKE2b-256 |
b41a060a4fa37f38ac5d169b5b15736f6333aed68a90ad0952e203f9935a409d
|