Skip to content

Commit

Permalink
Modified formula to compute debug offset and angle. Moved computation…
Browse files Browse the repository at this point in the history
… to a separate function.
  • Loading branch information
TheAntTeam committed Jan 22, 2024
1 parent 16f40e8 commit 92d2bba
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/TheAntFarm/ui_manager/ui_align_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ def apply_align(self):

self.align_apply_s.emit(align_to_be_applied_flag, alignment_points)

@staticmethod
def compute_offset_point(x_in, y_in, offset_in, angle_in):
x_out = offset_in + (x_in * math.cos(math.radians(angle_in)) -
(y_in * math.sin(math.radians(angle_in))))
y_out = offset_in + ((x_in * math.sin(math.radians(angle_in))) +
(y_in * math.cos(math.radians(angle_in))))
return x_out, y_out

def add_new_point(self):
x_val = self.ui.x_point_layer_dsb.value()
y_val = self.ui.y_point_layer_dsb.value()
Expand All @@ -90,17 +98,12 @@ def add_new_point(self):
for r in range(0, num_rows):
actual_x_base = float(self.ui.align_points_tw.cellWidget(r, 0).text())
actual_y_base = float(self.ui.align_points_tw.cellWidget(r, 1).text())
updated_x_offs = (actual_x_base + offset_val) * math.cos(math.radians(angle_val)) - \
((actual_y_base + offset_val) * math.sin(math.radians(angle_val)))
updated_y_offs = (actual_x_base + offset_val) * math.sin(math.radians(angle_val)) + \
(actual_y_base + offset_val) * math.cos(math.radians(angle_val))
updated_x_offs, updated_y_offs = self.compute_offset_point(actual_x_base, actual_y_base,
offset_val, angle_val)
self.ui.align_points_tw.setCellWidget(r, 2, QLabel("{:.3f}".format(updated_x_offs)))
self.ui.align_points_tw.setCellWidget(r, 3, QLabel("{:.3f}".format(updated_y_offs)))

new_x_val = (x_val + offset_val) * math.cos(math.radians(angle_val)) - \
((y_val + offset_val) * math.sin(math.radians(angle_val)))
new_y_val = (x_val + offset_val) * math.sin(math.radians(angle_val)) + \
(y_val + offset_val) * math.cos(math.radians(angle_val))
new_x_val, new_y_val = self.compute_offset_point(x_val, y_val, offset_val, angle_val)

self.ui.align_points_tw.insertRow(num_rows)
self.ui.align_points_tw.setCellWidget(num_rows, 0, QLabel("{:.3f}".format(x_val)))
Expand Down

0 comments on commit 92d2bba

Please sign in to comment.