def test_rotate_points(): rot = gtr.Rotation(ROT_90) points = np.array([[2, 0, 0], [0, 2, 0], [0, 0, 2], [3, 0, 3]]) assert np.all(rot(points) == np.array([[0, 2, 0], [-2, 0, 0], [0, 0, 2], [0, 3, 3]])) rot = gtr.Rotation(ROT_180) assert np.all(rot(points) == np.array([[-2, 0, 0], [0, -2, 0], [0, 0, 2], [-3, 0, 3]])) rot = gtr.Rotation(ROT_270) assert np.all(rot(points) == np.array([[0, -2, 0], [2, 0, 0], [0, 0, 2], [0, -3, 3]]))
def test_rotate_point(): rot = gtr.Rotation(ROT_90) assert rot([2, 0, 0]).tolist() == [0, 2, 0] assert rot([0, 2, 0]).tolist() == [-2, 0, 0] assert rot([0, 0, 2]).tolist() == [0, 0, 2] rot = gtr.Rotation(ROT_180) assert rot([2, 0, 0]).tolist() == [-2, 0, 0] assert rot([0, 2, 0]).tolist() == [0, -2, 0] assert rot([0, 0, 2]).tolist() == [0, 0, 2] rot = gtr.Rotation(ROT_270) assert rot([2, 0, 0]).tolist() == [0, -2, 0] assert rot([0, 2, 0]).tolist() == [2, 0, 0] assert rot([0, 0, 2]).tolist() == [0, 0, 2]
def test_rotate_point(): rot = gtr.Rotation(ROT_90) nt.assert_equal(rot([2, 0, 0]).tolist(), [0, 2, 0]) nt.assert_equal(rot([0, 2, 0]).tolist(), [-2, 0, 0]) nt.assert_equal(rot([0, 0, 2]).tolist(), [0, 0, 2]) rot = gtr.Rotation(ROT_180) nt.assert_equal(rot([2, 0, 0]).tolist(), [-2, 0, 0]) nt.assert_equal(rot([0, 2, 0]).tolist(), [0, -2, 0]) nt.assert_equal(rot([0, 0, 2]).tolist(), [0, 0, 2]) rot = gtr.Rotation(ROT_270) nt.assert_equal(rot([2, 0, 0]).tolist(), [0, -2, 0]) nt.assert_equal(rot([0, 2, 0]).tolist(), [2, 0, 0]) nt.assert_equal(rot([0, 0, 2]).tolist(), [0, 0, 2])
def test_pivot_rotate_point(): point = [1, 2, 3] new_orig = np.array([10., 45., 50.]) t = gtr.Translation(new_orig) t_inv = gtr.Translation(new_orig * -1) R = gtr._rodrigues_to_dcm(TEST_UVEC, np.pi) # change origin, rotate 180 p1 = gtr.PivotRotation(R, new_orig)(point) # do the steps manually p2 = t_inv(point) p2 = gtr.Rotation(R)(p2) p2 = t(p2) assert p1.tolist() == p2.tolist()
def test_pivot_rotate_points(): points = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]) new_orig = np.array([10., 45., 50.]) t = gtr.Translation(new_orig) t_inv = gtr.Translation(new_orig * -1) R = gtr._rodrigues_to_dcm(TEST_UVEC, np.pi) # change origin, rotate 180 p1 = gtr.PivotRotation(R, new_orig)(points) # do the steps manually p2 = t_inv(points) p2 = gtr.Rotation(R)(p2) p2 = t(p2) nt.assert_true(np.all(p1 == p2))
def test_transform_rotate_neuron_h5(): rot = gtr.Rotation(ROT_90) nrn_a = load_neuron(H5_NRN_PATH) nrn_b = nrn_a.transform(rot) _check_fst_nrn_rotate(nrn_a, nrn_b, ROT_90)