當前位置: 首頁>>代碼示例>>Python>>正文


Python vtk.vtkMatrix4x4方法代碼示例

本文整理匯總了Python中vtk.vtkMatrix4x4方法的典型用法代碼示例。如果您正苦於以下問題:Python vtk.vtkMatrix4x4方法的具體用法?Python vtk.vtkMatrix4x4怎麽用?Python vtk.vtkMatrix4x4使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在vtk的用法示例。


在下文中一共展示了vtk.vtkMatrix4x4方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: scale_point

# 需要導入模塊: import vtk [as 別名]
# 或者: from vtk import vtkMatrix4x4 [as 別名]
def scale_point(camera, point, invert=False):
    """Scale a point using the camera's transform matrix.

    Parameters
    ----------
    camera : vtk.vtkCamera
        The camera who's matrix to use.

    point : tuple(float)
        Length 3 tuple of the point coordinates.

    invert : bool
        If True, invert the matrix to transform the point out of the
        camera's transformed space. Default is False to transform a
        point from world coordinates to the camera's transformed space.

    """
    if invert:
        mtx = vtk.vtkMatrix4x4()
        mtx.DeepCopy(camera.GetModelTransformMatrix())
        mtx.Invert()
    else:
        mtx = camera.GetModelTransformMatrix()
    scaled = mtx.MultiplyDoublePoint((point[0], point[1], point[2], 0.0))
    return (scaled[0], scaled[1], scaled[2]) 
開發者ID:pyvista,項目名稱:pyvista,代碼行數:27,代碼來源:renderer.py

示例2: move

# 需要導入模塊: import vtk [as 別名]
# 或者: from vtk import vtkMatrix4x4 [as 別名]
def move(actor, matrix):
    transfo_mat = vtk.vtkMatrix4x4()
    for i in range(0,4):
        for j in range(0,4):
            transfo_mat.SetElement(i,j, matrix[i,j])        
    actor.SetUserMatrix(transfo_mat) 
開發者ID:curiale,項目名稱:Medical-Image-Analysis-IPython-Tutorials,代碼行數:8,代碼來源:volumerendering.py

示例3: np2vtk

# 需要導入模塊: import vtk [as 別名]
# 或者: from vtk import vtkMatrix4x4 [as 別名]
def np2vtk(mat):
    if mat.shape == (4, 4):
        obj = vtk.vtkMatrix4x4()
        for i in range(4):
            for j in range(4):
                obj.SetElement(i, j, mat[i, j])
        return obj


# ---------------------------------------------------------------------------------------# 
開發者ID:adityadua24,項目名稱:robopy,代碼行數:12,代碼來源:transforms.py

示例4: transform

# 需要導入模塊: import vtk [as 別名]
# 或者: from vtk import vtkMatrix4x4 [as 別名]
def transform(self, trans):
        """Compute a transformation in place using a 4x4 transform.

        Parameters
        ----------
        trans : vtk.vtkMatrix4x4, vtk.vtkTransform, or np.ndarray
            Accepts a vtk transformation object or a 4x4 transformation matrix.

        """
        if isinstance(trans, vtk.vtkMatrix4x4):
            t = pyvista.trans_from_matrix(trans)
        elif isinstance(trans, vtk.vtkTransform):
            t = pyvista.trans_from_matrix(trans.GetMatrix())
        elif isinstance(trans, np.ndarray):
            if trans.ndim != 2:
                raise ValueError('Transformation array must be 4x4')
            elif trans.shape[0] != 4 or trans.shape[1] != 4:
                raise ValueError('Transformation array must be 4x4')
            t = trans
        else:
            raise TypeError('Input transform must be either:\n'
                            '\tvtk.vtkMatrix4x4\n'
                            '\tvtk.vtkTransform\n'
                            '\t4x4 np.ndarray\n')

        x = (self.points*t[0, :3]).sum(1) + t[0, -1]
        y = (self.points*t[1, :3]).sum(1) + t[1, -1]
        z = (self.points*t[2, :3]).sum(1) + t[2, -1]

        # overwrite points
        self.points[:, 0] = x
        self.points[:, 1] = y
        self.points[:, 2] = z 
開發者ID:pyvista,項目名稱:pyvista,代碼行數:35,代碼來源:common.py

示例5: _array2vtkTransform

# 需要導入模塊: import vtk [as 別名]
# 或者: from vtk import vtkMatrix4x4 [as 別名]
def _array2vtkTransform(self, arr):
        T = vtk.vtkTransform()
        matrix = vtk.vtkMatrix4x4()
        for i in range(0, 4):
            for j in range(0, 4):
                matrix.SetElement(i, j, arr[i, j])
        T.SetMatrix(matrix)
        return T 
開發者ID:poodarchu,項目名稱:Det3D,代碼行數:10,代碼來源:visualizercontrol.py


注:本文中的vtk.vtkMatrix4x4方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。