|
1 | | -# go-module-template |
2 | | -[](https://pkg.go.dev/github.com/soypat/go-module-template) |
3 | | -[](https://goreportcard.com/report/github.com/soypat/go-module-template) |
4 | | -[](https://codecov.io/gh/soypat/go-module-template) |
5 | | -[](https://github.com/soypat/go-module-template/actions/workflows/go.yml) |
6 | | -[](https://github.com/emersion/stability-badges#frozen) |
7 | | -[](https://sourcegraph.com/github.com/soypat/go-module-template?badge) |
8 | | -<!-- |
9 | | -[](https://opensource.org/licenses/MIT) |
10 | | -
|
11 | | -[](https://github.com/emersion/stability-badges#experimental) |
12 | | -
|
13 | | -See https://github.com/emersion/stability-badges#unstable for more stability badges. |
14 | | ---> |
15 | | - |
16 | | -Go module template with instructions on how to make your code importable and setting up codecov CI. |
17 | | - |
18 | | -How to install package with newer versions of Go (+1.16): |
19 | | -```sh |
20 | | -go mod download github.com/soypat/go-module-template@latest |
21 | | -``` |
22 | | - |
23 | | - |
24 | | -## First steps |
25 | | - |
26 | | -0. Replace LICENSE with your desired license. BSD 3 clause is included by default. |
27 | | - |
28 | | -1. Fix `go.mod` file by replacing `github.com/YOURUSER/YOURREPONAME` with your corresponding project repository link. |
29 | | - |
30 | | -2. Replace `soypat/go-module-template` in the badge URLs. Make sure you've replaced all of them by performing text search in the readme for `soypat` and `template`. |
31 | | - |
32 | | -3. Rename `module.go` and `module_test.go` to fit your own repository needs. Below are some exemplary modules that abide by what's generally considered "good practices": |
33 | | - - [`mu8` minimal machine learning library](https://github.com/soypat/mu8). Note how most interfaces and interface algorithms are defined at the root package level and how the concrete implementations live in the subdirectories. |
34 | | - - Similarily [`sdf`](https://github.com/soypat/sdf) also does the same with defining interfaces top level. |
35 | | - |
36 | | -## Setting up codecov CI |
37 | | -This instructive will allow for tests to run on pull requests and pushes to your repository. |
38 | | - |
39 | | -1. Create an account on [codecov.io](https://app.codecov.io/) |
40 | | - |
41 | | -2. Setup repository on codecov and obtain the CODECOV_TOKEN token, which is a string of base64 characters. |
42 | | - |
43 | | -3. Open up the github repository for this project and go to `Settings -> Secrets and variables -> Actions`. Once there create a New Repository Secret. Name it `CODECOV_TOKEN` and copy paste the token obtained in the previous step in the `secret` input box. Click "Add secret". |
44 | | - |
45 | | - |
| 1 | +# gsdf |
| 2 | +Offshoot from [this project](https://github.com/soypat/sdf/pull/13). Is WIP. |
| 3 | + |
| 4 | +## Features |
| 5 | + |
| 6 | +- Heapless algorithms for everything. No usage of GC in happy path. |
| 7 | +- Generate visualization for your parts as shaders. |
| 8 | +- Heapless Octree triangle renderer. Is stupid fast. |
| 9 | +- GPU and CPU implementations for all shapes and operations. CPU implementations are actually faster for simple parts. |
| 10 | + - Design your part using one API, switch between CPU and GPU after design. |
| 11 | +- Extremely coherent API design. |
| 12 | + |
| 13 | +## NPT Flange example. |
| 14 | +This was converted from the [original example](https://github.com/soypat/sdf/blob/main/examples/npt-flange/flange.go). See [README](https://github.com/soypat/sdf/tree/main/examples) for images. |
| 15 | +```go |
| 16 | +var ( |
| 17 | + npt threads.NPT |
| 18 | + flange glbuild.Shader3D |
| 19 | +) |
| 20 | +npt.SetFromNominal(1.0 / 2.0) |
| 21 | +pipe, err := threads.Nut(threads.NutParms{ |
| 22 | + Thread: npt, |
| 23 | + Style: threads.NutCircular, |
| 24 | +}) |
| 25 | +if err != nil { |
| 26 | + panic(err) |
| 27 | +} |
| 28 | + |
| 29 | +flange, err = gsdf.NewCylinder(flangeD/2, flangeH, flangeH/8) |
| 30 | +return makeSDF(flange) |
| 31 | +if err != nil { |
| 32 | + return nil, err |
| 33 | +} |
| 34 | +flange = gsdf.Translate(flange, 0, 0, -tlen/2) |
| 35 | +flange = gsdf.SmoothUnion(pipe, flange, 0.2) |
| 36 | +hole, err := gsdf.NewCylinder(internalDiameter/2, 4*flangeH, 0) |
| 37 | +if err != nil { |
| 38 | + return nil, err |
| 39 | +} |
| 40 | +flange = gsdf.Difference(flange, hole) // Make through-hole in flange bottom |
| 41 | +flange = gsdf.Scale(flange, 25.4) // convert to millimeters |
| 42 | + |
| 43 | +render(flange) // Do something with it. |
| 44 | +``` |
0 commit comments