本文整理汇总了Python中matrix.Matrix.scale方法的典型用法代码示例。如果您正苦于以下问题:Python Matrix.scale方法的具体用法?Python Matrix.scale怎么用?Python Matrix.scale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matrix.Matrix
的用法示例。
在下文中一共展示了Matrix.scale方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: scale
# 需要导入模块: from matrix import Matrix [as 别名]
# 或者: from matrix.Matrix import scale [as 别名]
def scale(self):
self.lines.pop(0) # Remove 'l"
arguments = self.lines.pop(0) # Get Arguments
# "Listify" Arguments
arguments = arguments.split(" ")
# Create Scale Matrix
temp = Matrix()
temp.scale( float( arguments[0] ),
float( arguments[1] ),
float( arguments[2] ) )
# Apply to MASTER matrix
self.master.multiply_forwards(temp)
示例2: test_scale
# 需要导入模块: from matrix import Matrix [as 别名]
# 或者: from matrix.Matrix import scale [as 别名]
def test_scale(self):
m = Matrix()
m = m.scale(scale_x=2, scale_y=3)
expected = [[2, 0, 0],
[0, 3, 0],
[0, 0, 1]]
self.compareMatrix(m.matrix, expected)
示例3: __init__
# 需要导入模块: from matrix import Matrix [as 别名]
# 或者: from matrix.Matrix import scale [as 别名]
class Transform:
def __init__(self):
self.position = [0.0, 0.0, 0.0, 0.0]
self.rotation = [0.0, 0.0, 0.0, 1.0]
self.scale = [1.0, 1.0, 1.0]
self.matrix = Matrix()
def setMatrix(self):
self.position = self.matrix.pos_component()
def getMatrix(self):
self.matrix.ident()
self.matrix.scale(self.scale)
quat = Matrix()
quat.set_quat(self.rotation)
self.matrix.mult_simple(quat)
self.matrix.translate(self.position)
#-------------------------------------------------------------------------------
# Eof
#-------------------------------------------------------------------------------
示例4: test_combine
# 需要导入模块: from matrix import Matrix [as 别名]
# 或者: from matrix.Matrix import scale [as 别名]
def test_combine(self):
m = Matrix()
# rotate 90 degrees CCW
m = m.translate(x=4, y=-2)
m = m.rotate_ccw(math.pi / 2)
m = m.scale(scale_x=2, scale_y=3)
expected = [[2, -1, 4],
[1, 3, -2],
[0, 0, 1]]
self.compareMatrix(m.matrix, expected)
示例5: draw_mesh
# 需要导入模块: from matrix import Matrix [as 别名]
# 或者: from matrix.Matrix import scale [as 别名]
def draw_mesh(self, mesh: Mesh):
camera_position = Vector(0, 0, -10)
camera_target = Vector(0, 0, 0)
camera_up = Vector(0, 1, 0)
view = Matrix.lookAtLH(camera_position, camera_target, camera_up)
projection = Matrix.perspectiveFovLH(radians(45), self.width / self.height, 0.1, 1)
rotation = Matrix.rotation(mesh.rotation)
translation = Matrix.translation(mesh.position)
scale = Matrix.scale(mesh.scale)
world = scale * rotation * translation
transform = world * view * projection
for i in range(0, len(mesh.indices), 3):
a = mesh.vertices[mesh.indices[i]]
b = mesh.vertices[mesh.indices[i + 1]]
c = mesh.vertices[mesh.indices[i + 2]]
v1 = self.project(a, transform)
v2 = self.project(b, transform)
v3 = self.project(c, transform)
self.draw_triangle(v1, v2, v3, mesh.texture)