Skip to content

Commit 963f217

Browse files
Jammy2211Jammy2211
authored andcommitted
black
1 parent 67ad463 commit 963f217

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

autoarray/geometry/geometry_util.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -374,20 +374,18 @@ def transform_grid_2d_to_reference_frame(
374374
grid
375375
The 2d grid of (y, x) coordinates which are transformed to a new reference frame.
376376
"""
377-
grid_2d = jnp.asarray(grid_2d)
378-
centre = jnp.asarray(centre)
379377

380-
# Inject a tiny dynamic dependency on `angle` to prevent heavy constant folding
381-
# (adds zero at runtime; negligible cost)
382-
dynamic_zero = jnp.zeros_like(grid_2d) * angle
383-
shifted = (grid_2d + dynamic_zero) - centre
378+
shifted_grid_2d = grid_2d - jnp.array(centre)
379+
380+
radius = jnp.sqrt(jnp.sum(jnp.square(shifted_grid_2d), axis=1))
381+
theta_coordinate_to_profile = jnp.arctan2(
382+
shifted_grid_2d[:, 0], shifted_grid_2d[:, 1]
383+
) - jnp.radians(angle)
384384

385-
radius = jnp.sqrt(jnp.sum(shifted * shifted, axis=1))
386-
theta = jnp.arctan2(shifted[:, 0], shifted[:, 1]) - jnp.deg2rad(angle)
387385
return jnp.vstack(
388386
[
389-
radius * jnp.sin(theta),
390-
radius * jnp.cos(theta),
387+
radius * jnp.sin(theta_coordinate_to_profile),
388+
radius * jnp.cos(theta_coordinate_to_profile),
391389
]
392390
).T
393391

0 commit comments

Comments
 (0)