def test_pllp(self): """Test for pllp function.""" c1 = Coord(-30, 0) c2 = Coord(30, 0) coord = pllp(c1, 50, 50, c2) self.assertAlmostEqual(0, coord.x) self.assertAlmostEqual(40, coord.y) coord = pllp(c1, 30, 30, c2) self.assertAlmostEqual(coord.x, 0) self.assertAlmostEqual(coord.y, 0) coord = pllp(c1, 90, 30, c2) self.assertAlmostEqual(60, coord.x) self.assertAlmostEqual(0, coord.y)
def __is_ok(self) -> None: """Check and show the final position.""" mode = self.tab_widget.currentIndex() if mode == 0: x = self.plap_p1x_box.value() y = self.plap_p1y_box.value() c = plap( Coordinate(x, y), self.plap_distance_box.value(), radians(self.plap_angle_box.value()) ) elif mode == 1: x1 = self.pllp_p1x_box.value() y1 = self.pllp_p1y_box.value() x2 = self.pllp_p2x_box.value() y2 = self.pllp_p2y_box.value() c = pllp( Coordinate(x1, y1), self.pllp_distance1_box.value(), self.pllp_distance2_box.value(), Coordinate(x2, y2), self.pllp_inversed_box.isChecked() ) else: raise ValueError("invalid option") self.preview_label.setText(f"({c.x}, {c.y})") self.__x = c.x self.__y = c.y ok_button = self.button_box.button(QDialogButtonBox.Ok) ok_button.setEnabled(not (isnan(c.x) or isnan(c.y)))