diff options
author | jaseg <git@jaseg.de> | 2021-12-30 16:40:14 +0100 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2021-12-30 16:40:14 +0100 |
commit | f4b2e74923cc95c683cd7f5c4732d92e4aafd3ba (patch) | |
tree | f713a247d3cc2c11463be1af54ff42b0cd9dfb44 /gerbonara/gerber/aperture_macros/parse.py | |
parent | e4941dd5e371e8c9e729a72b8ec30d021bceb0cc (diff) | |
download | gerbonara-f4b2e74923cc95c683cd7f5c4732d92e4aafd3ba.tar.gz gerbonara-f4b2e74923cc95c683cd7f5c4732d92e4aafd3ba.tar.bz2 gerbonara-f4b2e74923cc95c683cd7f5c4732d92e4aafd3ba.zip |
Fix rotation bugs, all tests run through
Diffstat (limited to 'gerbonara/gerber/aperture_macros/parse.py')
-rw-r--r-- | gerbonara/gerber/aperture_macros/parse.py | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/gerbonara/gerber/aperture_macros/parse.py b/gerbonara/gerber/aperture_macros/parse.py index f1e2150..6eed381 100644 --- a/gerbonara/gerber/aperture_macros/parse.py +++ b/gerbonara/gerber/aperture_macros/parse.py @@ -114,10 +114,11 @@ class ApertureMacro: return [ primitive.to_graphic_primitives(offset, rotation, variables, unit) for primitive in self.primitives ] def rotated(self, angle): - copy = copy.deepcopy(self) - for primitive in copy.primitives: - primitive.rotation += rad_to_deg(angle) - return copy + dup = copy.deepcopy(self) + for primitive in dup.primitives: + # aperture macro primitives use degree counter-clockwise, our API uses radians clockwise + primitive.rotation -= rad_to_deg(angle) + return dup cons, var = ConstantExpression, VariableExpression @@ -127,26 +128,28 @@ class GenericMacros: _generic_hole = lambda n: [ ap.Circle(None, [0, var(n), 0, 0]), - ap.CenterLine(None, [0, var(n), var(n+1), 0, 0, var(n+2) * deg_per_rad])] + ap.CenterLine(None, [0, var(n), var(n+1), 0, 0, var(n+2) * -deg_per_rad])] # Initialize all these with "None" units so they inherit file units, and do not convert their arguments. + # NOTE: All generic macros have rotation values specified in **clockwise radians** like the rest of the user-facing + # API. circle = ApertureMacro('GNC', [ - ap.Circle(None, [1, var(1), 0, 0, var(4) * deg_per_rad]), + ap.Circle(None, [1, var(1), 0, 0, var(4) * -deg_per_rad]), *_generic_hole(2)]) rect = ApertureMacro('GNR', [ - ap.CenterLine(None, [1, var(1), var(2), 0, 0, var(5) * deg_per_rad]), + ap.CenterLine(None, [1, var(1), var(2), 0, 0, var(5) * -deg_per_rad]), *_generic_hole(3) ]) # w must be larger than h obround = ApertureMacro('GNO', [ - ap.CenterLine(None, [1, var(1), var(2), 0, 0, var(5) * deg_per_rad]), - ap.Circle(None, [1, var(2), +var(1)/2, 0, var(5) * deg_per_rad]), - ap.Circle(None, [1, var(2), -var(1)/2, 0, var(5) * deg_per_rad]), + ap.CenterLine(None, [1, var(1), var(2), 0, 0, var(5) * -deg_per_rad]), + ap.Circle(None, [1, var(2), +var(1)/2, 0, var(5) * -deg_per_rad]), + ap.Circle(None, [1, var(2), -var(1)/2, 0, var(5) * -deg_per_rad]), *_generic_hole(3) ]) polygon = ApertureMacro('GNP', [ - ap.Polygon(None, [1, var(2), 0, 0, var(1), var(3) * deg_per_rad]), + ap.Polygon(None, [1, var(2), 0, 0, var(1), var(3) * -deg_per_rad]), ap.Circle(None, [0, var(4), 0, 0])]) |