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


Python Matrix.identity方法代码示例

本文整理汇总了Python中Matrix.Matrix.identity方法的典型用法代码示例。如果您正苦于以下问题:Python Matrix.identity方法的具体用法?Python Matrix.identity怎么用?Python Matrix.identity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Matrix.Matrix的用法示例。


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

示例1: init

# 需要导入模块: from Matrix import Matrix [as 别名]
# 或者: from Matrix.Matrix import identity [as 别名]
   def init(self):
      # Initialize the renderer, set up the Window.
      glfw.init()
      glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 3)
      glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 3)
      glfw.window_hint(glfw.OPENGL_FORWARD_COMPAT, gl.GL_TRUE)
      glfw.window_hint(glfw.OPENGL_PROFILE, glfw.OPENGL_CORE_PROFILE)
      glfw.window_hint(glfw.DECORATED, gl.GL_TRUE)
      glfw.window_hint(glfw.DECORATED, gl.GL_TRUE)
      glfw.window_hint(glfw.RESIZABLE, gl.GL_FALSE)

      width = Config.windowWidth
      height = Config.windowHeight

      self.aspect = width/height

      # Initialize the window
      self.window = glfw.create_window(width, height, "Magic", None, None)
      glfw.make_context_current(self.window)
      self.renderer = Renderer()
      self.quad = []
      self.text = []

      # Set up camera
      self.viewMatrix = Matrix.identity()

      # Set up view transform. View is always 16 units high, and 16 * aspect units
      # wide. The extra space outside of a 4:3 ratio is unused, to make sure that
      # all the cards always fit in a 4:3 aspect monitor. 
      vHeight = 2
      vWidth = vHeight * self.aspect
      self.projectionMatrix = Matrix.ortho(-vWidth/2, vWidth/2, vHeight/2, -vHeight/2, -1, 1)
      self.viewProjectionMatrix = self.projectionMatrix * self.viewMatrix

      # Set up viewport
      fbWidth, fbHeight = glfw.get_framebuffer_size(self.window)
      gl.glViewport(0, 0, fbWidth, fbHeight)
      q = Quad(Texture('Images/Sen Triplets.jpg'))
      # Natural resolution of cards is 480x680
      cardAspect = 480/680
      q.x = 0
      q.y = 0
      q.height = .8
      q.width = q.height * cardAspect
      self.quad.append(q)
开发者ID:heavyairship,项目名称:Magic,代码行数:47,代码来源:Context.py

示例2: setBasis

# 需要导入模块: from Matrix import Matrix [as 别名]
# 或者: from Matrix.Matrix import identity [as 别名]
    def setBasis(self, basis):
        """Set the basis matrix for this coordinate system.  The basis matrix
        should be 3x3. The rows should be:
        
        | Row # | Description                                         |
        +-------+-----------------------------------------------------+
        | 0     | x basis vector (row vector, in parent coordinates.) |
        | 1     | y basis vector (row vector, in parent coordinates.) |
        | 2     | z basis vector (row vector, in parent coordinates.) |
        
        Therefore M * (x - O) = x' where:
        M = the basis vector
        O = origin of this coordinate system, in parent coordinate system.
        x = vector in parent coordinate system
        x' = vector in this coordinate system."""
        # TODO: error out if this matrix is not 3x3 and orthonormal.
        # TODO: error out if there is no parent coordinate system!
        if basis is not None:
            self.mBasis = basis # The basis matrix.
        else:
            self.mBasis = Matrix.identity(3)

        # We don't assign a value to this until we need it.
        self.mBasisTranspose = None
开发者ID:pmbrennan,项目名称:math3d,代码行数:26,代码来源:CoordinateSys.py

示例3: test_identity

# 需要导入模块: from Matrix import Matrix [as 别名]
# 或者: from Matrix.Matrix import identity [as 别名]
 def test_identity(self):
     m = Matrix(3, 3, mtype='i')
     self.assertEqual(m, Matrix([1, 0, 0], [0, 1, 0], [0, 0, 1]))
     m = Matrix(2, 2)
     m.identity()
     self.assertEqual(m, Matrix([1, 0], [0, 1]))
开发者ID:AnthonyBrunasso,项目名称:pymath,代码行数:8,代码来源:MatrixTests.py


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