Documentation ¶
Index ¶
- Constants
- func BenchmarkSDF2(description string, s SDF2)
- func BenchmarkSDF3(description string, s SDF3)
- func Clamp(x, a, b float64) float64
- func DtoR(degrees float64) float64
- func EqualFloat64(a, b, epsilon float64) bool
- func ErrMsg(msg string) error
- func FloatDecode(x float64) string
- func FloatEncode(s int, f uint64, e int) float64
- func GenerateMesh2D(s SDF2, grid v2i.Vec) (v2.VecSet, error)
- func LoadFont(fname string) (*truetype.Font, error)
- func Mix(x, y, a float64) float64
- func Nagon(n int, radius float64) v2.VecSet
- func Normal2(s SDF2, p v2.Vec, eps float64) v2.Vec
- func Normal3(s SDF3, p v3.Vec, eps float64) v3.Vec
- func NormalExtrude(p v3.Vec) v2.Vec
- func Raycast2(s SDF2, from, dir v2.Vec, scaleAndSigmoid, stepScale, epsilon, maxDist float64, ...) (v2.Vec, float64, int)
- func Raycast3(s SDF3, from, dir v3.Vec, scaleAndSigmoid, stepScale, epsilon, maxDist float64, ...) (collision v3.Vec, t float64, steps int)
- func RtoD(radians float64) float64
- func SawTooth(x, period float64) float64
- func Sign(x float64) float64
- func ZeroSmall(x, y, epsilon float64) float64
- type ArcSpiralSDF2
- type ArraySDF2
- type ArraySDF3
- type Bezier
- type BezierPolynomial
- type BezierSpline
- type BezierVertex
- type Box2
- func (a Box2) BottomLeft() v2.Vec
- func (a Box2) Center() v2.Vec
- func (a Box2) Contains(v v2.Vec) bool
- func (a Box2) Enlarge(v v2.Vec) Box2
- func (a Box2) Equals(b Box2, tolerance float64) bool
- func (a Box2) Extend(b Box2) Box2
- func (a Box2) Include(v v2.Vec) Box2
- func (a Box2) MinMaxDist2(p v2.Vec) v2.Vec
- func (a *Box2) Random() v2.Vec
- func (a *Box2) RandomSet(n int) v2.VecSet
- func (a Box2) ScaleAboutCenter(k float64) Box2
- func (a Box2) Size() v2.Vec
- func (a Box2) TopLeft() v2.Vec
- func (a Box2) Translate(v v2.Vec) Box2
- func (a Box2) Vertices() v2.VecSet
- type Box3
- func (a Box3) Center() v3.Vec
- func (a Box3) Contains(v v3.Vec) bool
- func (a Box3) Enlarge(v v3.Vec) Box3
- func (a Box3) Equals(b Box3, tolerance float64) bool
- func (a Box3) Extend(b Box3) Box3
- func (a Box3) Include(v v3.Vec) Box3
- func (a Box3) MinMaxDist2(p v3.Vec) v2.Vec
- func (a *Box3) Random() v3.Vec
- func (a *Box3) RandomSet(n int) v3.VecSet
- func (a Box3) ScaleAboutCenter(k float64) Box3
- func (a Box3) Size() v3.Vec
- func (a Box3) Translate(v v3.Vec) Box3
- func (a Box3) Vertices() v3.VecSet
- type BoxSDF2
- type BoxSDF3
- type CircleSDF2
- type ConeSDF3
- type CubicPolynomial
- type CubicSpline
- type CubicSplineSDF2
- type CutSDF2
- type CutSDF3
- type CylinderSDF3
- type DifferenceSDF2
- type DifferenceSDF3
- type ElongateSDF2
- type ElongateSDF3
- type ExtrudeFunc
- type ExtrudeRoundedSDF3
- type ExtrudeSDF3
- type Flange1
- type FlatFlankCamSDF2
- type GearRackParms
- type GearRackSDF2
- type GyroidSDF3
- type IntersectionSDF2
- type IntersectionSDF3
- type Line2
- type LineSDF2
- type LoftSDF3
- type M22
- type M33
- type M44
- func Identity3d() M44
- func MirrorXY() M44
- func MirrorXZ() M44
- func MirrorXeqY() M44
- func MirrorYZ() M44
- func RandomM44(a, b float64) M44
- func Rotate3d(v v3.Vec, a float64) M44
- func RotateToVector(a, b v3.Vec) M44
- func RotateX(a float64) M44
- func RotateY(a float64) M44
- func RotateZ(a float64) M44
- func Scale3d(v v3.Vec) M44
- func Translate3d(v v3.Vec) M44
- type Map2
- type MaxFunc
- type MinFunc
- type OffsetSDF2
- type OffsetSDF3
- type PolySDF2
- type Polygon
- type PolygonVertex
- type RotateCopySDF2
- type RotateCopySDF3
- type RotateUnionSDF2
- type RotateUnionSDF3
- type SDF2
- func ANSIButtressThread(radius float64, pitch float64) (SDF2, error)
- func AcmeThread(radius float64, pitch float64) (SDF2, error)
- func ArcSpiral2D(a, k float64, start, end float64, d float64) (SDF2, error)
- func Array2D(sdf SDF2, num v2i.Vec, step v2.Vec) SDF2
- func Box2D(size v2.Vec, round float64) SDF2
- func Center2D(s SDF2) SDF2
- func CenterAndScale2D(s SDF2, k float64) SDF2
- func Circle2D(radius float64) (SDF2, error)
- func CubicSpline2D(knot []v2.Vec) (SDF2, error)
- func Cut2D(sdf SDF2, a, v v2.Vec) SDF2
- func Difference2D(s0, s1 SDF2) SDF2
- func Elongate2D(sdf SDF2, h v2.Vec) SDF2
- func FlatFlankCam2D(distance float64, baseRadius float64, noseRadius float64) (SDF2, error)
- func GearRack2D(k *GearRackParms) (SDF2, error)
- func ISOThread(radius float64, pitch float64, external bool) (SDF2, error)
- func Intersect2D(s0, s1 SDF2) SDF2
- func Line2D(l, round float64) SDF2
- func LineOf2D(s SDF2, p0, p1 v2.Vec, pattern string) SDF2
- func MakeFlatFlankCam(lift float64, duration float64, maxDiameter float64) (SDF2, error)
- func MakeThreeArcCam(lift float64, duration float64, maxDiameter float64, k float64) (SDF2, error)
- func Multi2D(s SDF2, positions v2.VecSet) SDF2
- func NewFlange1(distance float64, centerRadius float64, sideRadius float64) SDF2
- func Offset2D(sdf SDF2, offset float64) SDF2
- func PlasticButtressThread(radius float64, pitch float64) (SDF2, error)
- func Polygon2D(vertex []v2.Vec) (SDF2, error)
- func RotateCopy2D(sdf SDF2, n int) SDF2
- func RotateUnion2D(sdf SDF2, num int, step M33) SDF2
- func ScaleUniform2D(sdf SDF2, k float64) SDF2
- func Slice2D(sdf SDF3, a v3.Vec, n v3.Vec) SDF2
- func TextSDF2(f *truetype.Font, t *Text, h float64) (SDF2, error)
- func ThreeArcCam2D(distance float64, baseRadius float64, noseRadius float64, flankRadius float64) (SDF2, error)
- func Transform2D(sdf SDF2, m M33) SDF2
- func Union2D(sdf ...SDF2) SDF2
- type SDF3
- func Array3D(sdf SDF3, num v3i.Vec, step v3.Vec) SDF3
- func Box3D(size v3.Vec, round float64) (SDF3, error)
- func Capsule3D(height, radius float64) (SDF3, error)
- func Cone3D(height, r0, r1, round float64) (SDF3, error)
- func Cut3D(sdf SDF3, a, n v3.Vec) SDF3
- func Cylinder3D(height, radius, round float64) (SDF3, error)
- func Difference3D(s0, s1 SDF3) SDF3
- func Elongate3D(sdf SDF3, h v3.Vec) SDF3
- func Extrude3D(sdf SDF2, height float64) SDF3
- func ExtrudeRounded3D(sdf SDF2, height, round float64) (SDF3, error)
- func Gyroid3D(scale v3.Vec) (SDF3, error)
- func Intersect3D(s0, s1 SDF3) SDF3
- func LineOf3D(s SDF3, p0, p1 v3.Vec, pattern string) SDF3
- func Loft3D(sdf0, sdf1 SDF2, height, round float64) (SDF3, error)
- func Multi3D(s SDF3, positions v3.VecSet) SDF3
- func NewVoxelSDF3(s SDF3, meshCells int, progress chan float64) SDF3
- func Offset3D(sdf SDF3, offset float64) SDF3
- func Orient3D(s SDF3, base v3.Vec, directions v3.VecSet) SDF3
- func Revolve3D(sdf SDF2) (SDF3, error)
- func RevolveTheta3D(sdf SDF2, theta float64) (SDF3, error)
- func RotateCopy3D(sdf SDF3, num int) SDF3
- func RotateUnion3D(sdf SDF3, num int, step M44) SDF3
- func ScaleExtrude3D(sdf SDF2, height float64, scale v2.Vec) SDF3
- func ScaleTwistExtrude3D(sdf SDF2, height, twist float64, scale v2.Vec) SDF3
- func ScaleUniform3D(sdf SDF3, k float64) SDF3
- func Screw3D(thread SDF2, length float64, taper float64, pitch float64, starts int) (SDF3, error)
- func Shell3D(sdf SDF3, thickness float64) (SDF3, error)
- func Sphere3D(radius float64) (SDF3, error)
- func Transform3D(sdf SDF3, matrix M44) SDF3
- func TwistExtrude3D(sdf SDF2, height, twist float64) SDF3
- func Union3D(sdf ...SDF3) SDF3
- type ScaleUniformSDF2
- type ScaleUniformSDF3
- type ScrewSDF3
- type ShellSDF3
- type SliceSDF2
- type SorSDF3
- type SphereSDF3
- type Text
- type ThreadParameters
- type ThreeArcCamSDF2
- type TransformSDF2
- type TransformSDF3
- type UnionSDF2
- type UnionSDF3
- type VoxelSDF3
Constants ¶
const InchesPerMillimetre = 1.0 / MillimetresPerInch
InchesPerMillimetre is inches per millimetre
const Mil = MillimetresPerInch / 1000.0
Mil is millimetres per 1/1000 of an inch
const MillimetresPerInch = 25.4
MillimetresPerInch is millimetres per inch (25.4)
const Pi = math.Pi
Pi (3.14159...)
const Tau = 2 * math.Pi
Tau (2 * Pi).
Variables ¶
This section is empty.
Functions ¶
func BenchmarkSDF2 ¶
BenchmarkSDF2 reports the evaluation speed for an SDF2.
func BenchmarkSDF3 ¶
BenchmarkSDF3 reports the evaluation speed for an SDF3.
func EqualFloat64 ¶
EqualFloat64 compares two float64 values for equality.
func FloatDecode ¶
FloatDecode returns a string that decodes the float64 bitfields.
func FloatEncode ¶
FloatEncode encodes a float64 from sign, fraction and exponent values.
func GenerateMesh2D ¶
GenerateMesh2D generates a set of internal mesh points for an SDF2.
func Normal2 ¶
Normal2 returns the normal of an SDF3 at a point (doesn't need to be on the surface). Computed by sampling it several times inside a box of side 2*eps centered on p.
func Normal3 ¶
Normal3 returns the normal of an SDF3 at a point (doesn't need to be on the surface). Computed by sampling it several times inside a box of side 2*eps centered on p.
func NormalExtrude ¶
NormalExtrude returns an extrusion function.
func Raycast2 ¶
func Raycast2(s SDF2, from, dir v2.Vec, scaleAndSigmoid, stepScale, epsilon, maxDist float64, maxSteps int) (v2.Vec, float64, int)
Raycast2 see Raycast3. NOTE: implementation using Raycast3 (inefficient?)
func Raycast3 ¶
func Raycast3(s SDF3, from, dir v3.Vec, scaleAndSigmoid, stepScale, epsilon, maxDist float64, maxSteps int) (collision v3.Vec, t float64, steps int)
Raycast3 collides a ray (with an origin point from and a direction dir) with an SDF3. sigmoid is useful for fixing bad distance functions (those that do not accurately represent the distance to the closest surface, but will probably imply more evaluations) stepScale controls precision (less stepSize, more precision, but more SDF evaluations): use 1 if SDF indicates distance to the closest surface. It returns the collision point, how many normalized distances to reach it (t), and the number of steps performed If no surface is found (in maxDist and maxSteps), t is < 0
Types ¶
type ArcSpiralSDF2 ¶
type ArcSpiralSDF2 struct {
// contains filtered or unexported fields
}
ArcSpiralSDF2 is a 2d Archimedean spiral.
func (*ArcSpiralSDF2) BoundingBox ¶
func (s *ArcSpiralSDF2) BoundingBox() Box2
BoundingBox returns the bounding box of a 2d Archimedean spiral.
type ArraySDF2 ¶
type ArraySDF2 struct {
// contains filtered or unexported fields
}
ArraySDF2 defines an XY grid array of an existing SDF2.
func (*ArraySDF2) BoundingBox ¶
BoundingBox returns the bounding box of a grid array of SDF2s.
type ArraySDF3 ¶
type ArraySDF3 struct {
// contains filtered or unexported fields
}
ArraySDF3 stores an XYZ array of a given SDF3
func (*ArraySDF3) BoundingBox ¶
BoundingBox returns the bounding box of an XYZ SDF3 array.
type Bezier ¶
type Bezier struct {
// contains filtered or unexported fields
}
Bezier curve specification..
func (*Bezier) Add ¶
func (b *Bezier) Add(x, y float64) *BezierVertex
Add an x,y vertex to a polygon.
type BezierPolynomial ¶
type BezierPolynomial struct {
// contains filtered or unexported fields
}
BezierPolynomial contains the bezier polynomial parameters.
func (*BezierPolynomial) Set ¶
func (p *BezierPolynomial) Set(x []float64)
Set calculates bezier polynomial coefficients given the end/control points.
type BezierSpline ¶
type BezierSpline struct {
// contains filtered or unexported fields
}
BezierSpline contains the x/y bezier curves for a 2D spline.
func NewBezierSpline ¶
func NewBezierSpline(p []v2.Vec) *BezierSpline
NewBezierSpline returns a bezier spline from the provided control/end points.
type BezierVertex ¶
type BezierVertex struct {
// contains filtered or unexported fields
}
BezierVertex specifies the vertex for a bezier curve.
func (*BezierVertex) Handle ¶
func (v *BezierVertex) Handle(theta, fwd, rev float64) *BezierVertex
Handle marks the vertex with a slope control handle.
func (*BezierVertex) HandleFwd ¶
func (v *BezierVertex) HandleFwd(theta, r float64) *BezierVertex
HandleFwd sets the slope handle in the forward direction.
func (*BezierVertex) HandleRev ¶
func (v *BezierVertex) HandleRev(theta, r float64) *BezierVertex
HandleRev sets the slope handle in the reverse direction.
func (*BezierVertex) Mid ¶
func (v *BezierVertex) Mid() *BezierVertex
Mid marks the vertex as a mid-curve control point.
type Box2 ¶
Box2 is a 2d bounding box.
func (Box2) BottomLeft ¶
BottomLeft returns the bottom left corner of a 2d bounding box.
func (Box2) Contains ¶
Contains checks if the 2d box contains the given vector (considering bounds as inside).
func (Box2) MinMaxDist2 ¶
MinMaxDist2 returns the minimum and maximum dist * dist from a point to a box. Points within the box have minimum distance = 0.
func (Box2) ScaleAboutCenter ¶
ScaleAboutCenter returns a new 2d box scaled about the center of a box.
type Box3 ¶
Box3 is a 3d bounding box.
func (Box3) Contains ¶
Contains checks if the 3d box contains the given vector (considering bounds as inside).
func (Box3) MinMaxDist2 ¶
MinMaxDist2 returns the minimum and maximum dist * dist from a point to a box. Points within the box have minimum distance = 0.
func (Box3) ScaleAboutCenter ¶
ScaleAboutCenter returns a new 3d box scaled about the center of a box.
type BoxSDF2 ¶
type BoxSDF2 struct {
// contains filtered or unexported fields
}
BoxSDF2 is the 2d signed distance object for a rectangular box.
func (*BoxSDF2) BoundingBox ¶
BoundingBox returns the bounding box for a 2d box.
type BoxSDF3 ¶
type BoxSDF3 struct {
// contains filtered or unexported fields
}
BoxSDF3 is a 3d box.
func (*BoxSDF3) BoundingBox ¶
BoundingBox returns the bounding box for a 3d box.
type CircleSDF2 ¶
type CircleSDF2 struct {
// contains filtered or unexported fields
}
CircleSDF2 is the 2d signed distance object for a circle.
func (*CircleSDF2) BoundingBox ¶
func (s *CircleSDF2) BoundingBox() Box2
BoundingBox returns the bounding box of a 2d circle.
type ConeSDF3 ¶
type ConeSDF3 struct {
// contains filtered or unexported fields
}
ConeSDF3 is a truncated cone.
func (*ConeSDF3) BoundingBox ¶
BoundingBox return the bounding box for the trucated cone..
type CubicPolynomial ¶
type CubicPolynomial struct {
// contains filtered or unexported fields
}
CubicPolynomial is a cubic polynomial
func (*CubicPolynomial) Set ¶
func (p *CubicPolynomial) Set(y0, y1, D0, D1 float64)
Set cubic polynomial coefficient values.
type CubicSpline ¶
type CubicSpline struct {
// contains filtered or unexported fields
}
CubicSpline is a 2d cubic spline.
func (*CubicSpline) BoundingBox ¶
func (s *CubicSpline) BoundingBox() Box2
BoundingBox returns the bounding box for a cubic spline.
type CubicSplineSDF2 ¶
type CubicSplineSDF2 struct {
// contains filtered or unexported fields
}
CubicSplineSDF2 is an SDF2 made from a set of cubic splines.
func (*CubicSplineSDF2) BoundingBox ¶
func (s *CubicSplineSDF2) BoundingBox() Box2
BoundingBox returns the 2d bounding box of a cubic spline.
func (*CubicSplineSDF2) Evaluate ¶
func (s *CubicSplineSDF2) Evaluate(p v2.Vec) float64
Evaluate returns the minimum distance from a point to the cubic spline SDF2. Note: This uses Newton-Raphson minimisation and is unstable in some circumstances. A simple (and slower) solution is to convert the cubic spline SDF2 to a polygon SDF2 and use that for rendering.
func (*CubicSplineSDF2) PolySpline2D ¶
func (s *CubicSplineSDF2) PolySpline2D(n int) (SDF2, error)
PolySpline2D returns a polygon SDF2 approximating a cubic spline SDF2.
func (*CubicSplineSDF2) Polygonize ¶
func (s *CubicSplineSDF2) Polygonize(n int) *Polygon
Polygonize returns a polygon approximating the cubic spline SDF2.
type CutSDF2 ¶
type CutSDF2 struct {
// contains filtered or unexported fields
}
CutSDF2 is an SDF2 made by cutting across an existing SDF2.
func (*CutSDF2) BoundingBox ¶
BoundingBox returns the bounding box for the cut SDF2.
type CutSDF3 ¶
type CutSDF3 struct {
// contains filtered or unexported fields
}
CutSDF3 makes a planar cut through an SDF3.
func (*CutSDF3) BoundingBox ¶
BoundingBox returns the bounding box of the cut SDF3.
type CylinderSDF3 ¶
type CylinderSDF3 struct {
// contains filtered or unexported fields
}
CylinderSDF3 is a cylinder.
func (*CylinderSDF3) BoundingBox ¶
func (s *CylinderSDF3) BoundingBox() Box3
BoundingBox returns the bounding box for a cylinder.
type DifferenceSDF2 ¶
type DifferenceSDF2 struct {
// contains filtered or unexported fields
}
DifferenceSDF2 is the difference of two SDF2s.
func (*DifferenceSDF2) BoundingBox ¶
func (s *DifferenceSDF2) BoundingBox() Box2
BoundingBox returns the bounding box of the difference of two SDF2s.
func (*DifferenceSDF2) Evaluate ¶
func (s *DifferenceSDF2) Evaluate(p v2.Vec) float64
Evaluate returns the minimum distance to the difference of two SDF2s.
func (*DifferenceSDF2) SetMax ¶
func (s *DifferenceSDF2) SetMax(max MaxFunc)
SetMax sets the maximum function to control blending.
type DifferenceSDF3 ¶
type DifferenceSDF3 struct {
// contains filtered or unexported fields
}
DifferenceSDF3 is the difference of two SDF3s, s0 - s1.
func (*DifferenceSDF3) BoundingBox ¶
func (s *DifferenceSDF3) BoundingBox() Box3
BoundingBox returns the bounding box of the SDF3 difference.
func (*DifferenceSDF3) Evaluate ¶
func (s *DifferenceSDF3) Evaluate(p v3.Vec) float64
Evaluate returns the minimum distance to the SDF3 difference.
func (*DifferenceSDF3) SetMax ¶
func (s *DifferenceSDF3) SetMax(max MaxFunc)
SetMax sets the maximum function to control blending.
type ElongateSDF2 ¶
type ElongateSDF2 struct {
// contains filtered or unexported fields
}
ElongateSDF2 is the elongation of an SDF2.
func (*ElongateSDF2) BoundingBox ¶
func (s *ElongateSDF2) BoundingBox() Box2
BoundingBox returns the bounding box of an elongated SDF2.
type ElongateSDF3 ¶
type ElongateSDF3 struct {
// contains filtered or unexported fields
}
ElongateSDF3 is the elongation of an SDF3.
func (*ElongateSDF3) BoundingBox ¶
func (s *ElongateSDF3) BoundingBox() Box3
BoundingBox returns the bounding box of an elongated SDF3.
type ExtrudeFunc ¶
ExtrudeFunc maps v3.Vec to v2.Vec - the point used to evaluate the SDF2.
func ScaleExtrude ¶
func ScaleExtrude(height float64, scale v2.Vec) ExtrudeFunc
ScaleExtrude returns an extrusion functions that scales with z.
func ScaleTwistExtrude ¶
func ScaleTwistExtrude(height, twist float64, scale v2.Vec) ExtrudeFunc
ScaleTwistExtrude returns an extrusion function that scales and twists with z.
func TwistExtrude ¶
func TwistExtrude(height, twist float64) ExtrudeFunc
TwistExtrude returns an extrusion function that twists with z.
type ExtrudeRoundedSDF3 ¶
type ExtrudeRoundedSDF3 struct {
// contains filtered or unexported fields
}
ExtrudeRoundedSDF3 extrudes an SDF2 to an SDF3 with rounded edges.
func (*ExtrudeRoundedSDF3) BoundingBox ¶
func (s *ExtrudeRoundedSDF3) BoundingBox() Box3
BoundingBox returns the bounding box for a rounded extrusion.
type ExtrudeSDF3 ¶
type ExtrudeSDF3 struct {
// contains filtered or unexported fields
}
ExtrudeSDF3 extrudes an SDF2 to an SDF3.
func (*ExtrudeSDF3) BoundingBox ¶
func (s *ExtrudeSDF3) BoundingBox() Box3
BoundingBox returns the bounding box for an extrusion.
func (*ExtrudeSDF3) Evaluate ¶
func (s *ExtrudeSDF3) Evaluate(p v3.Vec) float64
Evaluate returns the minimum distance to an extrusion.
func (*ExtrudeSDF3) SetExtrude ¶
func (s *ExtrudeSDF3) SetExtrude(extrude ExtrudeFunc)
SetExtrude sets the extrusion control function.
type Flange1 ¶
type Flange1 struct {
// contains filtered or unexported fields
}
Flange1 is a flange shape made from a center circle with two side circles.
func (*Flange1) BoundingBox ¶
BoundingBox returns the bounding box for the flange.
type FlatFlankCamSDF2 ¶
type FlatFlankCamSDF2 struct {
// contains filtered or unexported fields
}
FlatFlankCamSDF2 is 2d cam profile. The profile is made from a base circle, a smaller nose circle and flat, tangential flanks.
func (*FlatFlankCamSDF2) BoundingBox ¶
func (s *FlatFlankCamSDF2) BoundingBox() Box2
BoundingBox returns the bounding box for the cam.
type GearRackParms ¶
type GearRackParms struct { NumberTeeth int // number of rack teeth Module float64 // pitch circle diameter / number of gear teeth PressureAngle float64 // gear pressure angle (radians) Backlash float64 // backlash expressed as units of pitch circumference BaseHeight float64 // height of rack base }
GearRackParms defines the parameters for a gear rack.
type GearRackSDF2 ¶
type GearRackSDF2 struct {
// contains filtered or unexported fields
}
GearRackSDF2 is a 2d linear gear rack.
func (*GearRackSDF2) BoundingBox ¶
func (s *GearRackSDF2) BoundingBox() Box2
BoundingBox returns the bounding box for the gear rack.
type GyroidSDF3 ¶
type GyroidSDF3 struct {
// contains filtered or unexported fields
}
GyroidSDF3 is a 3d gyroid.
func (*GyroidSDF3) BoundingBox ¶
func (s *GyroidSDF3) BoundingBox() Box3
BoundingBox returns the bounding box for a 3d gyroid.
type IntersectionSDF2 ¶
type IntersectionSDF2 struct {
// contains filtered or unexported fields
}
IntersectionSDF2 is the intersection of two SDF2s.
func (*IntersectionSDF2) BoundingBox ¶
func (s *IntersectionSDF2) BoundingBox() Box2
BoundingBox returns the bounding box of an SDF2 intersection.
func (*IntersectionSDF2) Evaluate ¶
func (s *IntersectionSDF2) Evaluate(p v2.Vec) float64
Evaluate returns the minimum distance to the SDF2 intersection.
func (*IntersectionSDF2) SetMax ¶
func (s *IntersectionSDF2) SetMax(max MaxFunc)
SetMax sets the maximum function to control blending.
type IntersectionSDF3 ¶
type IntersectionSDF3 struct {
// contains filtered or unexported fields
}
IntersectionSDF3 is the intersection of two SDF3s.
func (*IntersectionSDF3) BoundingBox ¶
func (s *IntersectionSDF3) BoundingBox() Box3
BoundingBox returns the bounding box of an SDF3 intersection.
func (*IntersectionSDF3) Evaluate ¶
func (s *IntersectionSDF3) Evaluate(p v3.Vec) float64
Evaluate returns the minimum distance to the SDF3 intersection.
func (*IntersectionSDF3) SetMax ¶
func (s *IntersectionSDF3) SetMax(max MaxFunc)
SetMax sets the maximum function to control blending.
type Line2 ¶
type Line2 struct {
// contains filtered or unexported fields
}
Line2 is a 2d line defined as either point/point or point/vector.
func (Line2) Distance ¶
Distance returns the distance to the line. Greater than 0 implies to the right of the line vector.
type LineSDF2 ¶
type LineSDF2 struct {
// contains filtered or unexported fields
}
LineSDF2 is the 2d signed distance object for a line.
func (*LineSDF2) BoundingBox ¶
BoundingBox returns the bounding box for a 2d line.
type LoftSDF3 ¶
type LoftSDF3 struct {
// contains filtered or unexported fields
}
LoftSDF3 is an extrusion between two SDF2s.
func (*LoftSDF3) BoundingBox ¶
BoundingBox returns the bounding box for a loft extrusion.
type M22 ¶
type M22 struct {
// contains filtered or unexported fields
}
M22 is a 2x2 matrix.
func (M22) Determinant ¶
Determinant returns the determinant of a 2x2 matrix.
type M33 ¶
type M33 struct {
// contains filtered or unexported fields
}
M33 is a 3x3 matrix.
func Scale2d ¶
Scale2d returns a 3x3 scaling matrix. Scaling does not preserve distance. See: ScaleUniform2D().
func (M33) Determinant ¶
Determinant returns the determinant of a 3x3 matrix.
func (M33) MulPosition ¶
MulPosition multiplies a v2.Vec position with a rotate/translate matrix.
type M44 ¶
type M44 struct {
// contains filtered or unexported fields
}
M44 is a 4x4 matrix.
func MirrorXY ¶
func MirrorXY() M44
MirrorXY returns a 4x4 matrix with mirroring across the XY plane.
func MirrorXZ ¶
func MirrorXZ() M44
MirrorXZ returns a 4x4 matrix with mirroring across the XZ plane.
func MirrorXeqY ¶
func MirrorXeqY() M44
MirrorXeqY returns a 4x4 matrix with mirroring across the X == Y plane.
func MirrorYZ ¶
func MirrorYZ() M44
MirrorYZ returns a 4x4 matrix with mirroring across the YZ plane.
func RotateToVector ¶
RotateToVector returns the rotation matrix that transforms a onto the same direction as b.
func Scale3d ¶
Scale3d returns a 4x4 scaling matrix. Scaling does not preserve distance. See: ScaleUniform3D()
func (M44) Determinant ¶
Determinant returns the determinant of a 4x4 matrix.
type Map2 ¶
type Map2 struct {
// contains filtered or unexported fields
}
Map2 maps a 2d region to integer grid coordinates.
type MinFunc ¶
MinFunc is a minimum functions for SDF blending.
func ChamferMin ¶
ChamferMin returns a minimum function that makes a 45-degree chamfered edge (the diagonal of a square of size <r>). TODO: why the holes in the rendering?
type OffsetSDF2 ¶
type OffsetSDF2 struct {
// contains filtered or unexported fields
}
OffsetSDF2 offsets the distance function of an existing SDF2.
func (*OffsetSDF2) BoundingBox ¶
func (s *OffsetSDF2) BoundingBox() Box2
BoundingBox returns the bounding box of an offset SDF2.
type OffsetSDF3 ¶
type OffsetSDF3 struct {
// contains filtered or unexported fields
}
OffsetSDF3 offsets the distance function of an existing SDF3.
func (*OffsetSDF3) BoundingBox ¶
func (s *OffsetSDF3) BoundingBox() Box3
BoundingBox returns the bounding box of an offset SDF3.
type PolySDF2 ¶
type PolySDF2 struct {
// contains filtered or unexported fields
}
PolySDF2 is an SDF2 made from a closed set of line segments.
func (*PolySDF2) BoundingBox ¶
BoundingBox returns the bounding box of a 2d polygon.
type Polygon ¶
type Polygon struct {
// contains filtered or unexported fields
}
Polygon stores a set of 2d polygon vertices.
func (*Polygon) Add ¶
func (p *Polygon) Add(x, y float64) *PolygonVertex
Add an x,y vertex to a polygon.
func (*Polygon) AddV2 ¶
func (p *Polygon) AddV2(x v2.Vec) *PolygonVertex
AddV2 adds a V2 vertex to a polygon.
type PolygonVertex ¶
type PolygonVertex struct {
// contains filtered or unexported fields
}
PolygonVertex is a polygon vertex.
func (*PolygonVertex) Arc ¶
func (v *PolygonVertex) Arc(radius float64, facets int) *PolygonVertex
Arc replaces a line segment with a circular arc.
func (*PolygonVertex) Chamfer ¶
func (v *PolygonVertex) Chamfer(size float64) *PolygonVertex
Chamfer marks the polygon vertex for chamfering.
func (*PolygonVertex) Polar ¶
func (v *PolygonVertex) Polar() *PolygonVertex
Polar treats the polygon vertex values as polar coordinates (r, theta).
func (*PolygonVertex) Rel ¶
func (v *PolygonVertex) Rel() *PolygonVertex
Rel positions the polygon vertex relative to the prior vertex.
func (*PolygonVertex) Smooth ¶
func (v *PolygonVertex) Smooth(radius float64, facets int) *PolygonVertex
Smooth marks the polygon vertex for smoothing.
type RotateCopySDF2 ¶
type RotateCopySDF2 struct {
// contains filtered or unexported fields
}
RotateCopySDF2 copies an SDF2 n times in a full circle.
func (*RotateCopySDF2) BoundingBox ¶
func (s *RotateCopySDF2) BoundingBox() Box2
BoundingBox returns the bounding box of a rotate/copy SDF2.
type RotateCopySDF3 ¶
type RotateCopySDF3 struct {
// contains filtered or unexported fields
}
RotateCopySDF3 rotates and creates N copies of an SDF3 about the z-axis.
func (*RotateCopySDF3) BoundingBox ¶
func (s *RotateCopySDF3) BoundingBox() Box3
BoundingBox returns the bounding box of a rotate/copy SDF3.
type RotateUnionSDF2 ¶
type RotateUnionSDF2 struct {
// contains filtered or unexported fields
}
RotateUnionSDF2 defines a union of rotated SDF2s.
func (*RotateUnionSDF2) BoundingBox ¶
func (s *RotateUnionSDF2) BoundingBox() Box2
BoundingBox returns the bounding box of a union of rotated SDF2s.
func (*RotateUnionSDF2) Evaluate ¶
func (s *RotateUnionSDF2) Evaluate(p v2.Vec) float64
Evaluate returns the minimum distance to a union of rotated SDF2s.
func (*RotateUnionSDF2) SetMin ¶
func (s *RotateUnionSDF2) SetMin(min MinFunc)
SetMin sets the minimum function to control blending.
type RotateUnionSDF3 ¶
type RotateUnionSDF3 struct {
// contains filtered or unexported fields
}
RotateUnionSDF3 creates a union of SDF3s rotated about the z-axis.
func (*RotateUnionSDF3) BoundingBox ¶
func (s *RotateUnionSDF3) BoundingBox() Box3
BoundingBox returns the bounding box of a rotate/union object.
func (*RotateUnionSDF3) Evaluate ¶
func (s *RotateUnionSDF3) Evaluate(p v3.Vec) float64
Evaluate returns the minimum distance to a rotate/union object.
func (*RotateUnionSDF3) SetMin ¶
func (s *RotateUnionSDF3) SetMin(min MinFunc)
SetMin sets the minimum function to control blending.
type SDF2 ¶
SDF2 is the interface to a 2d signed distance function object.
func ANSIButtressThread ¶
ANSIButtressThread returns the 2d profile for an ANSI 45/7 buttress thread. https://en.wikipedia.org/wiki/Buttress_thread AMSE B1.9-1973
func AcmeThread ¶
AcmeThread returns the 2d profile for an acme thread.
func ArcSpiral2D ¶
ArcSpiral2D returns a 2d Archimedean spiral (r = m*theta + b).
func CenterAndScale2D ¶
CenterAndScale2D centers the origin of an SDF2 on it's bounding box, and then scales it. Distance is correct with scaling.
func CubicSpline2D ¶
CubicSpline2D returns an SDF2 made from a set of cubic splines.
func Cut2D ¶
Cut2D cuts the SDF2 along a line from a in direction v. The SDF2 to the right of the line remains.
func Difference2D ¶
Difference2D returns the difference of two SDF2 objects, s0 - s1.
func Elongate2D ¶
Elongate2D returns the elongation of an SDF2.
func FlatFlankCam2D ¶
FlatFlankCam2D creates a 2D cam profile. The profile is made from a base circle, a smaller nose circle and flat, tangential flanks. The base circle is centered on the origin. The nose circle is located on the positive y axis.
func GearRack2D ¶
func GearRack2D(k *GearRackParms) (SDF2, error)
GearRack2D returns the 2D profile for a gear rack.
func ISOThread ¶
ISOThread returns the 2d profile for an ISO/UTS thread. https://en.wikipedia.org/wiki/ISO_metric_screw_thread https://en.wikipedia.org/wiki/Unified_Thread_Standard
func Intersect2D ¶
Intersect2D returns the intersection of two SDF2s.
func MakeFlatFlankCam ¶
MakeFlatFlankCam makes a flat flank cam profile from design parameters.
func MakeThreeArcCam ¶
func MakeThreeArcCam( lift float64, duration float64, maxDiameter float64, k float64, ) (SDF2, error)
MakeThreeArcCam makes a three arc cam profile from design parameters.
func NewFlange1 ¶
NewFlange1 returns a flange shape made from a center circle with two side circles.
func PlasticButtressThread ¶
PlasticButtressThread returns the 2d profile for a screw top style plastic buttress thread. Similar to ANSI 45/7 - but with more corner rounding
func RotateCopy2D ¶
RotateCopy2D rotates and copies an SDF2 n times in a full circle.
func RotateUnion2D ¶
RotateUnion2D returns a union of rotated SDF2s.
func ScaleUniform2D ¶
ScaleUniform2D scales an SDF2 by k on each axis. Distance is correct with scaling.
func ThreeArcCam2D ¶
func ThreeArcCam2D( distance float64, baseRadius float64, noseRadius float64, flankRadius float64, ) (SDF2, error)
ThreeArcCam2D creates a 2D cam profile. The profile is made from a base circle, a smaller nose circle and circular flank arcs. The base circle is centered on the origin. The nose circle is located on the positive y axis. The flank arcs are tangential to the base and nose circles.
func Transform2D ¶
Transform2D applies a transformation matrix to an SDF2. Distance is *not* preserved with scaling.
type SDF3 ¶
SDF3 is the interface to a 3d signed distance function object.
func Cut3D ¶
Cut3D cuts an SDF3 along a plane passing through a with normal n. The SDF3 on the same side as the normal remains.
func Cylinder3D ¶
Cylinder3D return an SDF3 for a cylinder (rounded edges with round > 0).
func Difference3D ¶
Difference3D returns the difference of two SDF3s, s0 - s1.
func Elongate3D ¶
Elongate3D returns the elongation of an SDF3.
func ExtrudeRounded3D ¶
ExtrudeRounded3D extrudes an SDF2 to an SDF3 with rounded edges.
func Intersect3D ¶
Intersect3D returns the intersection of two SDF3s.
func NewVoxelSDF3 ¶
NewVoxelSDF3 returns a VoxelSDF3. This populates the whole cache from the given SDF. The progress listener may be nil.
func RevolveTheta3D ¶
RevolveTheta3D returns an SDF3 for a solid of revolution.
func RotateCopy3D ¶
RotateCopy3D rotates and creates N copies of an SDF3 about the z-axis.
func RotateUnion3D ¶
RotateUnion3D creates a union of SDF3s rotated about the z-axis.
func ScaleExtrude3D ¶
ScaleExtrude3D extrudes an SDF2 and scales it over the height of the extrusion.
func ScaleTwistExtrude3D ¶
ScaleTwistExtrude3D extrudes an SDF2 and scales and twists it over the height of the extrusion.
func ScaleUniform3D ¶
ScaleUniform3D uniformly scales an SDF3 on all axes.
func Screw3D ¶
func Screw3D( thread SDF2, length float64, taper float64, pitch float64, starts int, ) (SDF3, error)
Screw3D returns a screw SDF3.
func Transform3D ¶
Transform3D applies a transformation matrix to an SDF3.
func TwistExtrude3D ¶
TwistExtrude3D extrudes an SDF2 while rotating by twist radians over the height of the extrusion.
type ScaleUniformSDF2 ¶
type ScaleUniformSDF2 struct {
// contains filtered or unexported fields
}
ScaleUniformSDF2 scales another SDF2 on each axis.
func (*ScaleUniformSDF2) BoundingBox ¶
func (s *ScaleUniformSDF2) BoundingBox() Box2
BoundingBox returns the bounding box of an SDF2 with uniform scaling.
type ScaleUniformSDF3 ¶
type ScaleUniformSDF3 struct {
// contains filtered or unexported fields
}
ScaleUniformSDF3 is an SDF3 scaled uniformly in XYZ directions.
func (*ScaleUniformSDF3) BoundingBox ¶
func (s *ScaleUniformSDF3) BoundingBox() Box3
BoundingBox returns the bounding box of a uniformly scaled SDF3.
type ScrewSDF3 ¶
type ScrewSDF3 struct {
// contains filtered or unexported fields
}
ScrewSDF3 is a 3d screw form.
func (*ScrewSDF3) BoundingBox ¶
BoundingBox returns the bounding box for a 3d screw form.
type ShellSDF3 ¶
type ShellSDF3 struct {
// contains filtered or unexported fields
}
ShellSDF3 shells the surface of an existing SDF3.
func (*ShellSDF3) BoundingBox ¶
BoundingBox returns the bounding box of a shelled SDF3.
type SliceSDF2 ¶
type SliceSDF2 struct {
// contains filtered or unexported fields
}
SliceSDF2 creates an SDF2 from a planar slice through an SDF3.
func (*SliceSDF2) BoundingBox ¶
BoundingBox returns the bounding box of the sliced SDF2.
type SorSDF3 ¶
type SorSDF3 struct {
// contains filtered or unexported fields
}
SorSDF3 solid of revolution, SDF2 to SDF3.
func (*SorSDF3) BoundingBox ¶
BoundingBox returns the bounding box for a solid of revolution.
type SphereSDF3 ¶
type SphereSDF3 struct {
// contains filtered or unexported fields
}
SphereSDF3 is a sphere.
func (*SphereSDF3) BoundingBox ¶
func (s *SphereSDF3) BoundingBox() Box3
BoundingBox returns the bounding box for a sphere.
type Text ¶
type Text struct {
// contains filtered or unexported fields
}
Text stores a UTF8 string and it's rendering parameters.
type ThreadParameters ¶
type ThreadParameters struct { Name string // name of screw thread Radius float64 // nominal major radius of screw Pitch float64 // thread to thread distance of screw Taper float64 // thread taper (radians) HexFlat2Flat float64 // hex head flat to flat distance Units string // "inch" or "mm" }
ThreadParameters stores the values that define a thread.
func ThreadLookup ¶
func ThreadLookup(name string) (*ThreadParameters, error)
ThreadLookup lookups the parameters for a thread by name.
func (*ThreadParameters) HexHeight ¶
func (t *ThreadParameters) HexHeight() float64
HexHeight returns the hex head height (empirical).
func (*ThreadParameters) HexRadius ¶
func (t *ThreadParameters) HexRadius() float64
HexRadius returns the hex head radius.
type ThreeArcCamSDF2 ¶
type ThreeArcCamSDF2 struct {
// contains filtered or unexported fields
}
ThreeArcCamSDF2 is 2d cam profile. The profile is made from a base circle, a smaller nose circle and circular flank arcs.
func (*ThreeArcCamSDF2) BoundingBox ¶
func (s *ThreeArcCamSDF2) BoundingBox() Box2
BoundingBox returns the bounding box for the cam.
type TransformSDF2 ¶
type TransformSDF2 struct {
// contains filtered or unexported fields
}
TransformSDF2 transorms an SDF2 with rotation, translation and scaling.
func (*TransformSDF2) BoundingBox ¶
func (s *TransformSDF2) BoundingBox() Box2
BoundingBox returns the bounding box of a transformed SDF2.
type TransformSDF3 ¶
type TransformSDF3 struct {
// contains filtered or unexported fields
}
TransformSDF3 is an SDF3 transformed with a 4x4 transformation matrix.
func (*TransformSDF3) BoundingBox ¶
func (s *TransformSDF3) BoundingBox() Box3
BoundingBox returns the bounding box of a transformed SDF3.
type UnionSDF2 ¶
type UnionSDF2 struct {
// contains filtered or unexported fields
}
UnionSDF2 is a union of multiple SDF2 objects.
func (*UnionSDF2) BoundingBox ¶
BoundingBox returns the bounding box of an SDF2 union.
func (*UnionSDF2) EvaluateSlow ¶
EvaluateSlow returns the minimum distance to the SDF2 union.
type UnionSDF3 ¶
type UnionSDF3 struct {
// contains filtered or unexported fields
}
UnionSDF3 is a union of SDF3s.
func (*UnionSDF3) BoundingBox ¶
BoundingBox returns the bounding box of an SDF3 union.
type VoxelSDF3 ¶
type VoxelSDF3 struct {
// contains filtered or unexported fields
}
VoxelSDF3 is the SDF that represents a pre-computed voxel-based SDF3. It can be used as a cache, or for smoothing.
CACHE: It can be used to speed up all evaluations required by the surface mesher at the cost of scene setup time and accuracy.
SMOOTHING (meshCells <<< renderer's meshCells): It performs trilinear mapping for inner values and may be used as a cache for any other SDF, losing some accuracy.
WARNING: It may lose sharp features, even if meshCells is high.
func (*VoxelSDF3) BoundingBox ¶
BoundingBox returns the bounding box for a VoxelSDF3.