From 7dcc68f0bfb69a9e0a62ec84ebdc6d5921c8845e Mon Sep 17 00:00:00 2001 From: LyceanEM <60020395+LyceanEM@users.noreply.github.com> Date: Wed, 29 May 2024 10:32:52 +0100 Subject: [PATCH] Correcting rotation matrix usage in vector mapping and calculate conformal vectors, the pytest errors were partly due to an ordering error causing the u axis to be inverted when the point normal was aligned with the z axis. --- lyceanem/base_classes.py | 4 +++- lyceanem/electromagnetics/empropagation.py | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lyceanem/base_classes.py b/lyceanem/base_classes.py index e0f455b..0f393c9 100644 --- a/lyceanem/base_classes.py +++ b/lyceanem/base_classes.py @@ -392,8 +392,10 @@ def excitation_function( aperture_points = self.export_all_points() else: aperture_points = self.export_all_points(point_index=point_index) + + #as export all points imposes the transformation from local to global frame on the points and associated normal vectors, no rotation is required within calculate_conformalVectors aperture_weights = EM.calculate_conformalVectors( - desired_e_vector, aperture_points.point_data['Normals'], self.pose[:3, :3] + desired_e_vector, aperture_points.point_data['Normals'], np.eye(3) ) if phase_shift == "wavefront": source_points = np.asarray(aperture_points.points) diff --git a/lyceanem/electromagnetics/empropagation.py b/lyceanem/electromagnetics/empropagation.py index 04450f6..0369830 100644 --- a/lyceanem/electromagnetics/empropagation.py +++ b/lyceanem/electromagnetics/empropagation.py @@ -3678,7 +3678,7 @@ def vector_mapping(local_E_vector, point_normal, rotation_matrix): if abs(z_orth) == 0: # cannot use z axis as reference, so point normal is aligned with z axis, therefore face_u should be the on the # antenna y_axis, therefore face_v can be used to define backwards. - uvn_axes[0, :] = np.cross(point_vector, local_axes[0, :]) / np.linalg.norm( + uvn_axes[0, :] = np.cross(local_axes[0, :],point_vector) / np.linalg.norm( np.cross(local_axes[0, :], point_vector) ) @@ -3710,7 +3710,7 @@ def vector_mapping(local_E_vector, point_normal, rotation_matrix): ) # print('uvn',uvn_axes) - # convert uvn vector to local axes, and then rotate into global axes + # convert uvn vector to local axes, and then rotate into global axes if required global_vector = np.matmul(local_E_vector, uvn_axes) return global_vector