Skip to content

Commit

Permalink
Correcting rotation matrix usage in vector mapping and calculate conf…
Browse files Browse the repository at this point in the history
…ormal 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.
  • Loading branch information
LyceanEM committed May 29, 2024
1 parent 660bde7 commit 7dcc68f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion lyceanem/base_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions lyceanem/electromagnetics/empropagation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 7dcc68f

Please sign in to comment.