Documentation
¶
Overview ¶
Package cad provides a Go API for generating OpenSCAD code. It models CAD primitives (cubes, cylinders, spheres, etc.) and boolean/transform operations as Go types, and renders them to OpenSCAD syntax via a Document.
Index ¶
- type Box
- type CommonMutations
- func (c *CommonMutations) Difference(o ...Object) Object
- func (c *CommonMutations) Hull(o ...Object) Object
- func (c *CommonMutations) Intersection(o ...Object) Object
- func (c *CommonMutations) Minkowski(o ...Object) Object
- func (c *CommonMutations) Mirror(x float64, y float64, z float64) Object
- func (c *CommonMutations) Rotate(x float64, y float64, z float64) Object
- func (c *CommonMutations) Scale(x float64, y float64, z float64) Object
- func (c *CommonMutations) Translate(x float64, y float64, z float64) Object
- func (c *CommonMutations) Union(o ...Object) Object
- type Container
- type Cube
- type Cylinder
- type Difference
- type Document
- type ExtrudedPolygon
- type Hull
- type Intersection
- type Minkowski
- type Mirror
- type Object
- type Point2D
- type Rotate
- type RoundedCube
- type Scale
- type Sphere
- type Transform
- type Translate
- type Union
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Box ¶
type Box struct {
CommonMutations
// contains filtered or unexported fields
}
Box is a hollow rectangular box with optional rounded corners and a configurable wall thickness.
type CommonMutations ¶
type CommonMutations struct {
// contains filtered or unexported fields
}
CommonMutations is an embeddable struct that implements the transformation and boolean methods of the Object interface, delegating to its parent Object.
func (*CommonMutations) Difference ¶
func (c *CommonMutations) Difference(o ...Object) Object
Difference subtracts the provided objects from this object.
func (*CommonMutations) Hull ¶
func (c *CommonMutations) Hull(o ...Object) Object
Hull returns the convex hull of this object and the provided objects.
func (*CommonMutations) Intersection ¶
func (c *CommonMutations) Intersection(o ...Object) Object
Intersection returns the overlapping volume of this object and the provided objects.
func (*CommonMutations) Minkowski ¶
func (c *CommonMutations) Minkowski(o ...Object) Object
Minkowski returns the Minkowski sum of this object and the provided objects.
func (*CommonMutations) Mirror ¶
func (c *CommonMutations) Mirror(x float64, y float64, z float64) Object
Mirror reflects the object across the plane defined by the normal vector (x, y, z) and returns the resulting Object.
func (*CommonMutations) Rotate ¶
func (c *CommonMutations) Rotate(x float64, y float64, z float64) Object
Rotate rotates the object by (x, y, z) degrees around the respective axes and returns the resulting Object.
func (*CommonMutations) Scale ¶
func (c *CommonMutations) Scale(x float64, y float64, z float64) Object
Scale scales the object by factors (x, y, z) and returns the resulting Object.
func (*CommonMutations) Translate ¶
func (c *CommonMutations) Translate(x float64, y float64, z float64) Object
Translate moves the object by (x, y, z) and returns the resulting Object.
func (*CommonMutations) Union ¶
func (c *CommonMutations) Union(o ...Object) Object
Union combines this object with the provided objects into a merged solid.
type Container ¶
type Container struct {
CommonMutations
// contains filtered or unexported fields
}
Container is an internal base type that wraps a set of Objects inside a named OpenSCAD boolean operation block.
type Cube ¶
type Cube struct {
CommonMutations
// contains filtered or unexported fields
}
Cube is a rectangular box primitive.
type Cylinder ¶
type Cylinder struct {
CommonMutations
// contains filtered or unexported fields
}
Cylinder is a cylindrical primitive.
func NewCylinder ¶
NewCylinder creates a Cylinder with height h and radius r.
type Difference ¶
type Difference struct {
Container
}
Difference subtracts subsequent objects from the first object.
func NewDifference ¶
func NewDifference(o ...Object) *Difference
NewDifference creates a Difference from the provided objects.
type Document ¶
type Document struct {
Fn int
// contains filtered or unexported fields
}
Document holds a collection of Objects and global render settings, and produces a complete, formatted OpenSCAD source string.
func NewDocument ¶
NewDocument creates a Document containing the provided objects with a default $fn of 50.
type ExtrudedPolygon ¶
type ExtrudedPolygon struct {
CommonMutations
// contains filtered or unexported fields
}
ExtrudedPolygon is a 2-D polygon linearly extruded to height h.
func NewExtrudedPolygon ¶
func NewExtrudedPolygon(h float64, points ...Point2D) *ExtrudedPolygon
NewExtrudedPolygon creates an ExtrudedPolygon with the given height and vertex points.
type Hull ¶
type Hull struct {
Container
}
Hull produces the convex hull enclosing all child objects.
type Intersection ¶
type Intersection struct {
Container
}
Intersection produces the overlapping volume of all child objects.
func NewIntersection ¶
func NewIntersection(o ...Object) *Intersection
NewIntersection creates an Intersection from the provided objects.
type Minkowski ¶
type Minkowski struct {
Container
}
Minkowski computes the Minkowski sum of its child objects.
func NewMinkowski ¶
NewMinkowski creates a Minkowski from the provided objects.
type Object ¶
type Object interface {
Translate(x float64, y float64, z float64) Object
Mirror(x float64, y float64, z float64) Object
Rotate(x float64, y float64, z float64) Object
Scale(x float64, y float64, z float64) Object
Union(o ...Object) Object
Difference(o ...Object) Object
Hull(o ...Object) Object
Intersection(o ...Object) Object
Minkowski(o ...Object) Object
// contains filtered or unexported methods
}
Object is the core interface implemented by all CAD shapes and containers. It provides rendering to OpenSCAD syntax and fluent transformation methods.
type Point2D ¶
type Point2D struct {
// contains filtered or unexported fields
}
Point2D represents a 2-D point used to define polygon vertices.
func NewPoint2D ¶
NewPoint2D creates a Point2D at (x, y).
type RoundedCube ¶
type RoundedCube struct {
CommonMutations
// contains filtered or unexported fields
}
RoundedCube is a box primitive with rounded corners defined by a sphere radius.
func NewRoundedCube ¶
func NewRoundedCube( x float64, y float64, z float64, radius float64, ) *RoundedCube
NewRoundedCube creates a RoundedCube with dimensions x, y, z and corner radius.
func (*RoundedCube) Center ¶
func (r *RoundedCube) Center() Object
Center returns the RoundedCube translated so its geometric centre is at the origin.
type Sphere ¶
type Sphere struct {
CommonMutations
// contains filtered or unexported fields
}
Sphere is a spherical primitive.
type Transform ¶
type Transform struct {
CommonMutations
// contains filtered or unexported fields
}
Transform is an internal base type for OpenSCAD spatial transformation operations (translate, mirror, rotate, scale).


