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

Python transforms.ortho函数代码示例

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

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



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

示例1: resize

 def resize(self, width, height):
     gloo.set_viewport(0, 0, width, height)
     data_width = self._data_lim[0][1] - self._data_lim[0][0]
     data_height = self._data_lim[1][1] - self._data_lim[1][0]
     data_aspect = data_width / float(data_height)
     frame_aspect = width / float(height)
     if frame_aspect >= data_aspect:
         padding = (frame_aspect * data_height - data_width) / 2.
         frame_lim = [
             [self._data_lim[0][0] - padding,
              self._data_lim[0][1] + padding],
             [self._data_lim[1][0],
              self._data_lim[1][1]]]
     else:
         padding = (data_width / frame_aspect - data_height) / 2.
         frame_lim = [
             [self._data_lim[0][0],
              self._data_lim[0][1]],
             [self._data_lim[1][0] - padding,
              self._data_lim[1][1] + padding]]
     args_ortho = frame_lim[0][::(1 if self._dir_x_right else -1)]
     args_ortho += frame_lim[1][::(1 if self._dir_y_top else -1)]
     args_ortho += -1000, 1000
     self.projection = ortho(*args_ortho)
     self.program['projection'] = self.projection
开发者ID:Peque,项目名称:vispy,代码行数:25,代码来源:unstructured_2d.py


示例2: __init__

    def __init__(self):
        app.Canvas.__init__(self, keys='interactive', size=((W * 5), (H * 5)))

        self.program = gloo.Program(VERT_SHADER, FRAG_SHADER)
        self.texture = gloo.Texture2D(I, interpolation='linear')

        self.program['u_texture'] = self.texture
        self.program.bind(gloo.VertexBuffer(data))

        self.view = np.eye(4, dtype=np.float32)
        self.model = np.eye(4, dtype=np.float32)
        self.projection = np.eye(4, dtype=np.float32)

        self.program['u_model'] = self.model
        self.program['u_view'] = self.view
        self.projection = ortho(0, W, 0, H, -1, 1)
        self.program['u_projection'] = self.projection

        gloo.set_clear_color('white')

        self._timer = app.Timer('auto', connect=self.update, start=True)

        self.sim_is_initialized = False
        self.sim = None

        self.show()
开发者ID:btweinstein,项目名称:2d-lb,代码行数:26,代码来源:interop_test.py


示例3: toggle_projection

 def toggle_projection(self, event=None):
     """Toggle between perspective and orthonormal projection modes."""
     self.perspective = not self.perspective
     if self.perspective:
         self.volume_renderer.set_vol_projection(perspective(60, 1., 100, 0))
     else:
         self.volume_renderer.set_vol_projection(ortho(-1, 1, -1, 1, -1000, 1000))
开发者ID:tacyd,项目名称:volspy,代码行数:7,代码来源:viewer.py


示例4: __init__

    def __init__(self):
        app.Canvas.__init__(self, keys='interactive')
        self.size = W * 5, H * 5

        self.program = gloo.Program(VERT_SHADER, FRAG_SHADER)
        self.texture = gloo.Texture3D(I, interpolation='nearest',
                                      wrapping='clamp_to_edge')
        self.program['u_texture'] = self.texture
        self.program['i'] = 0.0
        self.program.bind(gloo.VertexBuffer(data))

        self.view = np.eye(4, dtype=np.float32)
        self.model = np.eye(4, dtype=np.float32)
        self.projection = np.eye(4, dtype=np.float32)

        self.program['u_model'] = self.model
        self.program['u_view'] = self.view
        self.projection = ortho(0, W, 0, H, -1, 1)
        self.program['u_projection'] = self.projection

        self.i = 0

        gloo.set_clear_color('white')

        self._timer = app.Timer('auto', connect=self.on_timer, start=True)
开发者ID:almarklein,项目名称:vispy,代码行数:25,代码来源:animate_images_slice.py


示例5: 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


示例6: on_resize

 def on_resize(self, event):
     width, height = event.size
     self.width=width
     self.height=height
     gloo.set_viewport(0, 0, width, height)
     self.projection = ortho(-self.scale/2, self.scale/2, -self.scale/2, self.scale/2, -1, 100) #perspective(1.0, width / float(height), 1.0, 10000000.0)
     self.program['u_projection'] = self.projection
开发者ID:gddickinson,项目名称:python_code,代码行数:7,代码来源:Scatter_Plot_2.py


示例7: on_mouse_wheel

 def on_mouse_wheel(self, event):
     #print(event.delta[1])
     oldscale=self.scale
     if event.delta[1]>0:
         self.scale /=event.delta[1]+1
     else:
         self.scale *= -event.delta[1]+1
     factor=self.scale/oldscale
     self.event=event
     self.projection = ortho(-self.scale/2, self.scale/2, -self.scale/2, self.scale/2, -1, 100) #perspective(1.0, width / float(height), 1.0, 10000000.0)
     self.program['u_projection'] = self.projection
     self.view = np.eye(4, dtype=np.float32)
     x,y=self.getEventCoordinates(event)
     print(factor)
     if factor<1:
         x-(x-self.pos[0])/factor
         y-(y-self.pos[1])/factor
     else:
         x=self.pos[0]-(x-self.pos[0])/factor
         y=self.pos[1]-(y-self.pos[1])/factor
     self.pos[0]=x
     self.pos[1]=y
     translate(self.view, -x, -y, -1)
     self.program['u_view'] = self.view
     self.getEventCoordinates(self.event)
     self.update()        
开发者ID:gddickinson,项目名称:python_code,代码行数:26,代码来源:Scatter_Plot_2.py


示例8: on_resize

 def on_resize(self, event):
     width, height = event.size
     gl.glViewport(0, 0, width, height)
     self.projection = ortho(0, width, 0, height, -100, 100)
     self.u_size = width / 512.0
     self.program['u_projection'] = self.projection
     self.program['u_size'] = self.u_size
开发者ID:dengemann,项目名称:vispy,代码行数:7,代码来源:show-markers.py


示例9: __init__

    def __init__(self):
        app.Canvas.__init__(self)

        # This size is used for comparison with agg (via matplotlib)
        self.size = 512, 512 + 2 * 32
        self.title = "Markers demo [press space to change marker]"

        self.vbo = VertexBuffer(data)
        self.view = np.eye(4, dtype=np.float32)
        self.model = np.eye(4, dtype=np.float32)
        self.projection = ortho(0, self.size[0], 0, self.size[1], -1, 1)
        self.programs = [
            Program(markers.vert, markers.frag + markers.tailed_arrow),
            Program(markers.vert, markers.frag + markers.disc),
            Program(markers.vert, markers.frag + markers.diamond),
            Program(markers.vert, markers.frag + markers.square),
            Program(markers.vert, markers.frag + markers.cross),
            Program(markers.vert, markers.frag + markers.arrow),
            Program(markers.vert, markers.frag + markers.vbar),
            Program(markers.vert, markers.frag + markers.hbar),
            Program(markers.vert, markers.frag + markers.clobber),
            Program(markers.vert, markers.frag + markers.ring)]

        for program in self.programs:
            program.set_vars(self.vbo,
                             u_antialias=u_antialias,
                             u_size=1,
                             u_model=self.model,
                             u_view=self.view,
                             u_projection=self.projection)
        self.index = 0
        self.program = self.programs[self.index]
开发者ID:dengemann,项目名称:vispy,代码行数:32,代码来源:show-markers.py


示例10: __init__

    def __init__(self, emulate3d=True):
        app.Canvas.__init__(self, keys='interactive', size=((W*5), (H*5)))

        if emulate3d:
            tex_cls = gloo.TextureEmulated3D
        else:
            tex_cls = gloo.Texture3D
        self.texture = tex_cls(img_array, interpolation='nearest',
                               wrapping='clamp_to_edge')

        self.program = ModularProgram(VERT_SHADER, FRAG_SHADER)
        self.program.frag['sampler_type'] = self.texture.glsl_sampler_type
        self.program.frag['sample'] = self.texture.glsl_sample
        self.program['u_texture'] = self.texture
        self.program['i'] = 0.0
        self.program.bind(gloo.VertexBuffer(data))

        self.view = np.eye(4, dtype=np.float32)
        self.model = np.eye(4, dtype=np.float32)
        self.projection = np.eye(4, dtype=np.float32)

        self.program['u_model'] = self.model
        self.program['u_view'] = self.view
        self.projection = ortho(0, W, 0, H, -1, 1)
        self.program['u_projection'] = self.projection

        self.i = 0

        gloo.set_clear_color('white')

        self._timer = app.Timer('auto', connect=self.on_timer, start=True)

        self.show()
开发者ID:Eric89GXL,项目名称:vispy,代码行数:33,代码来源:animate_images_slice.py


示例11: set_data

    def set_data(self, data):
        self.data = data

        self.xmin, self.xmax = np.nanmin(data.x_coords), np.nanmax(data.x_coords)
        self.ymin, self.ymax = np.nanmin(data.y_coords), np.nanmax(data.y_coords)
        self.zmin, self.zmax = np.nanmin(data.values), np.nanmax(data.values)

        self.cm_dx = (self.xmax-self.xmin)*0.1

        self.view = translate((0, 0, 0))
        self.projection = ortho(self.xmin, self.xmax + self.cm_dx, self.ymin, self.ymax, -1, 1)

        self.program['u_view'] = self.view
        self.program['u_projection'] = self.projection
        self.program['u_colormap'] = gloo.Texture1D(self.colormap.get_colors(), interpolation='linear')
        
        self.program_cm['u_view'] = self.view
        self.program_cm['u_projection'] = self.projection

        self.program_line['u_view'] = self.view
        self.program_line['u_projection'] = self.projection

        t0 = time.clock()
        vertices = self.generate_vertices(data)
        #print 'generate_vertices: ', time.clock()-t0
        self.vbo = gloo.VertexBuffer(vertices)
        self.program.bind(self.vbo)

        self.update()
开发者ID:majacassidy,项目名称:qtplot,代码行数:29,代码来源:canvas.py


示例12: 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


示例13: on_resize

 def on_resize(self, event):
     width, height = event.size
     gloo.set_viewport(0, 0, width, height)
     self.projection = ortho(0, width, 0, height, -100, 100)
     self.u_size = width / 512.0
     self.program["u_projection"] = self.projection
     self.program["u_size"] = self.u_size
开发者ID:Zulko,项目名称:vispy,代码行数:7,代码来源:show_markers.py


示例14: apply_zoom

	def apply_zoom(self):
		width, height = self.physical_size
		gloo.set_viewport(0, 0, width, height)
		a, b, c = .5, .5, 2
		if width>height:
			a *= width/height
		else:
			b *= height/width
		self.projection = ortho(-a, a, -b, b, -c, c)
		self.program['u_projection'] = self.projection
开发者ID:JKrehl,项目名称:Electrons,代码行数:10,代码来源:AtomsViewer.py


示例15: __init__

    def __init__(self, fragment_shader, vol_texture, num_channels, entry_texture, gain=1.0):
        gloo.Program.__init__(self, self.vert_shader, fragment_shader)

        self['u_data_texture'] = vol_texture
        self['u_projection'] = ortho(-.5, .5, -.5, .5, -100, 100)
        self.bind(self.port_verts)
        self['u_model'] = self.port_model
        self['u_view'] = np.eye(4, dtype=np.float32)
        self['u_entry_texture'] = entry_texture
        self['u_gain'] = gain
        self['u_numchannels'] = num_channels
开发者ID:tacyd,项目名称:volspy,代码行数:11,代码来源:render.py


示例16: __init__

    def __init__(self, size):
        gloo.set_viewport(0, 0, *size)

        self._size = size
        width, height = size
        self._projection_matrix = ortho(0, width, 0, height, -1, 1)
        self._state = GraphicsState()
        self._state.ctm = identity_transform.copy()
        self._state_stack = [self._state]

        self._line_renderer = LINE_RENDERER
        self._marker_renderer = MARKER_RENDERER
        self._rect_renderer = RECT_RENDERER
        self._text_renderer = TEXT_RENDERER

        self._text_pos = (0, 0)
开发者ID:tonysyu,项目名称:deli,代码行数:16,代码来源:graphics_context.py


示例17: intrinsic_to_opengl_projection

def intrinsic_to_opengl_projection(intrinsic_mat, left, right, top, bottom,
                                   near, far):
    """
    Converts intrinsic matrix to OpenGL format.
    :param intrinsic_mat: Intrinsic matrix in row-major order.
    :return: OpenGL perspective mat (including NDC matrix) in column-major
             format.
    """
    perspective_mat = np.vstack((
        np.hstack((intrinsic_mat[0, :], 0)),
        np.hstack((intrinsic_mat[1, :], 0)),
        [0, 0, near + far, near * far],
        np.hstack((intrinsic_mat[2, :], 0))
    ))
    ndc_mat = ortho(left, right, bottom, top, near, far).T

    return ndc_mat.dot(perspective_mat)
开发者ID:void42,项目名称:svbrdf-renderer,代码行数:17,代码来源:graphics_utils.py


示例18: on_resize

    def on_resize(self, event):
        width, height = event.size
        gl.glViewport(0, 0, width, height)
        self.projection = ortho( 0, width, 0, height, -100, 100 )
        self.program['u_projection'] = self.projection

        # Compute thje new size of the quad 
        r = width/float(height)
        R = W/float(H)
        if r < R:
            w,h = width, width/R
            x,y = 0, int((height-h)/2)
        else:
            w,h = height*R, height
            x,y = int((width-w)/2), 0
        data['a_position'] = np.array([[x, y], [x+w, y], [x, y+h], [x+w, y+h]])
        self.program.set_vars(oogl.VertexBuffer(data))
开发者ID:joe311,项目名称:vispy,代码行数:17,代码来源:animate-images.py


示例19: on_resize

    def on_resize(self, event):
        width, height = self.size
        gloo.set_viewport(0, 0, *event.physical_size)
        self.projection = ortho(0, width, 0, height, 0, 1)
        self.program['u_projection'] = self.projection

        # Compute the new size of the quad
        r = width / float(height)
        R = W / float(H)
        if r < R:
            w, h = width, width / R
            x, y = 0, int((height - h) / 2)
        else:
            w, h = height * R, height
            x, y = int((width - w) / 2), 0
        data['a_position'] = np.array(
            [[x, y], [x + w, y], [x, y + h], [x + w, y + h]])
        self.program.bind(gloo.VertexBuffer(data))
开发者ID:kmuehlbauer,项目名称:scripts,代码行数:18,代码来源:animate_gloo.py


示例20: __init__

    def __init__(self):
        app.Canvas.__init__(self)
        self.size = W*5,H*5

        self.program = oogl.Program(VERT_SHADER, FRAG_SHADER)
        self.texture = oogl.Texture2D(I)
        self.texture.set_filter(gl.GL_NEAREST, gl.GL_NEAREST)
        
        self.program['u_texture'] = self.texture
        self.program.set_vars(oogl.VertexBuffer(data))

        self.view = np.eye(4,dtype=np.float32)
        self.model = np.eye(4,dtype=np.float32)
        self.projection = np.eye(4,dtype=np.float32)

        self.program['u_model'] = self.model
        self.program['u_view'] = self.view
        self.projection = ortho(0, W, 0, H, -1, 1)
        self.program['u_projection'] = self.projection
开发者ID:joe311,项目名称:vispy,代码行数:19,代码来源:animate-images.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python transforms.perspective函数代码示例发布时间:2022-05-26
下一篇:
Python event.EventEmitter类代码示例发布时间: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