Skip to content

Commit

Permalink
Fix sign convention
Browse files Browse the repository at this point in the history
  • Loading branch information
AreWeDreaming committed Jul 24, 2024
1 parent f971250 commit c09e426
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions regression/test_geometry_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ class TestGeomtryUtils(unittest.TestCase):

def test_get_phi_tor_from_two_points(self):
for x1_vec, x2_vec, phi_check in zip([np.array([8, 0.5, 0.01]),
np.array([-0.9807852804032304, -0.1950903220161284, 0.006681805010885])],
[np.array([4, 0.8, 0.02]),
np.array([-2.3048453154126185, -0.45846223813263876, 0.04097180441021919])],
[7.8654877038163695, -180.0]):
np.array([-2.3048453154126185, -0.45846223813263876, 0.04097180441021919])],
[np.array([4, 0.8, 0.02]),
np.array([-0.9807852804032304, -0.1950903220161284, 0.006681805010885])],
[-7.8654877038163695, 0]):
phi = get_phi_tor_from_two_points(x1_vec, x2_vec)
self.assertTrue(np.allclose(phi, phi_check, rtol=1.e-5, atol=1.e-5))

Expand Down
4 changes: 2 additions & 2 deletions src/plasma_math_tools/geometry_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ def get_theta_pol_from_two_points(R1_vec, R2_vec):
def get_phi_tor_from_two_points(x1_vec, x2_vec):
# x1_vec and x2_vec should be 2D and lie in the x,y plane
phi_1 = np.arctan2(x1_vec[1], x1_vec[0])
phi_12 = np.arctan2(x1_vec[1]-x2_vec[1], x1_vec[0]-x2_vec[0])
phi_tor = np.rad2deg(phi_1 - phi_12)
phi_12 = np.arctan2(x1_vec[1] - x2_vec[1], x1_vec[0] - x2_vec[0])
phi_tor = -np.rad2deg(phi_1 - phi_12 )
return phi_tor

class Contouring():
Expand Down

0 comments on commit c09e426

Please sign in to comment.