Skip to content

Commit

Permalink
Break up spirals into quarter circles for JLCPCB
Browse files Browse the repository at this point in the history
  • Loading branch information
gmlewis committed May 10, 2019
1 parent 2bdca8e commit 7c2291c
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions examples/bifilar-with-capacitor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,15 @@ func main() {

top := g.TopCopper()
top.Add(
Polygon(Pt{0, 0}, true, spiralT, 0.0),
Circle(startT, padD),
Circle(centerHole, padD),
Circle(topOuter, padD),
Circle(botOuter, padD),
padLine(topOuter, endT),
)
for _, pts := range spiralT {
top.Add(Polygon(Pt{0, 0}, true, pts, 0.0))
}

topMask := g.TopSolderMask()
topMask.Add(
Expand All @@ -105,14 +107,16 @@ func main() {

bottom := g.BottomCopper()
bottom.Add(
Polygon(Pt{0, 0}, true, spiralB, 0.0),
Circle(startT, padD),
Circle(centerHole, padD),
padLine(startB, centerHole),
Circle(topOuter, padD),
Circle(botOuter, padD),
padLine(botOuter, endB),
)
for _, pts := range spiralB {
bottom.Add(Polygon(Pt{0, 0}, true, pts, 0.0))
}

bottomMask := g.BottomSolderMask()
bottomMask.Add(
Expand Down Expand Up @@ -243,22 +247,35 @@ func newSpiral() *spiral {
}

func (s *spiral) genSpiral(
startAngleOffset, endAngleOffset float64) (startPt, endPt Pt, pts []Pt) {
startAngleOffset, endAngleOffset float64) (startPt, endPt Pt, pts [][]Pt) {
start := s.startAngle + startAngleOffset
end := s.endAngle + endAngleOffset
halfTW := *trace * 0.5

quarterSteps := int(0.5 + math.Pi / *step)
steps := int(0.5 + (end-start) / *step)
for i := 0; i < steps; i++ {
for i := 0; i < steps; i += (quarterSteps - 1) {
section := genSpiralSection(i, quarterSteps, steps, start, end)
pts = append(pts, section)
}
return genPt(start, 0.0, 0.0), genPt(end, 0.0, 0.0), pts
}

func genSpiralSection(startCount, quarterSteps, steps int, start, end float64) (pts []Pt) {
halfTW := *trace * 0.5

i := startCount
for ; i <= startCount+quarterSteps && i < steps; i++ {
angle := start + *step*float64(i)
pts = append(pts, genPt(angle, halfTW, 0.0))
}
pts = append(pts, genPt(end, halfTW, 0.0))
pts = append(pts, genPt(end, -halfTW, 0.0))
for i := steps - 1; i >= 0; i-- {
if i >= steps {
pts = append(pts, genPt(end, halfTW, 0.0))
pts = append(pts, genPt(end, -halfTW, 0.0))
}
for i--; i >= startCount; i-- {
angle := start + *step*float64(i)
pts = append(pts, genPt(angle, -halfTW, 0.0))
}
pts = append(pts, pts[0])
return genPt(start, 0.0, 0.0), genPt(end, 0.0, 0.0), pts
return pts
}

0 comments on commit 7c2291c

Please sign in to comment.