summaryrefslogtreecommitdiff
path: root/gerbonara/cad/kicad/symbols.py
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2023-10-26 23:53:23 +0200
committerjaseg <git@jaseg.de>2023-10-26 23:53:23 +0200
commit36da1fd68bcfb44957d370584231545cee0b2e20 (patch)
tree7bf1730a71392ab3de33010a56edf3ce0a2a09e6 /gerbonara/cad/kicad/symbols.py
parent9624e46147755d221c8e7cf519e9ecd416381857 (diff)
downloadgerbonara-36da1fd68bcfb44957d370584231545cee0b2e20.tar.gz
gerbonara-36da1fd68bcfb44957d370584231545cee0b2e20.tar.bz2
gerbonara-36da1fd68bcfb44957d370584231545cee0b2e20.zip
Fix failing test cases
Diffstat (limited to 'gerbonara/cad/kicad/symbols.py')
-rw-r--r--gerbonara/cad/kicad/symbols.py27
1 files changed, 3 insertions, 24 deletions
diff --git a/gerbonara/cad/kicad/symbols.py b/gerbonara/cad/kicad/symbols.py
index baa77bb..ed93f7b 100644
--- a/gerbonara/cad/kicad/symbols.py
+++ b/gerbonara/cad/kicad/symbols.py
@@ -20,6 +20,7 @@ from .base_types import *
from ...utils import rotate_point, Tag, arc_bounds
from ...newstroke import Newstroke
from .schematic_colors import *
+from .primitives import center_arc_to_kicad_mid
PIN_ETYPE = AtomChoice(Atom.input, Atom.output, Atom.bidirectional, Atom.tri_state, Atom.passive, Atom.free,
@@ -249,28 +250,6 @@ class Circle:
**self.stroke.svg_attrs(colorscheme.lines))
-# https://stackoverflow.com/questions/28910718/give-3-points-and-a-plot-circle
-def define_circle(p1, p2, p3):
- """
- Returns the center and radius of the circle passing the given 3 points.
- In case the 3 points form a line, raises a ValueError.
- """
- temp = p2[0] * p2[0] + p2[1] * p2[1]
- bc = (p1[0] * p1[0] + p1[1] * p1[1] - temp) / 2
- cd = (temp - p3[0] * p3[0] - p3[1] * p3[1]) / 2
- det = (p1[0] - p2[0]) * (p2[1] - p3[1]) - (p2[0] - p3[0]) * (p1[1] - p2[1])
-
- if abs(det) < 1.0e-6:
- raise ValueError()
-
- # Center of circle
- cx = (bc*(p2[1] - p3[1]) - cd*(p1[1] - p2[1])) / det
- cy = ((p1[0] - p2[0]) * cd - (p2[0] - p3[0]) * bc) / det
-
- radius = math.sqrt((cx - p1[0])**2 + (cy - p1[1])**2)
- return ((cx, cy), radius)
-
-
@sexp_type('arc')
class Arc:
start: Rename(XYCoord) = field(default_factory=XYCoord)
@@ -280,7 +259,7 @@ class Arc:
fill: Fill = field(default_factory=Fill)
def bounding_box(self, default=None):
- (cx, cy), r = define_circle((self.start.x, self.start.y), (self.mid.x, self.mid.y), (self.end.x, self.end.y))
+ (cx, cy), r = center_arc_to_kicad_mid(self.mid, self.start, self.end)
x1, y1 = self.start.x, self.start.y
x2, y2 = self.mid.x-x1, self.mid.y-x2
x3, y3 = (self.end.x - x1)/2, (self.end.y - y1)/2
@@ -289,7 +268,7 @@ class Arc:
def to_svg(self, colorscheme=Colorscheme.KiCad):
- (cx, cy), r = define_circle((self.start.x, self.start.y), (self.mid.x, self.mid.y), (self.end.x, self.end.y))
+ (cx, cy), r = center_arc_to_kicad_mid(self.mid, self.start, self.end)
x1r = self.start.x - cx
y1r = self.start.y - cy