get_bounds_fit_matrix#

k3d.transform.get_bounds_fit_matrix(xmin, xmax, ymin, ymax, zmin, zmax)[source]#

Return a 4x4 transform matrix.

Map the default bounding box [-0.5, 0.5, -0.5, 0.5, -0.5, 0.5] into a custom bounding box [xmin, xmax, ymin, ymax, zmin, zmax].

Parameters
  • xmin (float) – Lower x bound.

  • xmax (float) – Upper x bound.

  • ymin (float) – Lower y bound.

  • ymax (float) – Upper y bound.

  • zmin (float) – Lower z bound.

  • zmax (float) – Upper z bound.

Returns

Transform matrix.

Return type

ndarray

Raises

TypeError – Expected float.

Examples#

from k3d.transform import get_bounds_fit_matrix

bfm = get_bounds_fit_matrix(0, 1, -1, 1, 2, 4)

"""
array([[1. , 0. , 0. , 0.5],
       [0. , 2. , 0. , 0. ],
       [0. , 0. , 2. , 3. ],
       [0. , 0. , 0. , 1. ]], dtype=float32)
"""