|
42 | 42 | if SHOW_PRINT_STATEMENTS: |
43 | 43 | sys.stdout = sys.stderr |
44 | 44 |
|
| 45 | + def angled_overlap_deg(v1, v2): |
| 46 | + norm_v1 = np.linalg.norm(v1) |
| 47 | + norm_v2 = np.linalg.norm(v2) |
| 48 | + |
| 49 | + if np.isclose(norm_v1, 0.0) or np.isclose(norm_v2, 0.0): |
| 50 | + if not (np.isclose(norm_v1, 0.0) and np.isclose(norm_v2, 0.0)): |
| 51 | + return np.inf |
| 52 | + |
| 53 | + return 0.0 |
| 54 | + |
| 55 | + dot = np.minimum(1.0, np.sum((v1 / np.linalg.norm(v1)) * (v2 / np.linalg.norm(v2)))) |
| 56 | + angle_deg = np.arccos(dot) * 180.0 / np.pi |
| 57 | + |
| 58 | + return angle_deg |
| 59 | + |
45 | 60 |
|
46 | 61 | def dimension_permutation(infinite_dim: int) -> tuple[int, int]: |
47 | 62 | offset_dim = (1 + infinite_dim) % 3 |
@@ -404,21 +419,6 @@ def test_box_and_polyslab_gradients_match(is_3d, infinite_dim_2d, shift_box_cent |
404 | 419 | **test_data, |
405 | 420 | ) |
406 | 421 |
|
407 | | - def angled_overlap_deg(v1, v2): |
408 | | - norm_v1 = np.linalg.norm(v1) |
409 | | - norm_v2 = np.linalg.norm(v2) |
410 | | - |
411 | | - if np.isclose(norm_v1, 0.0) or np.isclose(norm_v2, 0.0): |
412 | | - if not (np.isclose(norm_v1, 0.0) and np.isclose(norm_v2, 0.0)): |
413 | | - return np.inf |
414 | | - |
415 | | - return 0.0 |
416 | | - |
417 | | - dot = np.minimum(1.0, np.sum((v1 / np.linalg.norm(v1)) * (v2 / np.linalg.norm(v2)))) |
418 | | - angle_deg = np.arccos(dot) * 180.0 / np.pi |
419 | | - |
420 | | - return angle_deg |
421 | | - |
422 | 422 | box_polyslab_overlap_deg = angled_overlap_deg(box_grad_filtered, polyslab_grad_filtered) |
423 | 423 | fd_overlap_deg = angled_overlap_deg(fd_box, fd_polyslab) |
424 | 424 | box_fd_adj_overlap_deg = angled_overlap_deg(box_grad_filtered, fd_box) |
|
0 commit comments