This repository has been archived by the owner on Aug 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathboardspacer.go
99 lines (87 loc) · 2.17 KB
/
boardspacer.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package main
import (
"log"
"github.com/soypat/sdf"
"github.com/soypat/sdf/form2/obj2"
"github.com/soypat/sdf/form3/obj3"
"github.com/soypat/sdf/helpers/matter"
"github.com/soypat/sdf/render"
"gonum.org/v1/gonum/spatial/r2"
"gonum.org/v1/gonum/spatial/r3"
)
const (
baseWidth = 100.0
baseLength = 100.0
baseThickness = 2.4
frontPanelThickness = 3.0
frontPanelLength = 170.0
frontPanelHeight = 50.0
frontPanelYOffset = 15.0
holeWidth = 4.0
pillarHeight = 7
)
var material = matter.PLA
func main() {
b := base()
err := render.CreateSTL("pcb_base.stl", render.NewOctreeRenderer(b, 200))
if err != nil {
log.Fatal(err)
}
}
// base returns the base mount.
func base() sdf.SDF3 {
// base
pp := obj2.PanelParams{
Size: r2.Vec{baseLength, baseWidth},
CornerRadius: holeWidth * 1.2,
HoleDiameter: material.InternalDimScale(holeWidth),
HoleMargin: [4]float64{4.5, 4.5, 4.5, 4.5},
HolePattern: [4]string{"x", "x", "x", "x"},
}
pan, err := obj2.Panel(pp)
if err != nil {
panic(err)
}
s2 := sdf.Extrude3D(pan, baseThickness)
xOfs := 0.5 * baseLength
yOfs := 0.5 * baseWidth
s2 = sdf.Transform3D(s2, sdf.Translate3D(r3.Vec{xOfs, yOfs, 0}))
// standoffs
zOfs := 0.5 * (pillarHeight + baseThickness)
m4Positions := []r3.Vec{
// Regular board spacing
{4.5, 4.5, zOfs}, {4.5, 95.5, zOfs}, {95.5, 95.5, zOfs}, {95.5, 4.5, zOfs},
{60, 30, zOfs},
{60, 70, zOfs},
// {40, 50, zOfs},
// {60, 50, zOfs},
}
m4Standoffs := standoffs(4, m4Positions)
m3Positions := []r3.Vec{
{9, 35.5, zOfs},
{9, 62.5, zOfs},
{91, 64.5, zOfs},
{91, 37.5, zOfs},
{35.5, 91, zOfs},
{62.5, 91, zOfs},
}
m3Standoffs := standoffs(3, m3Positions)
s4 := sdf.Union3D(s2, m4Standoffs, m3Standoffs)
s4.SetMin(sdf.MinPoly(2, 3.0))
return s4
}
// multiple standoffs
func standoffs(holeWidth float64, positions []r3.Vec) sdf.SDF3 {
k := obj3.StandoffParams{
PillarHeight: pillarHeight,
PillarDiameter: holeWidth * 2,
HoleDepth: pillarHeight + baseThickness,
HoleDiameter: material.InternalDimScale(holeWidth),
}
// from the board mechanicals
s, err := obj3.Standoff(k)
if err != nil {
panic(err)
}
return sdf.Multi3D(s, positions)
}