本文整理汇总了Python中Matrix.multiply_matrices方法的典型用法代码示例。如果您正苦于以下问题:Python Matrix.multiply_matrices方法的具体用法?Python Matrix.multiply_matrices怎么用?Python Matrix.multiply_matrices使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix
的用法示例。
在下文中一共展示了Matrix.multiply_matrices方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parameter_xform
# 需要导入模块: import Matrix [as 别名]
# 或者: from Matrix import multiply_matrices [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
示例2: texture_surface_piece
# 需要导入模块: import Matrix [as 别名]
# 或者: from Matrix import multiply_matrices [as 别名]
def texture_surface_piece(p, t, txf, border_color, offset = 0):
p.textureId = t.texture_id()
p.useTextureTransparency = ('a' in t.color_mode)
p.textureModulationColor = t.modulation_rgba()
p.textureBorderColor = border_color
va = offset_vertices(p, offset)
s2tc = t.texture_matrix()
p2s = p.model.openState.xform
p2s.premultiply(txf.inverse())
import Matrix
p2tc = Matrix.multiply_matrices(s2tc, Matrix.xform_matrix(p2s))
import _contour
_contour.affine_transform_vertices(va, p2tc)
p.textureCoordinates = va
p.using_surface_coloring = True
示例3: fit_map_in_map
# 需要导入模块: import Matrix [as 别名]
# 或者: from Matrix import multiply_matrices [as 别名]
def fit_map_in_map(map1, map2,
initial_map1_transform = None,
map1_threshold = None,
ijk_step_size_min = 0.01, # Grid index units
ijk_step_size_max = 1.5, # Grid index units
max_steps = 10000,
optimize_translation = True,
optimize_rotation = True):
# Files have to have file suffix indicating volume format.
if initial_map1_transform:
xf = Matrix.chimera_xform(initial_map1_transform)
map1.surface_model().openState.globalXform(xf)
use_threshold = (map1_threshold != None)
points, point_weights = map_points_and_weights(map1, use_threshold)
if len(points) == 0:
if use_threshold:
print 'No grid points above map threshold.'
else:
print 'Map has no non-zero values.'
return
move_tf, stats = motion_to_maximum(points, point_weights, map2, max_steps,
ijk_step_size_min, ijk_step_size_max,
optimize_translation, optimize_rotation)
if initial_map1_transform:
move_tf = Matrix.multiply_matrices(move_tf, initial_map1_transform)
header = ('\nFit map %s in map %s using %d points\n'
% (map1.name, map2.name, stats['points']) +
' correlation = %.4g, overlap = %.4g\n'
% (stats['correlation'], stats['overlap']) +
' steps = %d, shift = %.3g, angle = %.3g degrees\n'
% (stats['steps'], stats['shift'], stats['angle']))
print header
#tfs = Matrix.transformation_description(move_tf)
#print tfs
xf = Matrix.chimera_xform(move_tf)
map1.surface_model().openState.globalXform(xf)
示例4: group_symmetries
# 需要导入模块: import Matrix [as 别名]
# 或者: from Matrix import multiply_matrices [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