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


Python Matrix.translation_matrix方法代码示例

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


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

示例1: parameter_xform

# 需要导入模块: import Matrix [as 别名]
# 或者: from Matrix import translation_matrix [as 别名]
def parameter_xform(rotq, rotc, trans):

    import Matrix as m
    ttf = m.translation_matrix(trans)
    sa2 = m.norm(rotq[:3])
    ca2 = rotq[3]
    from math import atan2, pi
    angle = 2*atan2(sa2,ca2) * 180.0/pi
    axis = m.normalize_vector(rotq[:3])
    rtf = m.rotation_transform(axis, angle, rotc)
    tf = m.multiply_matrices(ttf, rtf)
    xf = m.chimera_xform(tf)
    return xf
开发者ID:davem22101,项目名称:semanticscience,代码行数:15,代码来源:fly.py

示例2: group_symmetries

# 需要导入模块: import Matrix [as 别名]
# 或者: from Matrix import translation_matrix [as 别名]
def group_symmetries(group, center, axis, mol):

    from Commands import CommandError

    g0 = group[:1].lower()
    if g0 in ('c', 'd'):
        # Cyclic or dihedral symmetry: C<n>, D<n>
        try:
            n = int(group[1:])
        except ValueError:
            raise CommandError, 'Invalid symmetry group syntax "%s"' % group
        if n < 2:
            raise CommandError, 'Cn or Dn with n = %d < 2' % (n,)
        if g0 == 'c':
            tflist = cyclic_symmetries(n)
        else:
            tflist = dihedral_symmetries(n)
    elif g0 == 'i':
        # Icosahedral symmetry: i[,<orientation>]
        import Icosahedron as icos
        gfields = group.split(',')
        if len(gfields) == 1:
            orientation = '222'
        elif len(gfields) == 2:
            orientation = gfields[1]
            if not orientation in icos.coordinate_system_names:
                raise CommandError, ('Unknown icosahedron orientation "%s"'
                                     % orientation)
        else:
            raise CommandError, 'Invalid symmetry group syntax "%s"' % group
        tflist = icos.icosahedral_symmetry_matrices(orientation)
    elif g0 == 'h':
        # Helical symmetry: h,<repeat>,<rise>[,<angle>[,<n>,<offet>]]
        gfields = group.split(',')
        nf = len(gfields)
        if nf < 3 or nf > 6:
            raise CommandError, 'Invalid symmetry group syntax "%s"' % group
        try:
            param = [float(f) for f in gfields[1:]]
        except ValueError:
            raise CommandError, 'Invalid symmetry group syntax "%s"' % group
        if len(param) == 2:
            param.append(360.0)
        if len(param) == 3:
            param.append(int(param[0]))
        if len(param) == 4:
            param.append(0)
        repeat, rise, angle, n, offset = param
        tflist = helical_symmetry(repeat, rise, angle, n, offset)
    elif g0 == 't':
        # Translation symmetry: t,<n>,<distance> or t,<n>,<dx>,<dy>,<dz>
        gfields = group.split(',')
        nf = len(gfields)
        if nf != 3 and nf != 5:
            raise CommandError, 'Invalid symmetry group syntax "%s"' % group
        try:
            param = [float(f) for f in gfields[1:]]
        except ValueError:
            raise CommandError, 'Invalid symmetry group syntax "%s"' % group
        n = param[0]
        if n != int(n):
            raise CommandError, 'Invalid symmetry group syntax "%s"' % group
        if nf == 3:
          delta = (0,0,param[1])
        else:
          delta = param[1:]
        tflist = translation_symmetry(n, delta)
    elif group.lower() == 'biomt':
        # BIOMT biological unit matrices from PDB file header.
        if not hasattr(mol, 'pdbHeaders'):
            msg = 'Molecule %s has no BIOMT matrices or PDB headers' % mol.name
            raise CommandError, msg
        from PDBmatrices import pdb_biomt_matrices
        tflist = pdb_biomt_matrices(mol.pdbHeaders)
        if len(tflist) == 0:
            msg = 'Molecule %s has no BIOMT matrices in PDB header' % mol.name
            raise CommandError, msg
        from Matrix import is_identity_matrix
        if len(tflist) == 1 and is_identity_matrix(tflist[0]):
            msg = 'Molecule %s has only identity BIOMT matrix in PDB header' % mol.name
            raise CommandError, msg
    else:
        raise CommandError, 'Unknown symmetry group "%s"' % group

    # Apply center and axis transformation.
    if tuple(center) != (0,0,0) or tuple(axis) != (0,0,1):
        import Matrix as m
        tf = m.multiply_matrices(m.vector_rotation_transform(axis, (0,0,1)),
                                 m.translation_matrix([-c for c in center]))
        tfinv = m.invert_matrix(tf)
        tflist = [m.multiply_matrices(tfinv, t, tf) for t in tflist]

    return tflist
开发者ID:davem22101,项目名称:semanticscience,代码行数:95,代码来源:symcmd.py


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