parameters: (transformNode, narray, toWorld = False)
docstring: Set transformation matrix from a numpy array of size 4x4 (toParent).
  
    :param world: if set to True then the transform will be set so that transform
      to world matrix will be equal to narray; otherwise transform to parent will be
      set as narray.
    :raises RuntimeError: in case of failure
docstring_summary: Set transformation matrix from a numpy array of size 4x4 (toParent).
docstring_tokens: Set transformation matrix from a numpy array of size 4x4 ( toParent ) .
function: def updateTransformMatrixFromArray(transformNode, narray, toWorld = False):
    """Set transformation matrix from a numpy array of size 4x4 (toParent).
  
    :param world: if set to True then the transform will be set so that transform
      to world matrix will be equal to narray; otherwise transform to parent will be
      set as narray.
    :raises RuntimeError: in case of failure
    """
    import numpy as np
    from vtk import vtkMatrix4x4
    narrayshape = narray.shape
    if narrayshape != (4,4):
      raise RuntimeError("Unsupported numpy array shape: "+str(narrayshape)+" expected (4,4)")
    if toWorld and transformNode.GetParentTransformNode():
      # thisToParent = worldToParent * thisToWorld = inv(parentToWorld) * toWorld
      narrayParentToWorld = arrayFromTransformMatrix(transformNode.GetParentTransformNode())
      thisToParent = np.dot(np.linalg.inv(narrayParentToWorld), narray)
      updateTransformMatrixFromArray(transformNode, thisToParent, toWorld = False)
    else:
      vmatrix = vtkMatrix4x4()
      updateVTKMatrixFromArray(vmatrix, narray)
      transformNode.SetMatrixTransformToParent(vmatrix)
function_tokens: def updateTransformMatrixFromArray ( transformNode , narray , toWorld = False ) : import numpy as np from vtk import vtkMatrix4x4 narrayshape = narray . shape if narrayshape != ( 4 , 4 ) : raise RuntimeError ( "Unsupported numpy array shape: " + str ( narrayshape ) + " expected (4,4)" ) if toWorld and transformNode . GetParentTransformNode ( ) : # thisToParent = worldToParent * thisToWorld = inv(parentToWorld) * toWorld narrayParentToWorld = arrayFromTransformMatrix ( transformNode . GetParentTransformNode ( ) ) thisToParent = np . dot ( np . linalg . inv ( narrayParentToWorld ) , narray ) updateTransformMatrixFromArray ( transformNode , thisToParent , toWorld = False ) else : vmatrix = vtkMatrix4x4 ( ) updateVTKMatrixFromArray ( vmatrix , narray ) transformNode . SetMatrixTransformToParent ( vmatrix )