本文整理汇总了Python中mathutils.Matrix.copy方法的典型用法代码示例。如果您正苦于以下问题:Python Matrix.copy方法的具体用法?Python Matrix.copy怎么用?Python Matrix.copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mathutils.Matrix
的用法示例。
在下文中一共展示了Matrix.copy方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getmat
# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import copy [as 别名]
def getmat(bone, active, context, ignoreparent):
'''Helper function for visual transform copy,
gets the active transform in bone space
'''
data_bone = context.active_object.data.bones[bone.name]
#all matrices are in armature space unless commented otherwise
otherloc = active.matrix # final 4x4 mat of target, location.
bonemat_local = Matrix(data_bone.matrix_local) # self rest matrix
if data_bone.parent:
parentposemat = Matrix(
context.active_object.pose.bones[data_bone.parent.name].matrix)
parentbonemat = Matrix(data_bone.parent.matrix_local)
else:
parentposemat = bonemat_local.copy()
parentbonemat = bonemat_local.copy()
# FIXME! why copy from the parent if setting identity ?, Campbell
parentposemat.identity()
parentbonemat.identity()
if parentbonemat == parentposemat or ignoreparent:
newmat = bonemat_local.inverted() * otherloc
else:
bonemat = parentbonemat.inverted() * bonemat_local
newmat = bonemat.inverted() * parentposemat.inverted() * otherloc
return newmat
示例2: getWorld
# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import copy [as 别名]
def getWorld(self):
t = Vector(self.translation).to_4d()
mr = Matrix()
for row in range(3):
mr[row][0:3] = self.rotation[row]
mr.transpose() # = Inverse rotation
p = -(mr * t) # Camera position in world coordinates
p[3] = 1.0
m = mr.copy()
m.col[3] = p # Set translation to camera position
return m
示例3: test_matrix_inverse_safe
# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import copy [as 别名]
def test_matrix_inverse_safe(self):
mat = Matrix(((1, 4, 0, -1),
(2, -1, 0, -2),
(0, 3, 0, 3),
(-2, 9, 0, 0)))
# Warning, if we change epsilon in py api we have to update this!!!
epsilon = 1e-8
inv_mat_safe = mat.copy()
inv_mat_safe[0][0] += epsilon
inv_mat_safe[1][1] += epsilon
inv_mat_safe[2][2] += epsilon
inv_mat_safe[3][3] += epsilon
inv_mat_safe.invert()
'''
inv_mat_safe = Matrix(((1.0, -0.5, 0.0, -0.5),
(0.222222, -0.111111, -0.0, 0.0),
(-333333344.0, 316666656.0, 100000000.0, 150000000.0),
(0.888888, -0.9444444, 0.0, -0.5)))
'''
self.assertEqual(mat.inverted_safe(), inv_mat_safe)
示例4: Line
# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import copy [as 别名]
class Line(Projection):
"""
2d Line
Internally stored as p: origin and v:size and direction
moving p will move both ends of line
moving p0 or p1 move only one end of line
p1
^
| v
p0 == p
"""
def __init__(self, p=None, v=None, p0=None, p1=None):
"""
Init by either
p: Vector or tuple origin
v: Vector or tuple size and direction
or
p0: Vector or tuple 1 point location
p1: Vector or tuple 2 point location
Will convert any into Vector 2d
both optionnals
"""
Projection.__init__(self)
if p is not None and v is not None:
self.p = Vector(p).to_2d()
self.v = Vector(v).to_2d()
elif p0 is not None and p1 is not None:
self.p = Vector(p0).to_2d()
self.v = Vector(p1).to_2d() - self.p
else:
self.p = Vector((0, 0))
self.v = Vector((0, 0))
self.line = None
@property
def copy(self):
return Line(self.p.copy(), self.v.copy())
@property
def p0(self):
return self.p
@property
def p1(self):
return self.p + self.v
@p0.setter
def p0(self, p0):
"""
Note: setting p0
move p0 only
"""
p1 = self.p1
self.p = Vector(p0).to_2d()
self.v = p1 - p0
@p1.setter
def p1(self, p1):
"""
Note: setting p1
move p1 only
"""
self.v = Vector(p1).to_2d() - self.p
@property
def length(self):
"""
3d length
"""
return self.v.length
@property
def angle(self):
"""
2d angle on xy plane
"""
return atan2(self.v.y, self.v.x)
@property
def a0(self):
return self.angle
@property
def angle_normal(self):
"""
2d angle of perpendicular
lie on the right side
p1
|--x
p0
"""
return atan2(-self.v.x, self.v.y)
@property
def reversed(self):
return Line(self.p, -self.v)
@property
def oposite(self):
return Line(self.p + self.v, -self.v)
#.........这里部分代码省略.........