|
6 | 6 | Point, |
7 | 7 | cartesian_to_spherical, |
8 | 8 | cartesian_to_spherical_vectorized, |
| 9 | + create_standoff_transform, |
9 | 10 | spherical_coordinate_basis, |
10 | 11 | spherical_to_cartesian, |
11 | 12 | spherical_to_cartesian_vectorized, |
@@ -87,3 +88,15 @@ def test_spherical_coordinate_basis(): |
87 | 88 | assert np.allclose(np.diff(r_hat / point), 0) # verify that r_hat is a scalar multiple of the cartesian coords |
88 | 89 | assert cartesian_to_spherical_vectorized(point + 0.01*phi_hat)[2] > phi # verify phi_hat points along increasing phi |
89 | 90 | assert cartesian_to_spherical_vectorized(point + 0.01*theta_hat)[1] > th # verify theta_hat points along increasing theta |
| 91 | + |
| 92 | +def test_create_standoff_transform(): |
| 93 | + z_offset = 3.2 |
| 94 | + dzdy = 0.15 |
| 95 | + t = create_standoff_transform(z_offset, dzdy) |
| 96 | + assert np.allclose(t[:3,:3] @ t[:3,:3].T, np.eye(3)) # it's an orthonormal transform |
| 97 | + assert np.allclose(np.linalg.det(t[:3,:3]), 1.0) # orientation preserving |
| 98 | + assert np.allclose(t @ np.array([0,0,0,1]), np.array([0,0,-z_offset,1.])) # translates the origin correctly |
| 99 | + new_x_axis = (t @ np.array([1,0,0,1]) - t @ np.array([0,0,0,1]))[:3] |
| 100 | + new_y_axis = (t @ np.array([0,1,0,1]) - t @ np.array([0,0,0,1]))[:3] |
| 101 | + assert np.allclose(new_x_axis, np.array([1.,0,0])) |
| 102 | + assert new_y_axis[2] > 0 # the y axis was rotated upward, so that the top of the transducer gets closer to the skin |
0 commit comments