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


Python Matrix.rotation_from_axis_angle方法代码示例

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


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

示例1: read_rotation

# 需要导入模块: import Matrix [as 别名]
# 或者: from Matrix import rotation_from_axis_angle [as 别名]
  def read_rotation(self, f):

    axis = self.read_vector(f, 'rotation_axis', None)
    angle = self.read_float(f, 'rotation_angle', None)
    if axis is None or angle is None:
      return ((1,0,0),(0,1,0),(0,0,1))
    import Matrix
    r = Matrix.rotation_from_axis_angle(axis, angle)
    return r
开发者ID:davem22101,项目名称:semanticscience,代码行数:11,代码来源:netcdf_format.py

示例2: find_rotation

# 需要导入模块: import Matrix [as 别名]
# 或者: from Matrix import rotation_from_axis_angle [as 别名]
    def find_rotation(self, group):

        va = group._v_attrs
        if 'rotation_axis' in va and 'rotation_angle' in va:
            axis = va.rotation_axis
            angle = va.rotation_angle
            import Matrix
            r = Matrix.rotation_from_axis_angle(axis, angle)
        else:
            r = ((1,0,0),(0,1,0),(0,0,1))
        return r
开发者ID:davem22101,项目名称:semanticscience,代码行数:13,代码来源:cmap_format.py

示例3: __init__

# 需要导入模块: import Matrix [as 别名]
# 或者: from Matrix import rotation_from_axis_angle [as 别名]
  def __init__(self, path, file_type):

    self.path = path

    import os.path
    self.name = os.path.basename(path)
    
    file = open(path, 'rb')

    file.seek(0,2)                              # go to end of file
    file_size = file.tell()
    file.seek(0,0)                              # go to beginning of file

    # Infer file byte order from column axis size nc.  Requires nc < 2**16
    # Was using mode value but 0 is allowed and does not determine byte order.
    self.swap_bytes = 0
    from numpy import int32
    nc = self.read_values(file, int32, 1)
    self.swap_bytes = not (nc > 0 and nc < 65536)
    file.seek(0,0)

    v = self.read_header_values(file, file_size, file_type)

    unsigned_8_bit = (file_type == 'imod' or v['type'] == 'mrc')
    self.element_type = self.value_type(v['mode'], unsigned_8_bit)

    self.check_header_values(v, file_size, file)
    self.header = v             # For dumpmrc.py standalone program.
    
    self.data_offset = file.tell()
    file.close()
    
    # Axes permutation.
    # Names c,r,s refer to fast, medium, slow file matrix axes.
    # Names i,j,k refer to x,y,z spatial axes.
    mapc, mapr, maps = v['mapc'], v['mapr'], v['maps']
    if (1 in (mapc, mapr, maps) and
        2 in (mapc, mapr, maps) and
        3 in (mapc, mapr, maps)):
      crs_to_ijk = (mapc-1,mapr-1,maps-1)
      ijk_to_crs = [None,None,None]
      for a in range(3):
        ijk_to_crs[crs_to_ijk[a]] = a
    else:
      crs_to_ijk = ijk_to_crs = (0, 1, 2)
    self.crs_to_ijk = crs_to_ijk
    self.ijk_to_crs = ijk_to_crs

    crs_size = v['nc'], v['nr'], v['ns']
    self.matrix_size = [int(s) for s in crs_size]
    self.data_size = [int(crs_size[a]) for a in ijk_to_crs]

    mx, my, mz = v['mx'], v['my'], v['mz']
    xlen, ylen, zlen = v['xlen'], v['ylen'], v['zlen']
    if mx > 0 and my > 0 and mz > 0 and xlen > 0 and ylen > 0 and zlen > 0:
      self.data_step = (xlen/mx, ylen/my, zlen/mz)
    else:
      self.data_step = (1.0, 1.0, 1.0)

    alpha, beta, gamma = (v['alpha'], v['beta'], v['gamma'])
    if alpha == 0 or beta == 0 or gamma == 0:
      alpha = beta = gamma = 90
    self.cell_angles = (alpha, beta, gamma)

    if (v['type'] == 'mrc2000' and
        (v['zorigin'] != 0 or v['xorigin'] != 0 or v['yorigin'] != 0)):
      #
      # This is a new MRC 2000 format file.  The xyz origin header parameters
      # are used instead of using ncstart, nrstart nsstart for new style files,
      # provided the xyz origin specified is not zero.  It turns out the
      # xorigin, yorigin, zorigin values are zero in alot of new files while
      # the ncstart, nrstart, nsstart give the correct (non-zero) origin. So in
      # cases where the xyz origin parameters and older nrstart, ncstart,
      # nsstart parameters specify different origins the one that is non-zero
      # is preferred.  And if both are non-zero, the newer xorigin, yorigin,
      # zorigin are used.
      #
      self.data_origin = (v['xorigin'], v['yorigin'], v['zorigin'])
    else:
      crs_start = v['ncstart'], v['nrstart'], v['nsstart']
      ijk_start = [crs_start[a] for a in ijk_to_crs]
      # Check if ijk_start values appear to be uninitialized.
      limit = 10*max(max(mx,my,mz), max(self.data_size))
      if [s for s in ijk_start if abs(s) > limit]:
        self.data_origin = (0., 0., 0.)
      else:
        from VolumeData.griddata import scale_and_skew
        self.data_origin = scale_and_skew(ijk_start, self.data_step,
                                          self.cell_angles)

    r = ((1,0,0),(0,1,0),(0,0,1))
    for lbl in v['labels']:
      if lbl.startswith('Chimera rotation: '):
        ax,ay,az,angle = map(float, lbl.rstrip('\0').split()[2:])
        import Matrix
        r = Matrix.rotation_from_axis_angle((ax,ay,az), angle)
    self.rotation = r
    
    self.min_intensity = v['amin']
    self.max_intensity = v['amax']
开发者ID:davem22101,项目名称:semanticscience,代码行数:102,代码来源:mrc_format.py


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