Package: metablmath
This is an active fork ofblmath, a collection
math-related utilities developed at Body Labs.The fork’s goals are moderate: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.Add additional functionality which relates well to what is here.Respond to community contributions.It’s used by related forks such aslace.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 librarypipinstallmetablmathAnd 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 extensionrakeunittestrakelintContributeIssue Tracker:https://github.com/metabolize/blmath/issuesSource Code:https://github.com/metabolize/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.LicenseThe project is licensed under the two-clause BSD license.