Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #347

Merged
merged 1 commit into from
Jun 11, 2024
Merged

Fix #347

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions sionna/rt/solver_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -816,12 +816,22 @@ def _swap_edges(self, edges):
# 1. norm(p1) >= norm(p0)
# 2. azimuth(p1) >= azimuth(p0)
# 3. elevation (p1) >= elevation(p0)
needs_swap_1 = r0 > r1
not_disc_1 = tf.experimental.numpy.isclose(r0, r1)
needs_swap_2 = tf.logical_and(not_disc_1, phi0 > phi1)
not_disc_2 = tf.experimental.numpy.isclose(phi0, phi1)
not_disc_12 = tf.logical_and(not_disc_1, not_disc_2)
needs_swap_3 = tf.logical_and(not_disc_12, theta0 > theta1)

# More details of the algorithm:
# needs_swap 1: !r_equal and r0 > r1
# needs_swap 2: r_equal and !phi_equal and phi0 > phi1
# needs_swap 3: r_equal and phi_equal and theta0 > theta1
# Note: case when all three coordinates are equal is not considered

r_equal = tf.experimental.numpy.isclose(r0, r1)
phi_equal = tf.experimental.numpy.isclose(phi0, phi1)
case_2 = tf.logical_and(r_equal, tf.logical_not(phi_equal))
case_3 = tf.logical_and(r_equal, phi_equal)

needs_swap_1 = tf.logical_and(tf.logical_not(r_equal), r0 > r1)
needs_swap_2 = tf.logical_and(case_2, phi0 > phi1)
needs_swap_3 = tf.logical_and(case_3, theta0 > theta1)

needs_swap = tf.reduce_any(tf.stack([needs_swap_1,
needs_swap_2,
needs_swap_3], axis=1),
Expand Down
Loading