当前位置: 首页>>代码示例>>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;未经允许,请勿转载。