Geometry Toolbox

A geometry toolbox.

Available Functions

>>> from pymedphys.geometry import cubify_cube_definition, plot_cube

API

pymedphys.geometry.cubify_cube_definition(cube_definition)[source]

Convertes a set of 3-D points into the vertices that define a cube.

Each point is defined as a length 3 tuple.

Parameters:
cube_definition : str

A list containing three 3-D points.

cube_definition[0]: The origin of the cube.
cube_definition[1]: Point that primarily determines the cube edge lengths.
cube_definition[2]: Point that primarily defines the cube rotation.
Returns:
final_points

A list containing four 3-D points on the vertices of a cube.

Examples

>>> import numpy as np
>>> from pymedphys.geometry import cubify_cube_definition
>>>
>>> cube_definition = [(0, 0, 0), (0, 1, 0), (0, 0, 1)]
>>> np.array(cubify_cube_definition(cube_definition))
array([[0., 0., 0.],
       [0., 1., 0.],
       [0., 0., 1.],
       [1., 0., 0.]])

The second point has primary control over the resulting edge lengths.

>>> cube_definition = [(0, 0, 0), (0, 3, 0), (0, 0, 1)]
>>> np.array(cubify_cube_definition(cube_definition))
array([[0., 0., 0.],
       [0., 3., 0.],
       [0., 0., 3.],
       [3., 0., 0.]])

The third point has control over the final cube rotation.

>>> cube_definition = [(0, 0, 0), (0, 1, 0), (1, 0, 0)]
>>> np.array(cubify_cube_definition(cube_definition))
array([[ 0.,  0.,  0.],
       [ 0.,  1.,  0.],
       [ 1.,  0.,  0.],
       [ 0.,  0., -1.]])
pymedphys.geometry.plot_cube(cube_definition)[source]