Documentation
¶
Overview ¶
Package toolbox3d provides a collection of parts for building practical 3D models for 3D prints.
Index ¶
- Constants
- func AngleDist(theta1, theta2 float64) float64
- func CanonicalAngle(theta float64) float64
- func ClampAxis(s model3d.Solid, axis Axis, min, max float64) model3d.Solid
- func ClampAxisMax(s model3d.Solid, axis Axis, max float64) model3d.Solid
- func ClampAxisMin(s model3d.Solid, axis Axis, min float64) model3d.Solid
- func ClampXMax(s model3d.Solid, max float64) model3d.Solid
- func ClampXMin(s model3d.Solid, max float64) model3d.Solid
- func ClampYMax(s model3d.Solid, max float64) model3d.Solid
- func ClampYMin(s model3d.Solid, max float64) model3d.Solid
- func ClampZMax(s model3d.Solid, max float64) model3d.Solid
- func ClampZMin(s model3d.Solid, max float64) model3d.Solid
- func HeightMapToSolid(hm *HeightMap) model3d.Solid
- func HeightMapToSolidBidir(hm *HeightMap) model3d.Solid
- func L1LineJoin(r float64, lines ...model3d.Segment) model3d.Solid
- func LineJoin(r float64, lines ...model3d.Segment) model3d.Solid
- func RadialCurve(steps int, closed bool, f CurveFunc) model3d.Solid
- func SliceSolid(solid model3d.Solid, axis Axis, axisValue float64) model2d.Solid
- func Teardrop3D(p1, p2 model3d.Coord3D, radius float64) model3d.Solid
- func TriangularBall(thickness float64, p model3d.Coord3D) model3d.Solid
- func TriangularLine(thickness float64, p1, p2 model3d.Coord3D) model3d.Solid
- func TriangularPolygon(thickness float64, close bool, p ...model3d.Coord3D) model3d.Solid
- type Axis
- type AxisPinch
- type AxisSqueeze
- type CoordColorFunc
- func (c CoordColorFunc) Cached() CoordColorFunc
- func (c CoordColorFunc) ChangeFilterFunc(m *model3d.Mesh, epsilon float64) func(c model3d.Coord3D) bool
- func (c CoordColorFunc) Map(f func(model3d.Coord3D) model3d.Coord3D) CoordColorFunc
- func (c CoordColorFunc) QuantizedTriangleColor(mesh *model3d.Mesh, numColors int) func(t *model3d.Triangle) [3]float64
- func (c CoordColorFunc) RenderColor(coord model3d.Coord3D, rc model3d.RayCollision) render3d.Color
- func (c CoordColorFunc) SRGB(coord model3d.Coord3D) [3]float64
- func (c CoordColorFunc) SaveTexturedMaterialOBJ(path string, mesh *model3d.Mesh, uvMap model3d.MeshUVMap, resolution int, ...) error
- func (c CoordColorFunc) ToTexture(out *render3d.Image, mapping model3d.MeshUVMap, antialias int, verbose bool)
- func (c CoordColorFunc) Transform(t model3d.Transform) CoordColorFunc
- func (c CoordColorFunc) TriangleColor(t *model3d.Triangle) [3]float64
- type CurveFunc
- type Equirect
- type GearProfile
- type GridSearch2D
- type GridSearch3D
- func (g *GridSearch3D) MaxSDF(s model3d.SDF) (model3d.Coord3D, float64)
- func (g *GridSearch3D) Maximize(min, max model3d.Coord3D, f func(model3d.Coord3D) float64) (model3d.Coord3D, float64)
- func (g *GridSearch3D) Minimize(min, max model3d.Coord3D, f func(model3d.Coord3D) float64) (model3d.Coord3D, float64)
- type HeightMap
- func (h *HeightMap) AddHeightMap(h1 *HeightMap) bool
- func (h *HeightMap) AddSphere(center model2d.Coord, radius float64) bool
- func (h *HeightMap) AddSphereFill(center model2d.Coord, radius, sphereRadius float64) bool
- func (h *HeightMap) AddSpheresSDF(p model2d.PointSDF, numSpheres int, eps, maxRadius float64)
- func (h *HeightMap) Copy() *HeightMap
- func (h *HeightMap) HeightSquaredAt(c model2d.Coord) float64
- func (h *HeightMap) HigherAt(c model2d.Coord, height float64) bool
- func (h *HeightMap) MaxHeight() float64
- func (h *HeightMap) Mesh() *model3d.Mesh
- func (h *HeightMap) MeshBidir() *model3d.Mesh
- func (h *HeightMap) SetHeightSquaredAt(c model2d.Coord, hs float64)
- type HelicalGear
- type LineSearch
- type LineSearch3D
- func (l *LineSearch3D) Maximize(min, max model3d.Coord3D, f func(model3d.Coord3D) float64) (x model3d.Coord3D, fVal float64)
- func (l *LineSearch3D) Minimize(min, max model3d.Coord3D, f func(model3d.Coord3D) float64) (x model3d.Coord3D, fVal float64)
- func (l *LineSearch3D) SolidBounds(solid model3d.Solid) (min, max model3d.Coord3D)
- type Ramp
- type RectSet
- func (r *RectSet) Add(rect *model3d.Rect)
- func (r *RectSet) AddRectSet(r1 *RectSet)
- func (r *RectSet) ExactMesh() *model3d.Mesh
- func (r *RectSet) Max() model3d.Coord3D
- func (r *RectSet) Mesh() *model3d.Mesh
- func (r *RectSet) Min() model3d.Coord3D
- func (r *RectSet) Remove(rect *model3d.Rect)
- func (r *RectSet) RemoveRectSet(r1 *RectSet)
- func (r *RectSet) Solid() model3d.Solid
- type ScrewSolid
- type SmartSqueeze
- type SpurGear
- type Teardrop2D
Constants ¶
const ( AxisX = 0 AxisY = 1 AxisZ = 2 )
const ( DefaultSqueezeRatio = 0.1 DefaultPinchPower = 0.25 )
const DefaultTextureImageAntialias = 4
Variables ¶
This section is empty.
Functions ¶
func AngleDist ¶ added in v0.3.5
AngleDist computes the (shortest) absolute distance in radians between two angles. In the most basic case, this is equivalent to ||theta2 - theta1||. However, it handles the fact that angles can be offset by multiples of 2*pi.
func CanonicalAngle ¶ added in v0.3.5
CanonicalAngle converts an angle to the range [0, 2*pi].
func ClampAxis ¶ added in v0.3.4
ClampAxis creates a solid which does not extend beyond the range [min, max] along the given axis.
func ClampAxisMax ¶ added in v0.3.4
ClampAxisMax clamps the solid below a given maximum value along a given axis.
func ClampAxisMin ¶ added in v0.3.4
ClampAxisMin clamps the solid above a given minimum value along a given axis.
func HeightMapToSolid ¶ added in v0.2.8
HeightMapToSolid creates a 3D solid representing the volume under a height map and above the Z plane.
func HeightMapToSolidBidir ¶ added in v0.2.8
HeightMapToSolidBidir is like HeightMapToSolid, but it mirrors the solid across the Z plane to make it symmetric.
func L1LineJoin ¶ added in v0.2.13
L1LineJoin is like LineJoin, but uses L1 distance.
func LineJoin ¶ added in v0.2.11
LineJoin creates a Solid containing all points within a distance d of any line segments in a list.
func RadialCurve ¶ added in v0.3.4
RadialCurve creates a solid around a parametric curve.
The radius of the solid may vary across t, and extends in every normal direction to the curve.
func SliceSolid ¶ added in v0.4.2
SliceSolid returns a 2D cross-section of a 3D solid along the given axis at the given offset.
For example, if axis is AxisY, and axisValue is 3, then the resulting solid is true at (x', y') if the 3D solid is true at (x', 3, y').
func Teardrop3D ¶ added in v0.2.8
Teardrop3D creates a 3D teardrop by extending a profile Teardrop2D between p1 and p2.
If possible, the point of the teardrop will be facing into the positive Z direction to avoid supports.
func TriangularBall ¶ added in v0.2.13
TriangularBall creates a solid that is true within a given L1 distance from a point p.
func TriangularLine ¶ added in v0.2.13
TriangularLine creates a solid that is true within a given L1 distance of a segment, with the exception that it is always false past the endpoints.
To "smooth" the endpoints, use TriangularBall().
func TriangularPolygon ¶ added in v0.2.13
TriangularPolygon is similar to L1LineJoin, but only adds L1 balls to the connections between segments, rather than to all endpoints.
If close is true, then the last point is connected to the first. Otherwise, the endpoints are "cut off", i.e. points past the endpoints will not be inside the solid, even if they are within thickness distance of the endpoint. To achieve "rounded" tips, use TriangularBall() at the endpoints.
Types ¶
type AxisPinch ¶ added in v0.2.4
type AxisPinch struct { // The axis to pinch along. Axis Axis // Bounds on the axis to pinch. Min float64 Max float64 // Power controls how much pinching is performed. // A Power of 1 means no pinching. // Higher powers perform spatial pinching. // Lower powers un-pinch a region, moving coordinates // further from the center. // Reciprocal powers undo each other. Power float64 }
AxisPinch is similar to AxisSqueeze, except that it does not affect space outside of the pinched region.
Coordinates within the pinched region are pulled to the center of the region by following some polynomial.
AxisPinch can be used to prevent jagged edges on the tops and bottoms of marching cubes solids, by pinching the uneven edges into a much flatter surface.
func (*AxisPinch) ApplyBounds ¶ added in v0.2.4
ApplyBounds pinches the bounds.
type AxisSqueeze ¶
type AxisSqueeze struct { // The axis to compress. Axis Axis // Bounds on the axis to compress. Min float64 Max float64 // This is (new length / old length). // For example, if we use a squeeze ratio of 0.1, // then squeezing 2 inches will bring it down to // 0.2 inches. Ratio float64 }
AxisSqueeze is a coordinate transformation which squeezes some section of space into a much smaller amount of space along some axis.
AxisSqueeze can be used to efficiently produce meshes which are mostly uniform along some axis, for example a tall cylinder.
func (*AxisSqueeze) Apply ¶
func (a *AxisSqueeze) Apply(c model3d.Coord3D) model3d.Coord3D
Apply squeezes the coordinate.
func (*AxisSqueeze) ApplyBounds ¶
func (a *AxisSqueeze) ApplyBounds(min, max model3d.Coord3D) (newMin, newMax model3d.Coord3D)
ApplyBounds squeezes the bounds.
func (*AxisSqueeze) Inverse ¶
func (a *AxisSqueeze) Inverse() model3d.Transform
Inverse creates an AxisSqueeze that undoes the squeeze performed by a.
type CoordColorFunc ¶ added in v0.3.0
CoordColorFunc wraps a generic point-to-color function and provides methods for various other color-using APIs.
func ConstantCoordColorFunc ¶ added in v0.3.3
func ConstantCoordColorFunc(c render3d.Color) CoordColorFunc
ConstantCoordColorFunc creates a CoordColorFunc that returns a constant value.
func JoinedCoordColorFunc ¶ added in v0.3.3
func JoinedCoordColorFunc(sdfsAndColors ...any) CoordColorFunc
JoinedCoordColorFunc creates a CoordColorFunc that evaluates separate CoordColorFunc for different objects, where the object with maximum SDF is chosen.
Pass a sequence of object, color, object, color, ... where objects are *model3d.Mesh or model3d.SDF, and colors are render3d.Color or CoordColorFunc.
func JoinedMeshCoordColorFunc ¶ added in v0.3.4
func JoinedMeshCoordColorFunc(meshToColorFunc map[*model3d.Mesh]any) CoordColorFunc
JoinedMeshCoordColorFunc combines CoordColorFuncs for different meshes, using the color function of the mesh closest to a given point.
This behaves similarly to JoinedCoordColorFunc, but will choose the closest surface rather than the object with the overall greatest SDF. This should only affect points contained inside of the union of all of the objects.
func JoinedSolidCoordColorFunc ¶ added in v0.3.4
func JoinedSolidCoordColorFunc(points any, solidsAndColors ...any) CoordColorFunc
JoinedSolidCoordColorFunc creates a CoordColorFunc that returns colors for different solids depending on which solid contains a point. If multiple solids contain a point, the average of the solids' colors are used.
The points argument is a collection of points that are known to be within some solid. It may either be a slice of points, a *CoordTree, or a *CoordMap[Coord3D] returned by model3d.MarchingCubesInterior. It can also be nil, in which case no nearest neighbor lookups are performed. Note that the color function will panic() if no solid contains a given point or its nearest neighbor.
Since the color func must work on all points, not just points contained within one of the solids, a separate set of interior points should be provided to use for nearest neighbor lookup. This is the points argument.
func (CoordColorFunc) Cached ¶ added in v0.3.3
func (c CoordColorFunc) Cached() CoordColorFunc
Cached wraps c in another CoordColorFunc that caches colors for coordinates.
The cached function is safe to call concurrently from multiple Goroutines at once.
func (CoordColorFunc) ChangeFilterFunc ¶ added in v0.3.4
func (c CoordColorFunc) ChangeFilterFunc(m *model3d.Mesh, epsilon float64) func(c model3d.Coord3D) bool
ChangeFilterFunc creates a filter for mesh decimation that avoids decimating vertices near color changes.
In particular, it returns a function that returns true for points further than epsilon distance of a mesh vertex that is part of a segment that changes color.
func (CoordColorFunc) Map ¶ added in v0.4.2
func (c CoordColorFunc) Map(f func(model3d.Coord3D) model3d.Coord3D) CoordColorFunc
Map returns a new CoordColorFunc which applies f to all input coordinates before calling c.
func (CoordColorFunc) QuantizedTriangleColor ¶ added in v0.4.2
func (c CoordColorFunc) QuantizedTriangleColor(mesh *model3d.Mesh, numColors int) func(t *model3d.Triangle) [3]float64
QuantizedTriangleColor clusters triangle colors and returns a mapping from triangles to a finite space of colors.
Inputs to the resulting function need not be contained in the original mesh. The mesh is only used to obtain a dataset for clustering.
It is recommended that you call this on a cached CoordColorFunc to avoid re-computing colors at vertices shared across triangles.
func (CoordColorFunc) RenderColor ¶ added in v0.3.0
func (c CoordColorFunc) RenderColor(coord model3d.Coord3D, rc model3d.RayCollision) render3d.Color
RenderColor is a render3d.ColorFunc wrapper for c.F.
func (CoordColorFunc) SRGB ¶ added in v0.4.4
func (c CoordColorFunc) SRGB(coord model3d.Coord3D) [3]float64
SRGB returns the sRGB color as an array. This is useful for use with mesh.SaveVertexColorOBJ().
func (CoordColorFunc) SaveTexturedMaterialOBJ ¶ added in v0.4.0
func (c CoordColorFunc) SaveTexturedMaterialOBJ(path string, mesh *model3d.Mesh, uvMap model3d.MeshUVMap, resolution int, verbose bool) error
SaveTexturedMaterialOBJ writes an OBJ zip file with a material based on the color function.
The material is encoded as a texture with the given resolution as its side length.
It is highly recommended that the texture size is a multiple of 2 to work best with edges in an automatic UV map.
The provided uvMap is used to map texture coordinates to 3D coordinates. If it is nil, one will be built automatically.
func (CoordColorFunc) ToTexture ¶ added in v0.4.0
func (c CoordColorFunc) ToTexture(out *render3d.Image, mapping model3d.MeshUVMap, antialias int, verbose bool)
ToTexture writes a texture image for a UV map by averaging colors for 3D points mapped from each pixel.
This assumes that the UV map is confined to the unit square.
The antialias argument specifies the square root of the number of points to sample per pixel. A value of 0 will default to DefaultTextureImageAntialias.
func (CoordColorFunc) Transform ¶ added in v0.3.4
func (c CoordColorFunc) Transform(t model3d.Transform) CoordColorFunc
Transform wraps c in another CoordColorFunc that applies the inverse of t to input points.
func (CoordColorFunc) TriangleColor ¶ added in v0.3.0
func (c CoordColorFunc) TriangleColor(t *model3d.Triangle) [3]float64
TriangeColor returns sRGB colors for triangles by averaging the sRGB values of each vertex.
type CurveFunc ¶ added in v0.3.4
A CurveFunc is a parametric curve defined over [0, 1]. It returns a radius and point for each time value.
type Equirect ¶
type Equirect struct {
// contains filtered or unexported fields
}
An Equirect is an equirectangular bitmap representing colors on a sphere.
It can be used, for example, to aid in implementing a 3D polar function.
func NewEquirect ¶
NewEquirect creates an Equirect from an image. It is assumed that the top of the image is north (positive latitude), the bottom of the image is south, the left is west (negative longitude), the right is east (positive longitude).
type GearProfile ¶
func InvoluteGearProfile ¶
func InvoluteGearProfile(pressureAngle, module, clearance float64, numTeeth int) GearProfile
InvoluteGearProfile creates a GearProfile for a standard involute gear with the given specs.
func InvoluteGearProfileSizes ¶
func InvoluteGearProfileSizes(pressureAngle, module, addendum, dedendum float64, numTeeth int) GearProfile
InvoluteGearProfileSizes creates an involute gear profile using different parameters than InvoluteGearProfile.
type GridSearch2D ¶ added in v0.2.11
type GridSearch2D numerical.GridSearch2D
GridSearch2D is an extension of numerical.GridSearch2D with extra helper methods for concrete applications.
func (*GridSearch2D) MaxSDF ¶ added in v0.2.11
MaxSDF finds the point with maximal SDF and returns it, along with the SDF value.
type GridSearch3D ¶ added in v0.4.2
type GridSearch3D numerical.GridSearch3D
GridSearch3D is an extension of numerical.GridSearch3D with extra helper methods for concrete applications.
func (*GridSearch3D) MaxSDF ¶ added in v0.4.2
MaxSDF finds the point with maximal SDF and returns it, along with the SDF value.
type HeightMap ¶ added in v0.2.8
type HeightMap struct { // 2D boundaries of the grid. Min model2d.Coord Max model2d.Coord // Spacing of the grid elements. Delta float64 // Row-major data storing the squared heights at every // grid element. Rows int Cols int Data []float64 }
A HeightMap maps a 2D grid of points to non-negative Z values.
The HeightMap can be updated by adding hemispheres and other HeightMaps. These operations are union operators, in that they never reduce the height at any given grid point.
The HeightMap automatically performs interpolation for reads to provide the appearance of a continuous curve.
func NewHeightMap ¶ added in v0.2.8
NewHeightMap fills a rectangular 2D region with a height map that starts out at zero height.
The maxSize argument limits the number of rows and columns, and will be the greater of the two dimensions in the data grid.
func (*HeightMap) AddHeightMap ¶ added in v0.2.8
AddHeightMap writes the union of h and h1 to h.
This is optimized for the case when h and h1 are laid out exactly the same, with the same grid spacing and boundaries.
One use case for this API is to combine multiple height maps that were generated on different Goroutines.
Returns true if h1 modified h, or false otherwise.
func (*HeightMap) AddSphere ¶ added in v0.2.8
AddSphere adds a hemisphere to the height map, updating any cells that were lower than the corresponding point on the hemisphere.
Returns true if the sphere changed the height map in any way, or false if the sphere was already covered.
func (*HeightMap) AddSphereFill ¶ added in v0.2.11
AddSphereFill fills a circle with spheres of a bounded radius.
The sphereRadius argument determines the maximum radius for a sphere. The radius argument determines the radius of the circle to fill with spheres.
Returns true if the spheres changed the height map in any way, or false if the spheres were covered.
func (*HeightMap) AddSpheresSDF ¶ added in v0.2.11
AddSpheresSDF fills a 2D signed distance function with spheres that touch the edges of the SDF. This creates a smooth, 3D version of the 2D model.
The numSpheres argument specifies the number of spheres to sample inside the shape.
The eps argument is a small value used to determine the medial axis. Smaller values are more sensitive to jagged edges of the collider. See model2d.ProjectMedialAxis().
The maxRadius argument, if non-zero, is used to limit the height of the resulting object. See HeightMap.AddSphereFill().
func (*HeightMap) HeightSquaredAt ¶ added in v0.2.8
HeightSquaredAt gets the interpolated square of the height at any coordinate.
The coordinate may be out of bounds.
func (*HeightMap) HigherAt ¶ added in v0.2.8
HigherAt checks if the height map is higher than a given height at the given 2D coordinate. Returns true if the height map is higher.
The coordinate may be out of bounds.
func (*HeightMap) MaxHeight ¶ added in v0.2.8
MaxHeight gets the maximum height at any cell in the height map.
func (*HeightMap) Mesh ¶ added in v0.2.14
Mesh generates a solid mesh containing the volume under the height map but above the Z axis.
type HelicalGear ¶
func (*HelicalGear) Max ¶
func (h *HelicalGear) Max() model3d.Coord3D
func (*HelicalGear) Min ¶
func (h *HelicalGear) Min() model3d.Coord3D
type LineSearch ¶ added in v0.2.13
type LineSearch numerical.LineSearch
LineSearch is an extension of numerical.LineSearch with extra helper methods for concrete applications.
func (*LineSearch) CurveBounds ¶ added in v0.2.13
func (l *LineSearch) CurveBounds(min, max float64, f func(float64) model2d.Coord) (model2d.Coord, model2d.Coord)
CurveBounds approximates the bounding box of a parametric curve, such as a 2D bezier curve.
The min and max arguments specify the minimum and maximum argument to pass to f, which is typically in the range [0, 1] for Bezier curves.
type LineSearch3D ¶ added in v0.4.2
type LineSearch3D numerical.RecursiveLineSearch[numerical.Vec3]
LineSearch3D is a 3-dimensional recursive line search with extra helper methods for concrete applications.
func (*LineSearch3D) SolidBounds ¶ added in v0.4.2
func (l *LineSearch3D) SolidBounds(solid model3d.Solid) (min, max model3d.Coord3D)
SolidBounds estimates a tighter bounding rectangle for the solid using line searches to find the boundaries. The resulting bounds will always be slightly too tight, and may need to be expanded depending on the use case.
type Ramp ¶
type Ramp struct { model3d.Solid // P1 is the tip of the ramp, where the scale is 0. // Any point further in the direction of P1 will have // a scale of zero. P1 model3d.Coord3D // P2 is the base of the ramp, where the scale is 1. // Any point further in the direction of P2 will have // a scale of one. P2 model3d.Coord3D }
A Ramp wraps an existing solid and gradually increases the scale of the solid from 0% to 100% along a given axis.
This makes it easier to make shapes like upside-down pyramids and cones for use in FDM printing without supports.
type RectSet ¶ added in v0.2.11
type RectSet struct {
// contains filtered or unexported fields
}
A RectSet maintains the set of all points contained in a union of rectangular volumes.
The exact list of original rectangles is not preserved, but the information about the combined solid is.
A RectSet may use up to O(N^3) memory, where N is the number of contained rectangular volumes. In particular, usage is proportional to X*Y*Z, where X, Y and Z are the number of unique x, y, and z coordinates.
func (*RectSet) AddRectSet ¶ added in v0.2.11
AddRectSet adds another RectSet's volume to the set.
func (*RectSet) ExactMesh ¶ added in v0.2.11
ExactMesh creates a 3D mesh from the set of rects.
The returned mesh is not guaranteed to be manifold. For example, it is possible to create two rects that touch at a single vertex or edge, in which case there will be a singularity in the resulting mesh.
To create a manifold mesh, use Mesh().
func (*RectSet) RemoveRectSet ¶ added in v0.2.11
RemoveRectSet subtracts another RectSet's volume from the set.
type ScrewSolid ¶
type ScrewSolid struct { // P1 is the center of the start of the screw. P1 model3d.Coord3D // P2 is the center of the end of the screw. P2 model3d.Coord3D // Radius is the maximum radius of the screw, // including grooves. Radius float64 // GrooveSize is the size of the grooves. // This may not exceed Radius. GrooveSize float64 // Pointed can be set to true to indicate that the tip // at the P2 end should be cut off at a 45 degree // angle (in the shape of a cone). // Can be used for internal screw holes to avoid // support. Pointed bool }
A ScrewSolid is a model3d.Solid implementation of screws. It can also be used for screw holes, by combining it with model3d.SubtractedSolid.
Screws are similar to cylinders, so many of the fields are analogous to model3d.CylinderSolid.
func (*ScrewSolid) Max ¶
func (s *ScrewSolid) Max() model3d.Coord3D
func (*ScrewSolid) Min ¶
func (s *ScrewSolid) Min() model3d.Coord3D
type SmartSqueeze ¶ added in v0.2.7
type SmartSqueeze struct { // Axis is the axis to squeeze along. Axis Axis // SqueezeRatio is the axis squeeze ratio to use. SqueezeRatio float64 // PinchRange specifies how much space should be added // before and after a pinch to avoid singularities. // Should be small, but larger than the marching cubes // epsilon. PinchRange float64 // PinchPower is the power for pinches. PinchPower float64 // Ranges along the axis that cannot be squeezed. // Typically ranges should be added via AddUnsqueezable(). Unsqueezable [][2]float64 // Values of the axis at which a pinch should be used // to flatten plateaus. // Typically pinches will be added via AddPinch(). Pinches []float64 }
SmartSqueeze creates a transformation to squeeze a model along a certain axis without affecting certain regions that don't lend themselves to squeezing.
func NewSmartSqueeze ¶ added in v0.2.13
func NewSmartSqueeze(axis Axis, squeezeRatio, pinchRange, pinchPower float64) *SmartSqueeze
NewSmartSqueeze creates a SmartSqueeze with the given parameters, using defaults when necessary.
If squeezeRatio is 0, DefaultSqueezeRatio is used. If pinchPower is 0, DefaultPinchPower is used.
func (*SmartSqueeze) AddPinch ¶ added in v0.2.7
func (s *SmartSqueeze) AddPinch(val float64)
AddPinch adds an axis value at which the coordinates should be squeezed to flatten plateaus.
func (*SmartSqueeze) AddUnsqueezable ¶ added in v0.2.7
func (s *SmartSqueeze) AddUnsqueezable(min, max float64)
AddUnsqueezable adds a range of axis values in which no squeezing should be performed.
func (*SmartSqueeze) MarchingCubesSearch ¶ added in v0.2.7
func (s *SmartSqueeze) MarchingCubesSearch(solid model3d.Solid, delta float64, iters int) *model3d.Mesh
MachingCubesSearch uses the smart squeeze to convert a solid into a mesh efficiently.
In particular, the model is transformed, meshified, and then the inverse transformation is applied.
For usage information, see model3d.MarchingCubesSearch.
type Teardrop2D ¶ added in v0.2.8
type Teardrop2D struct { // Center is the center of the circle. Center model2d.Coord // Radius is the radius of the circle. Radius float64 // Direction is the direction in which the tip of the // tangent triangle is pointing. // If this is the zero vector, then a unit vector in // the Y direction is used. Direction model2d.Coord }
Teardrop2D is a 2D solid in a "teardrop" shape, i.e. a circle with a tangent triangle pointing off in one direction.
This can be used to cut circles out of shapes while avoiding support structures in FDM printing.
The shape, rendered in ASCII, looks like so:
--(&)-- @@@@/ (@@@@ @@@ @@@ /@@ @@. @@ @@ @@ @@ &@ @ @% @@ @@ @@ @@# @@@ @@@ @@@ &@@ @@* @@& @@@ @@@ @@# @@@ ^
func (*Teardrop2D) Max ¶ added in v0.2.8
func (t *Teardrop2D) Max() model2d.Coord
func (*Teardrop2D) Min ¶ added in v0.2.8
func (t *Teardrop2D) Min() model2d.Coord