本文整理汇总了Python中mathutils.Matrix.to_translation方法的典型用法代码示例。如果您正苦于以下问题:Python Matrix.to_translation方法的具体用法?Python Matrix.to_translation怎么用?Python Matrix.to_translation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mathutils.Matrix
的用法示例。
在下文中一共展示了Matrix.to_translation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mirrorPlane
# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import to_translation [as 别名]
def mirrorPlane(vertex, matrix):
vert = []
a = Matrix(matrix)
eul = a.to_euler()
normal = Vector((0.0, 0.0, 1.0))
normal.rotate(eul)
tras = Matrix.Translation(2*a.to_translation())
for i in vertex:
v = Vector(i)
r = v.reflect(normal)
vert.append((tras*r)[:])
return vert
示例2: transformToLocal
# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import to_translation [as 别名]
def transformToLocal(vec:Vector, mat:Matrix, junk_bme:bmesh=None):
""" transfrom vector to local space of 'mat' matrix """
# decompose matrix
loc = mat.to_translation()
rot = mat.to_euler()
scale = mat.to_scale()[0]
# apply scale
vec = vec / scale
# apply rotation
if rot != Euler((0, 0, 0), "XYZ"):
junk_bme = bmesh.new() if junk_bme is None else junk_bme
v1 = junk_bme.verts.new(vec)
bmesh.ops.rotate(junk_bme, verts=[v1], cent=loc, matrix=Matrix.Rotation(-rot.z, 3, 'Z'))
bmesh.ops.rotate(junk_bme, verts=[v1], cent=loc, matrix=Matrix.Rotation(-rot.y, 3, 'Y'))
bmesh.ops.rotate(junk_bme, verts=[v1], cent=loc, matrix=Matrix.Rotation(-rot.x, 3, 'X'))
vec = v1.co
return vec
示例3: test_matrix_to_translation
# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import to_translation [as 别名]
def test_matrix_to_translation(self):
mat = Matrix()
mat[0][3] = 1
mat[1][3] = 2
mat[2][3] = 3
self.assertEqual(mat.to_translation(), Vector((1, 2, 3)))