Skip to content
This repository has been archived by the owner on Aug 12, 2024. It is now read-only.

Commit

Permalink
add sdf3ui to highlights
Browse files Browse the repository at this point in the history
  • Loading branch information
soypat committed May 16, 2022
1 parent 6deeb5d commit 44f6b70
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
A rewrite of the original CAD package [`sdfx`](https://github.com/deadsy/sdfx) for generating 2D and 3D geometry using [Go](https://go.dev/).

## Highlights
* GUI with real-time rendering using [sdf3ui](https://github.com/soypat/sdf3ui).
* 3d and 2d objects modelled with signed distance functions (SDFs).
* Minimal and idiomatic API.
* Render objects as triangles or save to STL, 3MF(experimental) file format.
Expand Down
8 changes: 8 additions & 0 deletions internal/d3/box.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ func NewBox(center, size r3.Vec) Box {
return Box{Min: r3.Sub(center, half), Max: r3.Add(center, half)}
}

// CenteredBox creates a Box with a given center and size.
// Negative components of size will be interpreted as zero.
func CenteredBox(center, size r3.Vec) Box {
size = MaxElem(size, r3.Vec{}) // set negative values to zero.
half := r3.Scale(0.5, size)
return Box{Min: r3.Sub(center, half), Max: r3.Add(center, half)}
}

// Equals test the equality of 3d boxes.
func (a Box) Equals(b Box, tol float64) bool {
return EqualWithin(a.Min, b.Min, tol) && EqualWithin(a.Max, b.Max, tol)
Expand Down

0 comments on commit 44f6b70

Please sign in to comment.