Skip to content

Commit

Permalink
fix npt flange example
Browse files Browse the repository at this point in the history
  • Loading branch information
soypat committed Aug 17, 2024
1 parent e5576ab commit 44e5046
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,19 @@ This was converted from the [original example](https://github.com/soypat/sdf/blo
Thread: npt,
Style: threads.NutCircular,
})

// Base plate which goes bolted to joint.
flange, _ = gsdf.NewCylinder(flangeD/2, flangeH, flangeH/8)
// Make through-hole in flange bottom.
hole, _ := gsdf.NewCylinder(internalDiameter/2, flangeH, 0)
flange = gsdf.Difference(flange, hole)

// Join threaded section with flange.
flange = gsdf.Translate(flange, 0, 0, -tlen/2)
union := gsdf.SmoothUnion(pipe, flange, 0.2)
union = gsdf.Scale(union, 1)

// Make through-hole in flange bottom. Holes usually done at the end
// to avoid smoothing effects covering up desired negative space.
hole, _ := gsdf.NewCylinder(internalDiameter/2, 4*flangeH, 0)
union = gsdf.Difference(union, hole)
// Convert from imperial inches units to millimeter:
union = gsdf.Scale(union, 25.4)
renderSDF(union)
```
14 changes: 8 additions & 6 deletions examples/npt-flange/flange.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,21 @@ func scene() (gleval.SDF3, error) {

pipe, _ := threads.Nut(threads.NutParms{
Thread: npt,
Style: threads.NutHex,
Style: threads.NutCircular,
})
pipe = gsdf.Scale(pipe, 100)
return makeSDF(pipe)

// Base plate which goes bolted to joint.
flange, _ = gsdf.NewCylinder(flangeD/2, flangeH, flangeH/8)
// Make through-hole in flange bottom.
hole, _ := gsdf.NewCylinder(internalDiameter/2, 4*flangeH, 0)
flange = gsdf.Difference(flange, hole)

// Join threaded section with flange.
flange = gsdf.Translate(flange, 0, 0, -tlen/2)
union := gsdf.SmoothUnion(pipe, flange, 0.2)

// Make through-hole in flange bottom. Holes usually done at the end
// to avoid smoothing effects covering up desired negative space.
hole, _ := gsdf.NewCylinder(internalDiameter/2, 4*flangeH, 0)
union = gsdf.Difference(union, hole)
// Convert from imperial inches units to millimeter:
union = gsdf.Scale(union, 25.4)
return makeSDF(union)
}
Expand Down

0 comments on commit 44e5046

Please sign in to comment.