From 57941b1b76ffbdb9a5eeb9fef5e3c2365e3a4b84 Mon Sep 17 00:00:00 2001 From: jaseg Date: Sat, 5 Feb 2022 12:34:28 +0100 Subject: Arc approx WIP --- examples/test_arc_approx.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 examples/test_arc_approx.py (limited to 'examples/test_arc_approx.py') diff --git a/examples/test_arc_approx.py b/examples/test_arc_approx.py new file mode 100644 index 0000000..76d4116 --- /dev/null +++ b/examples/test_arc_approx.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 + +import math + +from gerbonara.graphic_objects import Arc +from gerbonara.graphic_objects import rotate_point + + +def approx_test(): + print('') + print('') + n = 16 + eps = 1/n*2*math.pi + cx, cy = 0, 0 + for clockwise in False, True: + for start_angle in range(n): + cx, cy = 0, cy+2.5 + for sweep_angle in range(n): + for color, max_error in zip(['black', 'red', 'blue', 'magenta'], [0.1, 0.3, 1, 3]): + cx = cx+2.5 + + x1, y1 = rotate_point(0, -1, start_angle*eps) + x2, y2 = rotate_point(x1, y1, sweep_angle*eps*(-1 if clockwise else 1)) + + arc = Arc(x1+cx, y1+cy, x2+cx, y2+cy, -x1, -y1, clockwise=clockwise, aperture=None, polarity_dark=True) + lines = arc.approximate(max_error=max_error) + + print(f'') + print('') + + +if __name__ == '__main__': + approx_test() -- cgit