File tree Expand file tree Collapse file tree 1 file changed +8
-10
lines changed
Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments