Skip to content
This repository has been archived by the owner on Oct 7, 2020. It is now read-only.

Ring pad support inspired by wuerth electronics smd mounting hardware #351

Merged
merged 39 commits into from
Oct 5, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
1829761
copper only ring pad prototype
poeschlr May 8, 2019
08f04bf
Workaround for mask margin bugs
poeschlr May 8, 2019
43d3007
Workaround for single paste zone (kicad bug)
poeschlr May 8, 2019
e7a2549
add interface to rotate a vector2d around a given origin
poeschlr May 8, 2019
64d2f17
handle solder paste parameters
poeschlr May 8, 2019
98603c8
use rotate function instead of calculating coordinates
poeschlr May 8, 2019
684e006
added polar coordinate handling to Vector2D
poeschlr May 9, 2019
b1c455b
extended arc interface
poeschlr May 9, 2019
a64340f
ensure -0 is not created by float formater
poeschlr May 10, 2019
19f3de8
More arc testcases
poeschlr May 10, 2019
03bd06c
ode style
poeschlr May 10, 2019
7a50885
python 2 compatibility
poeschlr May 10, 2019
12bc2f6
add rotation interface for basic nodes
poeschlr May 10, 2019
53b59eb
Add translation and intersection
poeschlr May 11, 2019
e008043
Add docstrings
poeschlr May 11, 2019
01a5f19
intersection supports arcs
poeschlr May 11, 2019
2957b34
cut line implemented
poeschlr May 11, 2019
244847b
Introduced geometric base clases for lines, circles and arcs
poeschlr May 12, 2019
6719d3f
Add cut functionallity to arcs
poeschlr May 12, 2019
f942451
arc pad primitive used for paste parts of ring pad
poeschlr May 13, 2019
4ddd2c3
Finish paste pad handling for ring pads
poeschlr May 14, 2019
3dca632
cleanups and docu
poeschlr May 14, 2019
3bda5f9
Correct overlap, paste radius and arc width calculation
poeschlr May 25, 2019
de61209
correct handling of paste to paste clearance
poeschlr May 26, 2019
c159b56
Add commandline interface script for generating ring pads
poeschlr May 26, 2019
f2a46bb
Add wuerth smt mouniting hardware with inner through hole
poeschlr May 26, 2019
ac37b7f
klc fixes
poeschlr May 26, 2019
191f472
fix ring pad paste for 2 zones
poeschlr May 27, 2019
3c2728b
Add M1.6 (including blind hole) and new naming convention
poeschlr May 27, 2019
9e7cb69
add reverse type
poeschlr May 27, 2019
f127438
add snap rivet version
poeschlr May 27, 2019
961ca20
script renamed to reflect the fact that it is generic
poeschlr May 28, 2019
23be404
add external thread version
poeschlr May 28, 2019
9f6bfe5
add maximum round radius to ring pad
poeschlr May 28, 2019
cb79753
handle 0 inner diameter
poeschlr May 28, 2019
6385473
add non npth version
poeschlr May 28, 2019
e12a59c
rename script folder to reflect the generic content
poeschlr May 29, 2019
a0706d7
Improved naming and description
poeschlr May 29, 2019
3244af2
typo in description
poeschlr Sep 1, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add translation and intersection
  • Loading branch information
poeschlr committed May 11, 2019
commit 53b59eb97f7192be6387c6180640c9a98149f698
8 changes: 8 additions & 0 deletions KicadModTree/PolygonPoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,14 @@ def rotate(self, angle, origin=(0, 0), use_degrees=True):
p.rotate(angle=angle, origin=origin, use_degrees=use_degrees)
return self

def translate(self, distance_vector):
for p in self.nodes:
p += distance_vector
return self

def __copy__(self):
return PolygonPoints(nodes=self.nodes)

def __iter__(self):
for n in self.nodes:
yield n
Expand Down
20 changes: 20 additions & 0 deletions KicadModTree/Vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,13 @@ def from_polar(radius, angle, origin=(0, 0), use_degrees=True):

return Vector2D({'x': x, 'y': y})+Vector2D(origin)

def to_homogeneous(self):
return Vector3D(self.x, self.y, 1)

@staticmethod
def from_homogeneous(source):
return Vector2D(source.x/source.z, source.y/source.z)


class Vector3D(Vector2D):
r"""Representation of a 3D Vector in space
Expand Down Expand Up @@ -298,6 +305,19 @@ def round_to(self, base):

return Vector3D([round(v / base) * base for v in self])

def cross_product(self, other):
other = Vector3D.__arithmetic_parse(other)

return Vector3D({
'x': self.y*other.z - self.z*other.y,
'y': self.z*other.x - self.x*other.z,
'z': self.x*other.y - self.y*other.x})

def dot_product(self, other):
other = Vector3D.__arithmetic_parse(other)

return self.x*other.x + self.y*other.y + self.z*other.z

Comment on lines +352 to +364
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above: this seems to be unused.
Can you give an example use-case for those functions?

@staticmethod
def __arithmetic_parse(value):
if isinstance(value, Vector3D):
Expand Down
5 changes: 5 additions & 0 deletions KicadModTree/nodes/base/Arc.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ def rotate(self, angle, origin=(0, 0), use_degrees=True):
self.start_pos.rotate(angle=angle, origin=origin, use_degrees=use_degrees)
return self

def translate(self, distance_vector):
self.center_pos += distance_vector
self.start_pos += distance_vector
return self

def calculateBoundingBox(self):
# TODO: finish implementation
min_x = min(self.start_pos.x, self._calulateEndPos().x)
Expand Down
5 changes: 5 additions & 0 deletions KicadModTree/nodes/base/Circle.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ def rotate(self, angle, origin=(0, 0), use_degrees=True):
self._calcEndPos()
return self

def translate(self, distance_vector):
self.center_pos += distance_vector
self._calcEndPos()
return self

def calculateBoundingBox(self):
min_x = self.center_pos.x-self.radius
min_y = self.center_pos.y-self.radius
Expand Down
13 changes: 13 additions & 0 deletions KicadModTree/nodes/base/Line.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,19 @@ def rotate(self, angle, origin=(0, 0), use_degrees=True):
self.end_pos.rotate(angle=angle, origin=origin, use_degrees=use_degrees)
return self

def translate(self, distance_vector):
self.start_pos += distance_vector
self.end_pos += distance_vector
return self

def cut(self, other, second_point=(0, 0)):
pass

def to_homogeneous(self):
p1 = self.start_pos.to_homogeneous()
p2 = self.end_pos.to_homogeneous()
return p1.cross_product(p2)

def calculateBoundingBox(self):
render_start_pos = self.getRealPosition(self.start_pos)
render_end_pos = self.getRealPosition(self.end_pos)
Expand Down
4 changes: 4 additions & 0 deletions KicadModTree/nodes/base/Pad.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ def rotate(self, angle, origin=(0, 0), use_degrees=True):
self.rotation -= a
return self

def translate(self, distance_vector):
self.at += distance_vector
return self

# calculate the outline of a pad
def calculateBoundingBox(self):
return Node.calculateBoundingBox(self)
Expand Down
4 changes: 4 additions & 0 deletions KicadModTree/nodes/base/Polygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ def rotate(self, angle, origin=(0, 0), use_degrees=True):
self.nodes.rotate(angle=angle, origin=origin, use_degrees=use_degrees)
return self

def translate(self, distance_vector):
self.nodes.translate(distance_vector)
return self

def calculateBoundingBox(self):
return nodes.calculateBoundingBox()

Expand Down
4 changes: 4 additions & 0 deletions KicadModTree/nodes/base/Text.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ def rotate(self, angle, origin=(0, 0), use_degrees=True):
self.rotation -= a
return self

def translate(self, distance_vector):
self.at += distance_vector
return self

def calculateBoundingBox(self):
width = len(self.text)*self.size['x']
height = self.size['y']
Expand Down
64 changes: 64 additions & 0 deletions KicadModTree/util/geometric_util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# KicadModTree is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# KicadModTree is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with kicad-footprint-generator. If not, see < http://www.gnu.org/licenses/ >.
#
# (C) 2016-2018 by Thomas Pointhuber, <thomas.pointhuber@gmx.at>

import math
from KicadModTree.nodes.base import *
from KicadModTree.Vector import *


class BaseNodeIntersection():

@staticmethod
def intersectTwoLines(line1, line2):
# we use homogeneous coordinates here.
l1 = line1.to_homogeneous()
l2 = line2.to_homogeneous()

ip = l1.cross_product(l2)
if ip.z == 0:
return None

return Vector2D.from_homogeneous(ip)

@staticmethod
def intersectLineWithCircle(line, circle):
# from http://mathworld.wolfram.com/Circle-LineIntersection.html
# Equations are for circle center on (0, 0) so we translate everything
# to the orign (well the line anyways as we do only need the radius of the circle)
lt = Line(start=line.start_pos, end=line.end_pos).translate(-circle.center_pos)

d = lt.end_pos - lt.start_pos
dr = math.hypot(d.x, d.y)
D = lt.start_pos.x*lt.end_pos.y - lt.end_pos.x*lt.start_pos.y

discriminant = circle.radius**2 * dr**2 - D**2
intersection = []
if discriminant < 0:
return intersection

intersection.append(
Vector2D({
'x': (D*d.y + math.copysign(1, d.y)*d.x*math.sqrt(discriminant))/dr**2,
'y': (-D*d.x + abs(d.y)*math.sqrt(discriminant))/dr**2
}) + circle.center_pos)
if discriminant == 0:
return intersection

intersection.append(
Vector2D({
'x': (D*d.y - math.copysign(1, d.y)*d.x*math.sqrt(discriminant))/dr**2,
'y': (-D*d.x - abs(d.y)*math.sqrt(discriminant))/dr**2
}) + circle.center_pos)
return intersection