def get_disk_norm(vaxis, haxis, offset=0.): norm = as_unit(vaxis) rot1 = make_rotation_matrix(norm, np.array([0., 0., 1.])) haxis2 = np.dot(rot1, haxis.reshape(3, 1)).T rot2 = make_rotation_matrix(haxis2, np.array([1., 0., 0.])) inv_rot = np.dot(rot2, rot1).T ref_norm = as_unit(np.array([np.cos(offset), np.sin(offset), 0.])) disk_norm = np.dot(inv_rot, ref_norm.reshape(3, 1)).T return disk_norm
def test_rot_matrix_vector_rotation_correct(self): from e3fp.fingerprint.array_ops import make_rotation_matrix, \ as_unit for i in range(2, 5): u0 = as_unit(np.random.uniform(size=3)) u1 = as_unit(np.random.uniform(size=3)) rot = make_rotation_matrix(u0, u1) np.testing.assert_array_almost_equal(u1, np.dot(rot, u0))
def test_rot_matrix_array_rotation_correct(self): from e3fp.fingerprint.array_ops import make_rotation_matrix, \ as_unit for i in range(1, 5): u0 = as_unit(np.random.uniform(size=3)) arr = np.random.uniform(size=(i, 3)) v = arr[0, :] rot = make_rotation_matrix(v, u0) rot_arr = np.dot(rot, arr.T).T u1 = as_unit(rot_arr[0, :]) np.testing.assert_array_almost_equal(u0.flatten(), u1.flatten())
def get_cgo_arc_obj(center, norm, start, radians, linespacing=0., color=[0., 0., 0.], alpha=1., res=.5 * np.pi / 180): """Get CGO parameters to create arc in PyMOL""" logging.debug(("Creating CGO arc with start {}, center {}, norm {}, " "covering {} deg").format(start, center, norm, radians * 180 / np.pi)) obj = [] obj = [COLOR] + color start_ref = start - center rad = np.linalg.norm(start_ref) if rad < 1e-7: return [] rot1 = make_rotation_matrix(norm, np.array([0., 0., 1.])) start2 = np.dot(rot1, start_ref.reshape(3, 1)).T rot2 = make_rotation_matrix(start2, np.array([1., 0., 0.])) inv_rot = np.dot(rot2, rot1).T angles = np.linspace(0., radians, float(radians) / res) ref_xyz = np.empty((angles.shape[0], 3), dtype=np.double) ref_xyz[:, 0] = rad * np.cos(angles) ref_xyz[:, 1] = rad * np.sin(angles) ref_xyz[:, 2] = 0 xyz = np.dot(inv_rot, ref_xyz.T).T + center if linespacing > 0.: i = 0 skip_num = max(1, int(linespacing / (rad * res))) while i < (xyz.shape[0] - 1 - skip_num): for j in range(skip_num): obj.extend(get_cgo_segment_obj(xyz[i, :], xyz[i + 1, :])) i += 1 i += skip_num else: for i in range(xyz.shape[0] - 1): obj.extend(get_cgo_segment_obj(xyz[i, :], xyz[i + 1, :])) return obj