5 from TestSketcher import SketcherTestCase
7 class SketcherSetAngle(SketcherTestCase):
10 l1 = self.sketch.addLine(0, 0, 0, 1)
11 l2 = self.sketch.addLine(0, 0, 1, 1)
12 self.sketch.setAngle(l1.result(), l2.result(), 30.0)
13 # Commit the transaction
16 dot_product = (l1.endPoint().x() - l1.startPoint().x()) * \
17 (l2.endPoint().x() - l2.startPoint().x()) + \
18 (l1.endPoint().y() - l1.startPoint().y()) * \
19 (l2.endPoint().y() - l2.startPoint().y())
21 math.pow((l1.endPoint().x() - l1.startPoint().x()), 2) +
22 math.pow((l1.endPoint().y() - l1.startPoint().y()), 2)
25 math.pow((l2.endPoint().x() - l2.startPoint().x()), 2) +
26 math.pow((l2.endPoint().y() - l2.startPoint().y()), 2)
28 angle = math.acos(dot_product / (norm_1 * norm_2))
29 self.assertAlmostEqual(
30 angle * 180 / math.pi, 30.0, delta=TestSketcher.DELTA
33 if __name__ == "__main__":