get_bounds_fit_matrix#

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

Return a 4x4 transform matrix mapping the default bounding box [-0.5, 0.5, …] into a custom bounding box.

Parameters:
  • xmin (float) – Bounds for the target box.

  • xmax (float) – Bounds for the target box.

  • ymin (float) – Bounds for the target box.

  • ymax (float) – Bounds for the target box.

  • zmin (float) – Bounds for the target box.

  • zmax (float) – Bounds for the target box.

Returns:

4x4 transformation matrix.

Return type:

ndarray

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)
"""