• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python transforms.rotate函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: on_timer

 def on_timer(self, event):
     if not self.stop_rotation:
         self.theta += .02
         self.phi += .02
         self.model = rotate(self.phi, (0, 1, 0)) * rotate(self.theta, (0, 0, 1))
         self.program['u_model'] = self.model
     self.clock += np.pi / 1000
     self.program['u_clock'] = self.clock
     self.update()
开发者ID:rreilink,项目名称:vispy,代码行数:9,代码来源:donut.py


示例17: adjust_rotate

    def adjust_rotate(self, event):
        """Adjust rotation of rendered data."""
        sign = {'Up':-1, 'Left':-1, ']':-1, '}':-1}.get(event.key, 1)

        print 'adjust_rotate %s' % event

        if event.key == 'S':
            # stop auto-rotate
            self.auto_rotate_X_angle = 0.0
            self.auto_rotate_Y_angle = 0.0
            self.auto_rotate_Z_angle = 0.0
            self.auto_rotate_X_speed = 0
            self.auto_rotate_Y_speed = 0
            self.auto_rotate_Z_speed = 0

            if self._timer is not None:
                self._timer.stop()
                self._timer = None

        elif 'Shift' in event.modifiers:
            # adjust auto-rotation speed in small increments
            if event.key in ('Right', 'Left'):
                self.auto_rotate_Y_speed += sign
            elif event.key in ('Up', 'Down'):
                self.auto_rotate_X_speed += sign
            elif event.key in ('[', ']', '{', '}'):
                self.auto_rotate_Z_speed += sign

            if self.auto_rotate_Z_speed != 0.0 \
                    or self.auto_rotate_Y_speed != 0.0 \
                    or self.auto_rotate_X_speed != 0.0:
                if self._timer is None:
                    print 'starting timer'
                    self._timer = app.Timer('auto', connect=self.on_timer, start=True)
            else:
                if self._timer is not None:
                    print 'stopping timer'
                    self._timer.stop()
                    self._timer = None
        else:
            # just apply a single small rotation increment
            axis = {
                'Up': (1, 0, 0), 
                'Down': (1, 0, 0), 
                'Left': (0, 1, 0),
                'Right': (0, 1, 0),
                '[': (0, 0, 1),
                ']': (0, 0, 1)
                }[event.key]

            angle = 2 * sign

            rotate(*(self.rotation, angle) + axis)
            rotate(*(self.anti_rotation, -angle) + axis)

            self.update_view()
开发者ID:tacyd,项目名称:volspy,代码行数:56,代码来源:viewer.py


示例18: timer

def timer(fps):
    global theta, phi
    theta += 0.5
    phi += 0.5
    model = np.eye(4, dtype=np.float32)
    rotate(model, theta, 0, 0, 1)
    rotate(model, phi, 0, 1, 0)
    program["model"] = model
    glut.glutTimerFunc(1000 / fps, timer, fps)
    glut.glutPostRedisplay()
开发者ID:tatak,项目名称:experimental,代码行数:10,代码来源:server.py


示例19: update_matrices

    def update_matrices(self):
        self.view = translate((0, 0, -self.translate))
        self.model = rotate(self.phi, (0,1,0)) * rotate(self.theta, (0, 0, 1))
        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.array(np.matrix(np.dot(self.view, 
                                                             self.model)).I.T)
开发者ID:rreilink,项目名称:vispy,代码行数:10,代码来源:brain.py


示例20: on_timer

 def on_timer(self, event):
     self.theta += 0.5
     self.phi += 0.5
     model = np.eye(4, dtype=np.float32)
     rotate(model, self.theta, 0, 0, 1)
     rotate(model, self.phi, 0, 1, 0)
     normal = np.array(np.matrix(np.dot(self.view, model)).I.T)
     self.program["u_model"] = model
     self.program["u_normal"] = normal
     self.update()
开发者ID:rossant,项目名称:vispy,代码行数:10,代码来源:lighted_cube.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python transforms.translate函数代码示例发布时间:2022-05-26
下一篇:
Python transforms.perspective函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap