OpenCMISS Maths

OpenCMISS Maths is a Python package containing math utility functions. These utility functions are general utilities commonly used by downstream packages.

This package provides two modules

  1. vectorops

  2. algorithms

These modules are surfaced under the namespace package opencmiss within the maths package. To use these modules the following import statement can be used:

import opencmiss.maths.vectorops
import opencmiss.maths.algorithms

Vector Operations

The vectorops module is a collection of functions that operate on python lists as if they were vectors. A basic implementation to forgo the need to use numpy.

Algorithms

The algorithms module is a collection of functions that perform calculations on python lists. These functions are commonly used in other OpenCMISS packages.

Package API

Vector Operations Module

A collection of functions that operate on python lists as if they were vectors. A basic implementation to forgo the need to use numpy.

opencmiss.maths.vectorops.axis_angle_to_quaternion(axis, angle)
Parameters
  • axis – Unit vector axis of rotation.

  • angle – Angle of rotation in right hand sense around axis, in radians.

Returns

Quaternion representing rotation.

opencmiss.maths.vectorops.axis_angle_to_rotation_matrix(axis, angle)
Parameters
  • axis – Unit vector axis of rotation.

  • angle – Angle of rotation in right hand sense around axis, in radians.

Returns

3x3 rotation matrix suitable for pre-multiplying vector v:

i.e. v’ = Mv

opencmiss.maths.vectorops.euler_to_rotation_matrix(euler_angles)

From OpenCMISS-Zinc graphics_library.cpp, with matrix transposed to row major. Matrix is product RzRyRx, giving rotation about x, then y, then z with positive angles rotating by right hand rule about axis. :param euler_angles: 3 angles in radians, components: 0 = azimuth (about z) 1 = elevation (about y) 2 = roll (about x) :return: 3x3 rotation matrix suitable for pre-multiplying vector v: i.e. v’ = Mv

opencmiss.maths.vectorops.matrix_constant_mult(m, c)

Multiply components of matrix m by constant c

opencmiss.maths.vectorops.matrix_mult(a, b)

Multiply 2 matrices: first index is down row, second is across column. Assumes sizes are compatible (number of columns of a == number of rows of b).

opencmiss.maths.vectorops.matrix_vector_mult(m, v)

Post multiply matrix m by vector v

opencmiss.maths.vectorops.quaternion_to_rotation_matrix(quaternion)

This method takes a quaternion representing a rotation and turns it into a rotation matrix. :return: 3x3 rotation matrix suitable for pre-multiplying vector v: i.e. v’ = Mv

opencmiss.maths.vectorops.rotation_matrix_to_euler(matrix)

From OpenCMISS-Zinc graphics_library.cpp, with matrix transposed to row major. Inverse function to euler_to_rotation_matrix.

opencmiss.maths.vectorops.vector_matrix_mult(v, m)

Premultiply matrix m by vector v

Algorithms Module

opencmiss.maths.algorithms.calculateExtents(values)

Calculate the maximum and minimum for each coordinate x, y, and z Return the max’s and min’s as:

[x_min, x_max, y_min, y_max, z_min, z_max]