当前位置: 首页>>代码示例>>Python>>正文


Python transforms.rotate函数代码示例

本文整理汇总了Python中vispy.util.transforms.rotate函数的典型用法代码示例。如果您正苦于以下问题:Python rotate函数的具体用法?Python rotate怎么用?Python rotate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了rotate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: on_timer

 def on_timer(self, event):
     self.theta += .11
     self.phi += .13
     self.model = np.dot(rotate(self.theta, (0, 0, 1)),
                         rotate(self.phi, (0, 1, 0)))
     self.program['u_model'] = self.model
     self.update()
开发者ID:Calvarez20,项目名称:vispy,代码行数:7,代码来源:galaxy.py

示例2: on_key_press

	def on_key_press(self, event):
		if event.text == 'k':
			self.model = np.dot(rotate(0.5, (0, 1, 0)), self.model)
			self.program['u_model'] = self.model

		if event.text == 'h' :
			self.theta -= .5
			self.model = np.dot(rotate(-0.5, (0, 1, 0)), self.model)
			self.program['u_model'] = self.model

		if event.text == 'u' :
			self.phi += .5
			self.model = np.dot(rotate(0.5, (1, 0, 0)), self.model)
			self.program['u_model'] = self.model

		if event.text == 'j' :
			self.phi -= .5
			self.model = np.dot(rotate(-0.5, (1, 0, 0)), self.model)
			self.program['u_model'] = self.model

		if event.text == 'r':
			self.phi = 0
			self.theta = 0
			self.model = np.eye(4, dtype=np.float32)
			self.program['u_model'] = self.model

		self.camera.onKeyPress(event)
		self.camera.update()
开发者ID:fesoliveira014,项目名称:proceduralpaper,代码行数:28,代码来源:renderer.py

示例3: test_transforms

def test_transforms():
    """Test basic transforms"""
    xfm = np.random.randn(4, 4).astype(np.float32)

    for rot in [xrotate, yrotate, zrotate]:
        new_xfm = rot(rot(xfm, 90), -90)
        assert_allclose(xfm, new_xfm)

    new_xfm = rotate(rotate(xfm, 90, 1, 0, 0), 90, -1, 0, 0)
    assert_allclose(xfm, new_xfm)

    new_xfm = translate(translate(xfm, 1, -1), 1, -1, 1)
    assert_allclose(xfm, new_xfm)

    new_xfm = scale(scale(xfm, 1, 2, 3), 1, 1. / 2., 1. / 3.)
    assert_allclose(xfm, new_xfm)

    # These could be more complex...
    xfm = ortho(-1, 1, -1, 1, -1, 1)
    assert_equal(xfm.shape, (4, 4))

    xfm = frustum(-1, 1, -1, 1, -1, 1)
    assert_equal(xfm.shape, (4, 4))

    xfm = perspective(1, 1, -1, 1)
    assert_equal(xfm.shape, (4, 4))
开发者ID:almarklein,项目名称:vispy,代码行数:26,代码来源:test_transforms.py

示例4: update_matrices

 def update_matrices(self):
     self.view = translate((0, 0, -self.translate))
     self.model = np.dot(rotate(self.theta, (1, 0, 0)), rotate(self.phi, (0, 1, 0)))
     self.projection = np.eye(4, dtype=np.float32)
     self.program["u_model"] = self.model
     self.program["u_view"] = self.view
     self.program["u_normal"] = np.linalg.inv(np.dot(self.view, self.model)).T
开发者ID:ringw,项目名称:vispy,代码行数:7,代码来源:brain.py

示例5: on_timer

 def on_timer(self, event):
     self.theta += .005
     self.phi += .005
     self.model = rotate(self.phi, (0, 1, 0)) * rotate(self.theta, (0, 0, 1))
     
     self.program['u_model'] = self.model
     self.update()
开发者ID:rreilink,项目名称:vispy,代码行数:7,代码来源:molecular_viewer.py

示例6: view

 def view(self, z=5, theta=0.0, phi=0.0):
     """ change the zoom factor and view point """
     self.program['u_view'] = translate((0, 0, -self.z))
     model = np.dot(rotate(self.theta, (0, 1, 0)),
                    rotate(self.phi, (0, 0, 1)))
     self.program['u_model'] = model
     self.update()
开发者ID:cawasthi,项目名称:vispy-tutorial,代码行数:7,代码来源:tetplot-gloo.py

示例7: test_transforms

def test_transforms():
    """Test basic transforms"""
    xfm = np.random.randn(4, 4).astype(np.float32)

    # Do a series of rotations that should end up into the same orientation
    # again, to ensure the order of computation is all correct
    # i.e. if rotated would return the transposed matrix this would not work
    # out (the translation part would be incorrect)
    new_xfm = xfm.dot(rotate(180, (1, 0, 0)).dot(rotate(-90, (0, 1, 0))))
    new_xfm = new_xfm.dot(rotate(90, (0, 0, 1)).dot(rotate(90, (0, 1, 0))))
    new_xfm = new_xfm.dot(rotate(90, (1, 0, 0)))
    assert_allclose(xfm, new_xfm)

    new_xfm = translate((1, -1, 1)).dot(translate((-1, 1, -1))).dot(xfm)
    assert_allclose(xfm, new_xfm)

    new_xfm = scale((1, 2, 3)).dot(scale((1, 1. / 2., 1. / 3.))).dot(xfm)
    assert_allclose(xfm, new_xfm)

    # These could be more complex...
    xfm = ortho(-1, 1, -1, 1, -1, 1)
    assert_equal(xfm.shape, (4, 4))

    xfm = frustum(-1, 1, -1, 1, -1, 1)
    assert_equal(xfm.shape, (4, 4))

    xfm = perspective(1, 1, -1, 1)
    assert_equal(xfm.shape, (4, 4))
开发者ID:Eric89GXL,项目名称:vispy,代码行数:28,代码来源:test_transforms.py

示例8: update_transforms

 def update_transforms(self, event):
     self.theta += .5
     self.phi += .5
     self.model = np.dot(rotate(self.theta, (0, 0, 1)),
                         rotate(self.phi, (0, 1, 0)))
     self.program['u_model'] = self.model
     self.update()
开发者ID:jay3sh,项目名称:vispy,代码行数:7,代码来源:glsl_sandbox_cube.py

示例9: update_transforms

 def update_transforms(self, event):
     self.theta += 0.5
     self.phi += 0.5
     self.model = np.eye(4, dtype=np.float32)
     rotate(self.model, self.theta, 0, 0, 1)
     rotate(self.model, self.phi, 0, 1, 0)
     self.program["u_model"] = self.model
     self.update()
开发者ID:per42,项目名称:vispy,代码行数:8,代码来源:glsl-sandbox-cube.py

示例10: on_timer

 def on_timer(self, event):
     self.theta += .5
     self.phi += .5
     model = np.eye(4, dtype=np.float32)
     rotate(model, self.theta, 0, 0, 1)
     rotate(model, self.phi, 0, 1, 0)
     self.cube['model'] = model
     self.update()
开发者ID:Peque,项目名称:vispy,代码行数:8,代码来源:post_processing.py

示例11: on_timer

 def on_timer(self, event):
     self.theta += .5
     self.phi += .5
     self.model = np.eye(4, dtype=np.float32)
     rotate(self.model, self.theta, 0, 0, 1)
     rotate(self.model, self.phi, 0, 1, 0)
     self.program['u_model'] = self.model
     self.update()
开发者ID:Peque,项目名称:vispy,代码行数:8,代码来源:display_lines.py

示例12: on_mouse_move

	def on_mouse_move(self, event):
		if event.is_dragging and event.button==1:
			delta = .2*(event.pos - event.last_event.pos)
			self.model = numpy.dot(self.model, rotate(delta[0], (0, 1, 0)))
			self.model = numpy.dot(self.model, rotate(delta[1], (1, 0, 0)))

			self.program['u_model'] = self.model
			self.update()
开发者ID:JKrehl,项目名称:Electrons,代码行数:8,代码来源:AtomsViewer.py

示例13: __init__

    def __init__(self):
        '''Map drawable - contains the goddamn map
        '''
        self.projection = np.eye(4)
        self.view = np.eye(4)

        self.model = scale(np.eye(4), 0.6)
        orientation_vector = (0, 1, 0)
        unit_orientation_angle = np.array(orientation_vector) / np.linalg.norm(orientation_vector)
        rotate(self.model, -30, *unit_orientation_angle)
        translate(self.model, -2.2, -2.4, -9)
        
        height, width = 5.0, 5.0  # Meters

        # Add texture coordinates
        # Rectangle of height height
        self.vertices = np.array([
            [-width / 2, -height / 2, 0],
            [ width / 2, -height / 2, 0],
            [ width / 2,  height / 2, 0],
            [-width / 2,  height / 2, 0],
        ], dtype=np.float32)

        self.tex_coords = np.array([
            [0, 1],
            [1, 1],
            [1, 0],
            [0, 0],
        ], dtype=np.float32)

        self.indices = IndexBuffer([
            0, 1, 2,
            2, 3, 0,
        ])

        ###### TESTING
        self.position_lla = self.ecef2llh((738575.65, -5498374.10, 3136355.42))
        ###### TESTING

        self.map, self.ranges = self.cache_map(self.position_lla[:2])
        self.map, self.ranges = self.get_map(self.position_lla[:2])
        self.program = Program(self.frame_vertex_shader, self.frame_frag_shader)

        default_map_transform = np.eye(4)

        self.program['vertex_position'] = self.vertices
        self.program['default_texcoord'] = self.tex_coords
        self.program['zoom'] = 1
        self.program['view'] = self.view
        self.program['model'] = self.model
        self.program['projection'] = self.projection

        self.program['map_transform'] = default_map_transform
        self.program['map_center'] = self.position_lla[:2]
        self.program['map_texture'] = self.map
        self.program['corners'] = self.ranges
        self.program['user_position'] = self.position_lla[:2]
        self.program['hide'] = 0
开发者ID:jpanikulam,项目名称:visar,代码行数:58,代码来源:map.py

示例14: on_timer

 def on_timer(self,event):
     self.timer_t += self.timer_dt # keep track on the current time
     self.theta += self.rotate_theta_speed
     self.phi += self.rotate_phi_speed
     self.model = np.eye(4, dtype=np.float32)
     rotate(self.model, self.theta, 0,0,1)
     rotate(self.model, self.phi,   0,1,0)
     self.program['u_model'] = self.model
     self.update()
开发者ID:PennyQ,项目名称:nbhdf5,代码行数:9,代码来源:nb6_h5_viewer.py

示例15: on_timer

 def on_timer(self, event):
     self.theta += .5
     self.phi += .5
     model = np.dot(rotate(self.theta, (0, 0, 1)),
                    rotate(self.phi, (0, 1, 0)))
     normal = np.linalg.inv(np.dot(self.view, model)).T
     self.program['u_model'] = model
     self.program['u_normal'] = normal
     self.update()
开发者ID:Lx37,项目名称:vispy,代码行数:9,代码来源:lighted_cube.py


注:本文中的vispy.util.transforms.rotate函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。