def _test_vs_euler_angles_xyz_angles(phi1, phi2, phi3): from scitbx.math import euler_angles_xyz_angles # compose rotation matrix R1 = matrix.col((1, 0, 0)).axis_and_angle_as_r3_rotation_matrix(phi1, deg=False) R2 = matrix.col((0, 1, 0)).axis_and_angle_as_r3_rotation_matrix(phi2, deg=False) R3 = matrix.col((0, 0, 1)).axis_and_angle_as_r3_rotation_matrix(phi3, deg=False) R = R1 * R2 * R3 # get two solution sets for the principal axes sol1 = solve_r3_rotation_for_angles_given_axes(R, (1, 0, 0), (0, 1, 0), (0, 0, 1), smaller_phi2_solution=False, deg=True) sol2 = solve_r3_rotation_for_angles_given_axes(R, (1, 0, 0), (0, 1, 0), (0, 0, 1), smaller_phi2_solution=True, deg=True) # get the solution set provided by euler_angles_xyz_angles tst = euler_angles_xyz_angles(R) # one of these must match assert approx_equal(sol1, tst, out=None) or approx_equal( sol2, tst, out=None)
def test_vs_euler_angles_xyz_angles(phi1, phi2, phi3): from scitbx.math import euler_angles_xyz_angles # compose rotation matrix R1 = matrix.col((1,0,0)).axis_and_angle_as_r3_rotation_matrix(phi1, deg=False) R2 = matrix.col((0,1,0)).axis_and_angle_as_r3_rotation_matrix(phi2, deg=False) R3 = matrix.col((0,0,1)).axis_and_angle_as_r3_rotation_matrix(phi3, deg=False) R = R1*R2*R3 # get two solution sets for the principal axes sol1 = solve_r3_rotation_for_angles_given_axes(R, (1,0,0), (0,1,0), (0,0,1), smaller_phi2_solution=False, deg=True) sol2 = solve_r3_rotation_for_angles_given_axes(R, (1,0,0), (0,1,0), (0,0,1), smaller_phi2_solution=True, deg=True) # get the solution set provided by euler_angles_xyz_angles tst = euler_angles_xyz_angles(R) # one of these must match assert any([approx_equal(sol1, tst, out=None), approx_equal(sol2, tst, out=None)]) return