Package: blmath
Collection of math-related utilities developed at Body Labs.This is a legacy library in active maintenance. The goals are:Keep the library working in current versions of Python and other
tools.Make bug fixes.Provide API stability and backward compatibility with the upstream
version.The main thrust is to transition the functionality in this library (and
the code which depends on it, such aslaceto new libraries includevgandpolliwog. In general, new
functionality should be added in the new libraries. As needed,
additional libraries can be added to the lace org.InstallationInstall dependenciesOn macOS:brew install homebrew/science/suite-sparse
brew install homebrew/science/opencv --without-numpyOn Linux:sudo apt-get install python-opencv libsuitesparse-devInstall the librarypipinstallblmathAnd import it just like the upstream library:fromblmath.numericsimportvxA collection of math related utilities used by many bits of BodyLabs’
code.blmath.numericsFunctions for manipulating numeric arrays, numbers, and linear algebra.Themost commonly used of theseare directly imported
intoblmath.numerics.blmath.numerics.vxis a namespace of common
linear algebra operations. These are easily expressed in numpy, but
abstracted for readability purposes.blmath.numerics.coercioncontains a validation
functionas_numeric_array, which produces useful error messages
up front on bad inputs, in place of cryptic messages like “cannot
broadcast…” later on.blmath.numerics.operationscontains basic
numerical operations such aszero_safe_divide.blmath.numerics.predicatescontains functions
likeisnumeric.blmath.numerics.roundingcontains functions
including “round to nearest” androundedlist.blmath.numerics.numpy_extcontains numpy utility
functions.blmath.numerics.matlabcontains some matlab shortcuts
which have no numpy equivalent. At MPI the fitting code was
originally written in Matlab before it was ported to Python.blmath.numerics.linalgcontains linear algebra operations.blmath.numerics.linalg.sparse_cgcontains a
faster matrix solve optimized for sparse Jacobians.blmath.numerics.linalg.lcholcontains a
Cythonized implementation of Cholesky factorization.blmath.numerics.linalg.isomorphismcomputes the isomorphism between two bases.blmath.numerics.linalg.gram_schmidtprovides a function for orthonormalization.blmath.geometryGeometric operations, transforms, and primitives, in 2D and 3D.Themost commonly used of theseare directly imported
intoblmath.geometry.blmath.geometry.Boxrepresents an
axis-aligned cuboid.blmath.geometry.Planerepresents a 2-D
plane in 3-space (not a hyperplane).blmath.geometry.Polylinerepresents an
unconstrained polygonal chain in 3-space.blmath.geometry.transformincludes code for 3D transforms.blmath.geometry.transform.CompositeTransformrepresents a composite transform using homogeneous coordinates.
(Thanks avd!)blmath.geometry.transform.CoordinateManagerprovides a convenient interface for named reference frames within a
stack of transforms and projecting points from one reference frame to
another.blmath.geometry.transform.find_rigid_transformfinds a rotation and translation that closely transforms one set of
points to another. Its cousinfind_rigid_rotationdoes the same,
but only allows rotation, not translation.blmath.geometry.transform.rotation.rotation_from_up_and_lookproduces a rotation matrix that gets a mesh into the canonical
reference frame from “up” and “look” vectors.Other modules:blmath.geometry.apexprovides functions for finding the
most extreme point.blmath.geometry.barycentricprovides a function
for projecting a point to a triangle using barycentric coordinates.blmath.geometry.convexifyprovides a function for
producing a convex hull from a mostly-planar curve.blmath.geometry.segmentprovides functions for
working with line segments in n-space.blmath.valueClass for wrapping and manipulatingvalue/unitspairs.blmath.unitsTODO write something hereblmath.consoleblmath.console.input_floatreads and returns a float
from console.blmath.console.input_valuecombinesunitswith a
float input from console and returnsValueobject.Developmentpipinstall-rrequirements_dev.txtpipinstall-e.# builds the native extensionrakeunittestrakelintTests are configured to run in both python 2.7 and 3.6 locally via tox
as well as in CircleCI. To run tests in multiple versions of python, runtox:pipinstall-rrequirements_dev.txttoxYou need to make sure thatpython2.7andpython3.6are valid
commands; this can be done in pyenv viapyenv global 3.6.5 2.7.15ContributeIssue Tracker:https://github.com/lace/blmath/issuesSource Code:https://github.com/lace/blmathPull requests welcome!SupportIf you are having issues, please let us know.AcknowledgementsThis collection was developed at Body Labs and includes a combination of
code developed at Body Labs, from legacy code and significant new
portions byEric Rachlin,Alex
Weiss, andPaul
Melnikow. It was extracted from the
Body Labs codebase and open-sourced byAlex
Weiss. In 2018 it wasforked by Paul
Melnikowand published asmetablmath. Thanks to a
repository and package transfer from Body Labs, the fork has been merged
back into the original.LicenseThe project is licensed under the two-clause BSD license.