本文整理汇总了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])
示例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)
示例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
# ---------------------------------------------------------------------------------------#
示例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
示例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