summaryrefslogtreecommitdiff
path: root/gerberex/utility.py
diff options
context:
space:
mode:
authorHiroshi Murayama <opiopan@gmail.com>2019-12-28 23:45:33 +0900
committerHiroshi Murayama <opiopan@gmail.com>2019-12-28 23:45:33 +0900
commit244fcaa5346f4fad819cc2b72857cfb2c472944a (patch)
treed849592e18a1afe61fb98f3207dabdaea1f5336e /gerberex/utility.py
parentd7a069324222bb8f69adc9b1c815fc9f3f6a29d6 (diff)
downloadgerbonara-244fcaa5346f4fad819cc2b72857cfb2c472944a.tar.gz
gerbonara-244fcaa5346f4fad819cc2b72857cfb2c472944a.tar.bz2
gerbonara-244fcaa5346f4fad819cc2b72857cfb2c472944a.zip
add a function that generate filled gerberdata with representing internal shape by fliping polarity
Diffstat (limited to 'gerberex/utility.py')
-rw-r--r--gerberex/utility.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/gerberex/utility.py b/gerberex/utility.py
index 4c89fa6..37de5e8 100644
--- a/gerberex/utility.py
+++ b/gerberex/utility.py
@@ -3,7 +3,7 @@
# Copyright 2019 Hiroshi Murayama <opiopan@gmail.com>
-from math import cos, sin, pi
+from math import cos, sin, pi, sqrt
def rotate(x, y, angle, center):
x0 = x - center[0]
@@ -18,3 +18,10 @@ def is_equal_value(a, b, error_range=0):
def is_equal_point(a, b, error_range=0):
return is_equal_value(a[0], b[0], error_range) and \
is_equal_value(a[1], b[1], error_range)
+
+def normalize_vec2d(vec):
+ length = sqrt(vec[0] * vec[0] + vec[1] * vec[1])
+ return (vec[0] / length, vec[1] / length)
+
+def dot_vec2d(vec1, vec2):
+ return vec1[0] * vec2[0] + vec1[1] * vec2[1] \ No newline at end of file