From f4b2e74923cc95c683cd7f5c4732d92e4aafd3ba Mon Sep 17 00:00:00 2001 From: jaseg Date: Thu, 30 Dec 2021 16:40:14 +0100 Subject: Fix rotation bugs, all tests run through --- gerbonara/gerber/graphic_primitives.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'gerbonara/gerber/graphic_primitives.py') diff --git a/gerbonara/gerber/graphic_primitives.py b/gerbonara/gerber/graphic_primitives.py index c917365..de1a0bc 100644 --- a/gerbonara/gerber/graphic_primitives.py +++ b/gerbonara/gerber/graphic_primitives.py @@ -12,12 +12,11 @@ class GraphicPrimitive: polarity_dark : bool = True -def rotate_point(x, y, angle, cx=None, cy=None): - if cx is None: - return (x, y) - else: - return (cx + (x - cx) * math.cos(angle) - (y - cy) * math.sin(angle), - cy + (x - cx) * math.sin(angle) + (y - cy) * math.cos(angle)) +def rotate_point(x, y, angle, cx=0, cy=0): + """ rotate point (x,y) around (cx,cy) clockwise angle radians """ + + return (cx + (x - cx) * math.cos(-angle) - (y - cy) * math.sin(-angle), + cy + (x - cx) * math.sin(-angle) + (y - cy) * math.cos(-angle)) @dataclass -- cgit