# ------------------------------------------------------------------------------ # Rotate all markers in the active path tracer marker set. # def rotate_markers(xform): from VolumePath import volume_path_dialog d = volume_path_dialog() if d == None: return # No marker sets exist. ms = d.active_marker_set if ms == None: return # No marker set chosen in dialog. from chimera import Point for m in ms.markers(): xyz = m.xyz() # Python tuple txyz = xform.apply(Point(*xyz)).data() m.set_xyz(txyz) # ------------------------------------------------------------------------------ # Convert Euler angles to an equivalent Chimera transformation matrix. # # Angles must be in degrees, not radians. # # Uses the most common Euler angle convention (the chi-convention) described at # # http://mathworld.wolfram.com/EulerAngles.html # def euler_transform(phi, theta, psi): from chimera import Xform, Vector xf1 = Xform.rotation(Vector(0,0,1), phi) # Rotate about z-axis xp = xf1.apply(Vector(1,0,0)) # New x-axis xf2 = Xform.rotation(xp, theta) # Rotate about new x-axis zp = xf2.apply(Vector(0,0,1)) # New z-axis xf3 = Xform.rotation(zp, psi) # Rotate about new z-axis xf = Xform() xf.premultiply(xf1) xf.premultiply(xf2) xf.premultiply(xf3) return xf # ------------------------------------------------------------------------------ # xf = euler_transform(30, 60, 45) rotate_markers(xf)