Merge pull request #1100 from RAMilewski/master

Synopses
This commit is contained in:
Revar Desmera 2023-03-28 18:22:41 -07:00 committed by GitHub
commit 9b150c9728
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 357 additions and 134 deletions

View file

@ -2,7 +2,7 @@
// LibFile: attachments.scad
// The modules in this file allows you to attach one object to another by making one object the child of another object.
// You can place the child object in relation to its parent object and control the position and orientation
// relative to the parent. The modifiers allow you to treat children in different ways that simple union, such
// relative to the parent. The modifiers allow you to treat children in ways different from simple union, such
// as differencing them from the parent, or changing their color. Attachment only works when the parent and child
// are both written to support attachment. Also included in this file are the tools to make your own "attachable" objects.
// Includes:
@ -42,7 +42,7 @@ _ANCHOR_TYPES = ["intersect","hull"];
// This library adds the concept of anchoring, spin and orientation to the `cube()`, `cylinder()`
// and `sphere()` builtins, as well as to most of the shapes provided by this library itself.
// - An anchor is a place on an object which you can align the object to, or attach other objects
// to using `attach()` or `position()`. An anchor has a position, a direction, and a spin.
// to using `attach()` or `position()`. An anchor has a position, a direction, and a spin.
// The direction and spin are used to orient other objects to match when using `attach()`.
// - Spin is a simple rotation around the Z axis.
// - Orientation is rotating an object so that its top is pointed towards a given vector.
@ -270,7 +270,7 @@ _ANCHOR_TYPES = ["intersect","hull"];
// _show_edges(edges="NONE");
// }
// }
// Figure(3D,Big,VPD=310,NoScales): Next are some examples showing how you can combine edge descriptors to obtain different edge sets. You can specify the top front edge with a numerical vector or by combining the named direction vectors. If you combine them as a list you get all the edges around the front or top faces. Adding `except` removes an edge.
// Figure(3D,Big,VPD=310,NoScales): Next are some examples showing how you can combine edge descriptors to obtain different edge sets. You can specify the top front edge with a numerical vector or by combining the named direction vectors. If you combine them as a list you get all the edges around the front and top faces. Adding `except` removes an edge.
// xdistribute(43){
// _show_edges(_edges([0,-1,1]),toplabel=["edges=[0,-1,1]"]);
// _show_edges(_edges(TOP+FRONT),toplabel=["edges=TOP+FRONT"]);
@ -463,12 +463,13 @@ _ANCHOR_TYPES = ["intersect","hull"];
// Section: Attachment Positioning
// Module: position()
// Usage:
// PARENT() position(from) CHILDREN;
//
// Synopsis: Attaches children to a parent object at an anchor point.
// Topics: Attachments
// See Also: attachable(), attach(), orient()
//
// Usage:
// PARENT() position(from) CHILDREN;
//
// Description:
// Attaches children to a parent object at an anchor point. For a step-by-step explanation
// of attachments, see the [[Attachments Tutorial|Tutorial-Attachments]].
@ -500,9 +501,12 @@ module position(from)
// Module: orient()
// Synopsis: Orients children's tops in the directon of the specified anchor.
// Topics: Attachments
// See Also: attachable(), attach(), orient()
// Usage:
// PARENT() orient(anchor, [spin]) CHILDREN;
// Topics: Attachments
// Description:
// Orients children such that their top is tilted in the direction of the specified parent anchor point.
// For a step-by-step explanation of attachments, see the [[Attachments Tutorial|Tutorial-Attachments]].
@ -513,7 +517,7 @@ module position(from)
// `$attach_anchor` is set to the `[ANCHOR, POSITION, ORIENT, SPIN]` information for the `anchor=`, if given.
// `$attach_to` is set to `undef`.
// `$attach_norot` is set to `true`.
// See Also: attachable(), attach(), orient()
//
// Example: When orienting to an anchor, the spin of the anchor may cause confusion:
// prismoid([50,50],[30,30],h=40) {
// position(TOP+RIGHT)
@ -551,11 +555,13 @@ module orient(anchor, spin) {
// Module: attach()
// Synopsis: Attaches children to a parent object at an anchor point and orientation.
// Topics: Attachments
// See Also: attachable(), position(), face_profile(), edge_profile(), corner_profile()
//
// Usage:
// PARENT() attach(from, [overlap=], [norot=]) CHILDREN;
// PARENT() attach(from, to, [overlap=], [norot=]) CHILDREN;
// Topics: Attachments
// See Also: attachable(), position(), face_profile(), edge_profile(), corner_profile()
// Description:
// Attaches children to a parent object at an anchor point and orientation. Attached objects will
// be overlapped into the parent object by a little bit, as specified by the `$overlap`
@ -606,10 +612,12 @@ module attach(from, to, overlap, norot=false)
// Section: Tagging
// Module: tag()
// Usage:
// PARENT() tag(tag) CHILDREN;
// Synopsis: Assigns a tag to an object
// Topics: Attachments
// See Also: force_tag(), recolor(), hide(), show_only(), diff(), intersect()
//
// Usage:
// PARENT() tag(tag) CHILDREN;
// Description:
// Assigns the specified tag to all of the children. Note that if you want
// to apply a tag to non-tag-aware objects you need to use {{force_tag()}} instead.
@ -643,10 +651,12 @@ module tag(tag)
// Module: force_tag()
// Usage:
// PARENT() force_tag([tag]) CHILDREN;
// Assigns a tag to a non-attachable object.
// Topics: Attachments
// See Also: tag(), recolor(), hide(), show_only(), diff(), intersect()
//
// Usage:
// PARENT() force_tag([tag]) CHILDREN;
// Description:
// You use this module when you want to make a non-attachable or non-BOSL2 module respect tags.
// It applies to its children the tag specified (or the tag currently in force if you don't specify a tag),
@ -705,10 +715,12 @@ module force_tag(tag)
// Module: default_tag()
// Usage:
// PARENT() default_tag(tag) CHILDREN;
// Synopsis: Sets a default tag for all children.
// Topics: Attachments
// See Also: force_tag(), recolor(), hide(), show_only(), diff(), intersect()
//
// Usage:
// PARENT() default_tag(tag) CHILDREN;
// Description:
// Sets a default tag for all of the children. This is intended to be used to set a tag for a whole module
// that is then used outside the module, such as setting the tag to "remove" for easy operation with {{diff()}}.
@ -788,12 +800,14 @@ module tag_scope(scope){
// Section: Attachment Modifiers
// Module: diff()
// Usage:
// diff([remove], [keep]) PARENT() CHILDREN;
// Synopsis: Performs a differencing operation using tags rather than hierarchy to control what happens.
// Topics: Attachments
// See Also: tag(), force_tag(), recolor(), show_only(), hide(), tag_diff(), intersect(), tag_intersect()
//
// Usage:
// diff([remove], [keep]) PARENT() CHILDREN;
// Description:
// Perform a differencing operation using tags to control what happens. This is specifically intended to
// Performs a differencing operation using tags to control what happens. This is specifically intended to
// address the situation where you want differences between a parent and child object, something
// that is impossible with the native difference() module.
// The children to diff are grouped into three categories, regardless of nesting level.
@ -976,10 +990,12 @@ module diff(remove="remove", keep="keep")
// Module: tag_diff()
// Usage:
// tag_diff(tag, [remove], [keep]) PARENT() CHILDREN;
// Synopsis: Performs a {{diff()}} and then sets a tag on the result.
// Topics: Attachments
// See Also: tag(), force_tag(), recolor(), show_only(), hide(), diff(), intersect(), tag_intersect()
//
// Usage:
// tag_diff(tag, [remove], [keep]) PARENT() CHILDREN;
// Description:
// Perform a differencing operation in the manner of {{diff()}} using tags to control what happens,
// and then tag the resulting difference object with the specified tag. This forces the specified
@ -1046,10 +1062,12 @@ module tag_diff(tag,remove="remove", keep="keep")
// Module: intersect()
// Usage:
// intersect([intersect], [keep]) PARENT() CHILDREN;
// Synopsis: Perform an intersection operation on children using tags rather than hierarchy to control what happens.
// Topics: Attachments
// See Also: tag(), force_tag(), recolor(), show_only(), hide(), diff(), tag_diff(), tag_intersect()
//
// Usage:
// intersect([intersect], [keep]) PARENT() CHILDREN;
// Description:
// Performs an intersection operation on its children, using tags to
// determine what happens. This is specifically intended to address
@ -1115,10 +1133,12 @@ module intersect(intersect="intersect",keep="keep")
// Module: tag_intersect()
// Usage:
// tag_intersect(tag, [intersect], [keep]) PARENT() CHILDREN;
// Synopsis: Performs an {{intersect()}} and then tags the result.
// Topics: Attachments
// See Also: tag(), force_tag(), recolor(), show_only(), hide(), diff(), tag_diff(), intersect()
//
// Usage:
// tag_intersect(tag, [intersect], [keep]) PARENT() CHILDREN;
// Description:
// Perform an intersection operation in the manner of {{intersect()}} using tags to control what happens,
// and then tag the resulting difference object with the specified tag. This forces the specified
@ -1170,10 +1190,12 @@ module tag_intersect(tag,intersect="intersect",keep="keep")
// Module: conv_hull()
// Usage:
// conv_hull([keep]) CHILDREN;
// Synopsis: Performs a hull operation on the children using tags to determine what happens.
// Topics: Attachments
// See Also: tag(), recolor(), show_only(), hide(), diff(), intersect()
//
// Usage:
// conv_hull([keep]) CHILDREN;
// Description:
// Performs a hull operation on the children using tags to determine what happens. The items
// not tagged with the `keep` tags are combined into a convex hull, and the children tagged with the keep tags
@ -1206,10 +1228,12 @@ module conv_hull(keep="keep")
// Module: tag_conv_hull()
// Usage:
// tag_conv_hull(tag, [keep]) CHILDREN;
// Synopsis: Performs a {{conv_hull()}} and then sets a tag on the result.
// Topics: Attachments
// See Also: tag(), recolor(), show_only(), hide(), diff(), intersect()
//
// Usage:
// tag_conv_hull(tag, [keep]) CHILDREN;
// Description:
// Perform a convex hull operation in the manner of {{conv_hull()}} using tags to control what happens,
// and then tag the resulting hull object with the specified tag. This forces the specified
@ -1256,10 +1280,12 @@ module tag_conv_hull(tag,keep="keep")
// Module: hide()
// Synopsis: Hides attachable children with the given tags.
// Topics: Attachments
// See Also: tag(), recolor(), show_only(), show_all(), show_int(), diff(), intersect()
//
// Usage:
// hide(tags) CHILDREN;
// Topics: Attachments
// See Also: tag(), recolor(), show_only(), diff(), intersect()
// Description:
// Hides all attachable children with the given tags, which you supply as a space separated string. Previously hidden objects remain hidden, so hiding is cumulative, unlike `show_only()`.
// For a step-by-step explanation of attachments, see the [[Attachments Tutorial|Tutorial-Attachments]].
@ -1290,10 +1316,12 @@ module hide(tags)
// Module: show_only()
// Synopsis: Show only the children with the listed tags.
// See Also: tag(), recolor(), show_all(), show_int(), diff(), intersect()
// Topics: Attachments
//
// Usage:
// show_only(tags) CHILDREN;
// Topics: Attachments
// See Also: tag(), recolor(), hide(), diff(), intersect()
// Description:
// Show only the children with the listed tags, which you sply as a space separated string. Only unhidden objects will be shown, so if an object is hidden either before or after the `show_only()` call then it will remain hidden. This overrides any previous `show_only()` calls. Unlike `hide()`, calls to `show_only()` are not cumulative.
// For a step-by-step explanation of attachments, see the [[Attachments Tutorial|Tutorial-Attachments]].
@ -1316,6 +1344,10 @@ module show_only(tags)
}
// Module: show_all()
// Synopsis: Shows all children and clears tags.
// See Also: tag(), recolor(), show_only(), show_int(), diff(), intersect()
// Topics: Attachments
//
// Usage;
// show_all() CHILDREN;
// Description:
@ -1334,6 +1366,10 @@ module show_all()
// Module: show_int()
// Synopsis: Shows children with the listed tags which were already shown in the parent context.
// See Also: tag(), recolor(), show_only(), show_all(), show_int(), diff(), intersect()
// Topics: Attachments
//
// Usage:
// show_int(tags) CHILDREN;
// Description:
@ -1353,13 +1389,16 @@ module show_int(tags)
}
// Section: Attachable Masks
// Section: Mask Attachment
// Module: face_mask()
// Synopsis: Ataches a 3d mask shape to the given faces of the parent.
// Topics: Attachments, Masking
// See Also: attachable(), position(), edge_mask(), corner_mask(), face_profile(), edge_profile(), corner_profile()
//
// Usage:
// PARENT() face_mask(faces) CHILDREN;
// Topics: Attachments, Masking
// Description:
// Takes a 3D mask shape, and attaches it to the given faces, with the appropriate orientation to be
// differenced away. The mask shape should be vertically oriented (Z-aligned) with the bottom half
@ -1399,10 +1438,12 @@ module face_mask(faces=[LEFT,RIGHT,FRONT,BACK,BOT,TOP]) {
// Module: edge_mask()
// Synopsis: Attaches a 3D mask shape to the given edges of the parent.
// Topics: Attachments, Masking
// See Also: attachable(), position(), attach(), face_mask(), corner_mask(), face_profile(), edge_profile(), corner_profile()
//
// Usage:
// PARENT() edge_mask([edges], [except]) CHILDREN;
// Topics: Attachments, Masking
// See Also: attachable(), position(), attach(), face_profile(), edge_profile(), corner_mask(), face_mask()
// Description:
// Takes a 3D mask shape, and attaches it to the given edges, with the appropriate orientation to be
// differenced away. The mask shape should be vertically oriented (Z-aligned) with the back-right
@ -1462,10 +1503,12 @@ module edge_mask(edges=EDGES_ALL, except=[]) {
// Module: corner_mask()
// Synopsis: Attaches a 3d mask shape to the given corners of the parent.
// Topics: Attachments, Masking
// See Also: attachable(), position(), attach(), face_mask(), edge_mask(), face_profile(), edge_profile(), corner_profile()
//
// Usage:
// PARENT() corner_mask([corners], [except]) CHILDREN;
// Topics: Attachments, Masking
// See Also: attachable(), position(), attach(), face_profile(), edge_profile(), edge_mask()
// Description:
// Takes a 3D mask shape, and attaches it to the specified corners, with the appropriate orientation to
// be differenced away. The 3D corner mask shape should be designed to mask away the X+Y+Z+ octant. If no tag is set
@ -1511,10 +1554,12 @@ module corner_mask(corners=CORNERS_ALL, except=[]) {
// Module: face_profile()
// Synopsis: Extrudes a 2D edge profile into a mask for all edges and corners of the given faces on the parent.
// Topics: Attachments, Masking
// See Also: attachable(), position(), attach(), edge_profile(), corner_profile(), face_mask(), edge_mask(), corner_mask()
//
// Usage:
// PARENT() face_profile(faces, r|d=, [convexity=]) CHILDREN;
// Topics: Attachments, Masking
// See Also: attachable(), position(), attach(), edge_profile(), corner_profile()
// Description:
// Given a 2D edge profile, extrudes it into a mask for all edges and corners bounding each given face. If no tag is set
// then `face_profile` sets the tag for children to "remove" so that it will work with the default {{diff()}} tag.
@ -1548,10 +1593,12 @@ module face_profile(faces=[], r, d, convexity=10) {
// Module: edge_profile()
// Synopsis: Extrudes a 2d edge profile into a mask on the given edges of the parent.
// Topics: Attachments, Masking
// See Also: attachable(), position(), attach(), face_profile(), corner_profile(), edge_mask(), face_mask(), corner_mask()
//
// Usage:
// PARENT() edge_profile([edges], [except], [convexity]) CHILDREN;
// Topics: Attachments, Masking
// See Also: attachable(), position(), attach(), face_profile(), corner_profile()
// Description:
// Takes a 2D mask shape and attaches it to the selected edges, with the appropriate orientation and
// extruded length to be `diff()`ed away, to give the edge a matching profile. If no tag is set
@ -1610,10 +1657,12 @@ module edge_profile(edges=EDGES_ALL, except=[], convexity=10) {
}
// Module: corner_profile()
// Synopsis: Rotationally extrudes a 2d edge profile into corner mask on the given corners of the parent.
// Topics: Attachments, Masking
// See Also: attachable(), position(), attach(), face_profile(), edge_profile(), corner_mask(), face_mask(), edge_mask()
//
// Usage:
// PARENT() corner_profile([corners], [except], [r=|d=], [convexity=]) CHILDREN;
// Topics: Attachments, Masking
// See Also: attachable(), position(), attach(), face_profile(), edge_profile()
// Description:
// Takes a 2D mask shape, rotationally extrudes and converts it into a corner mask, and attaches it
// to the selected corners with the appropriate orientation. If no tag is set
@ -1683,6 +1732,9 @@ module corner_profile(corners=CORNERS_ALL, except=[], r, d, convexity=10) {
// Module: attachable()
// Synopsis: Manages the anchoring, spin, orientation, and attachments for an object.
// Topics: Attachments
// See Also: reorient()
//
// Usage: Square/Trapezoid Geometry
// attachable(anchor, spin, two_d=true, size=, [size2=], [shift=], [override=], ...) {OBJECT; children();}
@ -1709,9 +1761,6 @@ module corner_profile(corners=CORNERS_ALL, except=[], r, d, convexity=10) {
// Usage: Pre-Specified Geometry
// attachable(anchor, spin, [orient], geom=) {OBJECT; children();}
//
// Topics: Attachments
// See Also: reorient()
//
// Description:
// Manages the anchoring, spin, orientation, and attachments for OBJECT, located in a 3D volume or 2D area.
// A managed 3D volume is assumed to be vertically (Z-axis) oriented, and centered.
@ -1993,6 +2042,9 @@ module attachable(
}
// Function: reorient()
// Synopsis: Calculates the transformation matrix needed to reorient an object.
// Topics: Attachments
// See Also: reorient(), attachable()
//
// Usage: Square/Trapezoid Geometry
// mat = reorient(anchor, spin, [orient], two_d=true, size=, [size2=], [shift=], ...);
@ -2028,9 +2080,6 @@ module attachable(
// mat = reorient(anchor, spin, [orient], vnf, [extent], ...);
// pts = reorient(anchor, spin, [orient], vnf, [extent], p=, ...);
//
// Topics: Attachments
// See Also: reorient(), attachable()
//
// Description:
// Given anchor, spin, orient, and general geometry info for a managed volume, this calculates
// the transformation matrix needed to be applied to the contents of that volume. A managed 3D
@ -2118,10 +2167,12 @@ function reorient(
// Function: named_anchor()
// Usage:
// a = named_anchor(name, pos, [orient], [spin]);
// Synopsis: Creates an anchro data structure.
// Topics: Attachments
// See Also: reorient(), attachable()
//
// Usage:
// a = named_anchor(name, pos, [orient], [spin]);
// Description:
// Creates an anchor data structure. For a step-by-step explanation of attachments,
// see the [[Attachments Tutorial|Tutorial-Attachments]].
@ -2134,6 +2185,9 @@ function named_anchor(name, pos, orient=UP, spin=0) = [name, pos, orient, spin];
// Function: attach_geom()
// Synopsis: Returns the internal geometry description of an attachable object.
// Topics: Attachments
// See Also: reorient(), attachable()
//
// Usage: Null/Point Geometry
// geom = attach_geom(...);
@ -2156,9 +2210,6 @@ function named_anchor(name, pos, orient=UP, spin=0) = [name, pos, orient, spin];
// Usage: VNF Geometry
// geom = attach_geom(vnf=, [extent=], ...);
//
// Topics: Attachments
// See Also: reorient(), attachable()
//
// Description:
// Given arguments that describe the geometry of an attachable object, returns the internal geometry description.
// This will probably not not ever need to be called by the end user.
@ -2365,10 +2416,11 @@ function attach_geom(
/// Internal Function: _attach_geom_2d()
// Usage:
// bool = _attach_geom_2d(geom);
/// Topics: Attachments
/// See Also: reorient(), attachable()
//
// Usage:
// bool = _attach_geom_2d(geom);
// Description:
// Returns true if the given attachment geometry description is for a 2D shape.
function _attach_geom_2d(geom) =
@ -2877,6 +2929,10 @@ function _standard_anchors(two_d=false) = [
// Module: show_anchors()
// Synopsis: Shows anchors for the parent object.
// Topics: Attachments
// See Also: expose_anchors(), anchor_arrow(), anchor_arrow2d(), frame_ref()
//
// Usage:
// PARENT() show_anchors([s], [std=], [custom=]);
// Description:
@ -2937,6 +2993,10 @@ module show_anchors(s=10, std=true, custom=true) {
// Module: anchor_arrow()
// Synopsis: Shows a 3d anchor orientation arrow.
// Topics: Attachments
// See Also: anchor_arrow2d(), show_anchors(), expose_anchors(), frame_ref()
//
// Usage:
// anchor_arrow([s], [color], [flag], [anchor=], [orient=], [spin=]) [ATTACHMENTS];
// Description:
@ -2972,6 +3032,10 @@ module anchor_arrow(s=10, color=[0.333,0.333,1], flag=true, $tag="anchor-arrow",
// Module: anchor_arrow2d()
// Synopsis: Shows a 2d anchor orientation arrow.
// Topics: Attachments
// See Also: anchor_arrow(), show_anchors(), expose_anchors(), frame_ref()
//
// Usage:
// anchor_arrow2d([s], [color], [flag]);
// Description:
@ -2988,6 +3052,9 @@ module anchor_arrow2d(s=15, color=[0.333,0.333,1], $tag="anchor-arrow") {
// Module: expose_anchors()
// Synopsis: Used to show a transparent object with solid color anchor arrows.
// Topics: Attachments
// See Also: anchor_arrow2d(), show_anchors(), show_anchors(), frame_ref()
// Usage:
// expose_anchors(opacity) {child1() show_anchors(); child2() show_anchors(); ...}
// Description:
@ -3011,6 +3078,9 @@ module expose_anchors(opacity=0.2) {
// Module: frame_ref()
// Synopsis: Shows axis orientation arrows.
// Topics: Attachments
// See Also: anchor_arrow(), anchor_arrow2d(), show_anchors(), expose_anchors()
// Usage:
// frame_ref(s, opacity);
// Description:

View file

@ -16,10 +16,12 @@ use <builtins.scad>
// Section: Coloring Objects
// Module: recolor()
// Synopsis: Sets the color for attachable children and all their descendants.
// Topics: Attachments
// See Also: color_this(), hsl(), hsv()
//
// Usage:
// recolor([c]) CHILDREN;
// Topics: Attachments
// See Also: color_this()
// Description:
// Sets the color for attachable children and all their descendants. This only works with attachables and you cannot
// have any color() modules above it in any parents, only other recolor() or color_this() modules.
@ -43,10 +45,12 @@ module recolor(c="default")
// Module: color_this()
// Synopsis: Sets the color for children at the current level only.
// Topics: Attachments
// See Also: recolor(), hsl(), hsv()
//
// Usage:
// color_this([c]) CHILDREN;
// Topics: Attachments
// See Also: recolor()
// Description:
// Sets the color for children at one level, reverting to the previous color for further descendants.
// This works only with attachables and you cannot have any color() modules above it in any parents,
@ -72,6 +76,10 @@ module color_this(c="default")
// Module: rainbow()
// Synopsis: Iterates through a list, displaying children in different colors.
// Topics: List Handling
// See Also: hsl(), hsv()
//
// Usage:
// rainbow(list,[stride],[maxhues],[shuffle],[seed]) CHILDREN;
// Description:
@ -111,6 +119,9 @@ module rainbow(list, stride=1, maxhues, shuffle=false, seed)
// Section: Colorspace Conversion
// Function&Module: hsl()
// Synopsis: Sets the color of children to a specified hue, saturation, lightness and optional alpha channel value.
// See Also: hsv(), recolor(), color_this()
//
// Usage:
// hsl(h,[s],[l],[a]) CHILDREN;
// rgb = hsl(h,[s],[l],[a]);
@ -146,6 +157,9 @@ module hsl(h,s=1,l=0.5,a=1)
// Function&Module: hsv()
// Synopsis: Sets the color of children to a hue, saturation, value and optional alpha channel value.
// See Also: hsl(), recolor(), color_this()
//
// Usage:
// hsv(h,[s],[v],[a]) CHILDREN;
// rgb = hsv(h,[s],[v],[a]);

View file

@ -17,11 +17,13 @@
// Section: Line Drawing
// Module: stroke()
// Synopsis: Draws a line along a path or region boundry.
// Topics: Paths (2D), Paths (3D), Drawing Tools
// See Also: offset_stroke(), path_sweep()
//
// Usage:
// stroke(path, [width], [closed], [endcaps], [endcap_width], [endcap_length], [endcap_extent], [trim]);
// stroke(path, [width], [closed], [endcap1], [endcap2], [endcap_width1], [endcap_width2], [endcap_length1], [endcap_length2], [endcap_extent1], [endcap_extent2], [trim1], [trim2]);
// Topics: Paths (2D), Paths (3D), Drawing Tools
// See Also: offset_stroke(), path_sweep()
// Description:
// Draws a 2D or 3D path with a given line width. Joints and each endcap can be replaced with
// various marker shapes, and can be assigned different colors. If passed a region instead of
@ -545,12 +547,14 @@ module stroke(
// Function&Module: dashed_stroke()
// Synopsis: Draws a dashed line along a path or region boundry.
// Topics: Paths, Drawing Tools
// See Also: stroke(), path_cut()
//
// Usage: As a Module
// dashed_stroke(path, dashpat, [width=], [closed=]);
// Usage: As a Function
// dashes = dashed_stroke(path, dashpat, [closed=]);
// Topics: Paths, Drawing Tools
// See Also: stroke(), path_cut()
// Description:
// Given a path (or region) and a dash pattern, creates a dashed line that follows that
// path or region boundary with the given dash pattern.
@ -622,6 +626,9 @@ module dashed_stroke(path, dashpat=[3,3], width=1, closed=false, fit=true, round
// Section: Computing paths
// Function&Module: arc()
// Synopsis: Draws a 2d pie-slice or returns 2D or 3D path forming an arc.
// Topics: Shapes (2D), Path Generators (2D)
//
// Usage: 2D arc from 0º to `angle` degrees.
// path=arc(n, r|d=, angle);
// Usage: 2D arc from START to END degrees.
@ -657,7 +664,7 @@ module dashed_stroke(path, dashpat=[3,3], width=1, closed=false, fit=true, round
// width = If given with `thickness`, arc starts and ends on X axis, to make a circle segment.
// thickness = If given with `width`, arc starts and ends on X axis, to make a circle segment.
// start = Start angle of arc.
// wedge = If true, include centerpoint `cp` in output to form pie slice shape.
// wedge = If true, include centerpoint `cp` in output to form pie slice shape. Default: false
// endpoint = If false exclude the last point (function only). Default: true
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). (Module only) Default: `CENTER`
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). (Module only) Default: `0`
@ -814,6 +821,9 @@ module arc(n, r, angle, d, cp, points, corner, width, thickness, start, wedge=fa
// Function: helix()
// Synopsis: Creates a 2d spiral or 3d helical path.
// Topics: Path Generators, Paths, Drawing Tools
//
// Usage:
// path = helix(l|h, [turns=], [angle=], r=|r1=|r2=, d=|d1=|d2=);
// Description:
@ -866,12 +876,14 @@ function _normal_segment(p1,p2) =
// Function: turtle()
// Usage:
// turtle(commands, [state], [full_state=], [repeat=])
// Synopsis: Uses [turtle graphics](https://en.wikipedia.org/wiki/Turtle_graphics) to generate a 2D path.
// Topics: Shapes (2D), Path Generators (2D), Mini-Language
// See Also: turtle3d()
//
// Usage:
// turtle(commands, [state], [full_state=], [repeat=])
// Description:
// Use a sequence of turtle graphics commands to generate a path. The parameter `commands` is a list of
// Use a sequence of [turtle graphics]{https://en.wikipedia.org/wiki/Turtle_graphics} commands to generate a path. The parameter `commands` is a list of
// turtle commands and optional parameters for each command. The turtle state has a position, movement direction,
// movement distance, and default turn angle. If you do not give `state` as input then the turtle starts at the
// origin, pointed along the positive x axis with a movement distance of 1. By default, `turtle` returns just
@ -1128,6 +1140,9 @@ function _turtle_command(command, parm, parm2, state, index) =
// Section: Debugging polygons
// Module: debug_polygon()
// Synopsis: Draws an annotated polygon.
// Topics: Shapes (2D)
//
// Usage:
// debug_polygon(points, paths, [vertices=], [edges=], [convexity=], [size=]);
// Description:

View file

@ -15,12 +15,14 @@
// Section: 2D Masking Shapes
// Function&Module: mask2d_roundover()
// Synopsis: Creates a 2D beading mask shape useful for rounding 90° edges.
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable, Masks (2D)
// See Also: corner_profile(), edge_profile(), face_profile(), fillet()
//
// Usage: As module
// mask2d_roundover(r|d=, [inset], [excess]) [ATTACHMENTS];
// Usage: As function
// path = mask2d_roundover(r|d=, [inset], [excess]);
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable, Masks (2D)
// See Also: corner_profile(), edge_profile(), face_profile()
// Description:
// Creates a 2D roundover/bead mask shape that is useful for extruding into a 3D mask for a 90° edge.
// Conversely, you can use that same extruded shape to make an interior fillet between two walls at a 90º angle.
@ -78,12 +80,14 @@ function mask2d_roundover(r, inset=0, excess=0.01, d, anchor=CENTER,spin=0) =
// Function&Module: mask2d_cove()
// Synopsis: Creates a 2d cove (quarter-round) mask shape.
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable, Masks (2D)
// See Also: corner_profile(), edge_profile(), face_profile()
//
// Usage: As module
// mask2d_cove(r|d=, [inset], [excess]) [ATTACHMENTS];
// Usage: As function
// path = mask2d_cove(r|d=, [inset], [excess]);
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable, Masks (2D)
// See Also: corner_profile(), edge_profile(), face_profile()
// Description:
// Creates a 2D cove mask shape that is useful for extruding into a 3D mask for a 90° edge.
// Conversely, you can use that same extruded shape to make an interior rounded shelf decoration between two walls at a 90º angle.
@ -141,6 +145,10 @@ function mask2d_cove(r, inset=0, excess=0.01, d, anchor=CENTER,spin=0) =
// Function&Module: mask2d_chamfer()
// Synopsis: Produces a 2D chamfer mask shape.
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable, Masks (2D)
// See Also: corner_profile(), edge_profile(), face_profile()
//
// Usage: As Module
// mask2d_chamfer(edge, [angle], [inset], [excess]) [ATTACHMENTS];
// mask2d_chamfer(y=, [angle=], [inset=], [excess=]) [ATTACHMENTS];
@ -149,8 +157,6 @@ function mask2d_cove(r, inset=0, excess=0.01, d, anchor=CENTER,spin=0) =
// path = mask2d_chamfer(edge, [angle], [inset], [excess]);
// path = mask2d_chamfer(y=, [angle=], [inset=], [excess=]);
// path = mask2d_chamfer(x=, [angle=], [inset=], [excess=]);
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable, Masks (2D)
// See Also: corner_profile(), edge_profile(), face_profile()
// Description:
// Creates a 2D chamfer mask shape that is useful for extruding into a 3D mask for a 90° edge.
// Conversely, you can use that same extruded shape to make an interior chamfer between two walls at a 90º angle.
@ -219,12 +225,14 @@ function mask2d_chamfer(edge, angle=45, inset=0, excess=0.01, x, y, anchor=CENTE
// Function&Module: mask2d_rabbet()
// Synopsis: Creates a rabbet mask shape.
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable, Masks (2D)
// See Also: corner_profile(), edge_profile(), face_profile()
//
// Usage: As Module
// mask2d_rabbet(size, [excess]) [ATTACHMENTS];
// Usage: As Function
// path = mask2d_rabbet(size, [excess]);
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable, Masks (2D)
// See Also: corner_profile(), edge_profile(), face_profile()
// Description:
// Creates a 2D rabbet mask shape that is useful for extruding into a 3D mask for a 90° edge.
// Conversely, you can use that same extruded shape to make an interior shelf decoration between two walls at a 90º angle.
@ -276,14 +284,16 @@ function mask2d_rabbet(size, excess=0.01, anchor=CENTER,spin=0) =
// Function&Module: mask2d_dovetail()
// Creates a 2d dovetail mask shape.
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable, Masks (2D)
// See Also: corner_profile(), edge_profile(), face_profile()
//
// Usage: As Module
// mask2d_dovetail(edge, [angle], [inset], [shelf], [excess], ...) [ATTACHMENTS];
// mask2d_dovetail(x=, [angle=], [inset=], [shelf=], [excess=], ...) [ATTACHMENTS];
// mask2d_dovetail(y=, [angle=], [inset=], [shelf=], [excess=], ...) [ATTACHMENTS];
// Usage: As Function
// path = mask2d_dovetail(edge, [angle], [inset], [shelf], [excess]);
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable, Masks (2D)
// See Also: corner_profile(), edge_profile(), face_profile()
// Description:
// Creates a 2D dovetail mask shape that is useful for extruding into a 3D mask for a 90° edge.
// Conversely, you can use that same extruded shape to make an interior dovetail between two walls at a 90º angle.
@ -353,12 +363,14 @@ function mask2d_dovetail(edge, angle=30, inset=0, shelf=0, excess=0.01, x, y, an
// Function&Module: mask2d_teardrop()
// Synopsis: Creates a 2d teardrop mask shape with a controllable maximum angle from vertical.
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable, Masks (2D)
// See Also: corner_profile(), edge_profile(), face_profile()
//
// Usage: As Module
// mask2d_teardrop(r|d=, [angle], [excess]) [ATTACHMENTS];
// Usage: As Function
// path = mask2d_teardrop(r|d=, [angle], [excess]);
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable, Masks (2D)
// See Also: corner_profile(), edge_profile(), face_profile()
// Description:
// Creates a 2D teardrop mask shape that is useful for extruding into a 3D mask for a 90° edge.
// Conversely, you can use that same extruded shape to make an interior teardrop fillet between two walls at a 90º angle.
@ -416,12 +428,14 @@ module mask2d_teardrop(r, angle=45, excess=0.01, d, anchor=CENTER, spin=0) {
}
// Function&Module: mask2d_ogee()
// Synopsis: Creates a 2d ogee mask shape.
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable, Masks (2D)
// See Also: corner_profile(), edge_profile(), face_profile()
//
// Usage: As Module
// mask2d_ogee(pattern, [excess], ...) [ATTAHCMENTS];
// Usage: As Function
// path = mask2d_ogee(pattern, [excess], ...);
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable, Masks (2D)
// See Also: corner_profile(), edge_profile(), face_profile()
//
// Description:
// Creates a 2D Ogee mask shape that is useful for extruding into a 3D mask for a 90° edge.

View file

@ -21,14 +21,16 @@ use <builtins.scad>
// Section: 2D Primitives
// Function&Module: square()
// Synopsis: Creates a 2D square or rectangle.
// Topics: Shapes (2D), Path Generators (2D)
// See Also: rect()
//
// Usage: As a Module
// square(size, [center], ...);
// Usage: With Attachments
// square(size, [center], ...) [ATTACHMENTS];
// Usage: As a Function
// path = square(size, [center], ...);
// See Also: rect()
// Description:
// When called as the builtin module, creates a 2D square or rectangle of the given size.
// When called as a function, returns a 2D path/list of points for a square/rectangle of the given size.
@ -71,12 +73,13 @@ module square(size=1, center, anchor, spin) {
// Function&Module: rect()
// Synopsis: Creates a 2d rectangle with optional corner rounding.
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable
// See Also: square()
// Usage: As Module
// rect(size, [rounding], [chamfer], ...) [ATTACHMENTS];
// Usage: As Function
// path = rect(size, [rounding], [chamfer], ...);
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable
// See Also: square()
// Description:
// When called as a module, creates a 2D rectangle of the given size, with optional rounding or chamfering.
// When called as a function, returns a 2D path/list of points for a square/rectangle of the given size.
@ -208,7 +211,10 @@ function rect(size=1, rounding=0, chamfer=0, atype="box", anchor=CENTER, spin=0,
// Function&Module: circle()
// Synopsis: Creates the approximation of a circle.
// Topics: Shapes (2D), Path Generators (2D)
// See Also: ellipse(), circle_2tangents(), circle_3points()
//
// Usage: As a Module
// circle(r|d=, ...) [ATTACHMENTS];
// circle(points=) [ATTACHMENTS];
@ -217,7 +223,6 @@ function rect(size=1, rounding=0, chamfer=0, atype="box", anchor=CENTER, spin=0,
// path = circle(r|d=, ...);
// path = circle(points=);
// path = circle(r|d=, corner=);
// See Also: ellipse(), circle_2tangents(), circle_3points()
// Description:
// When called as the builtin module, creates a 2D polygon that approximates a circle of the given size.
// When called as a function, returns a 2D list of points (path) for a polygon that approximates a circle of the given size.
@ -311,12 +316,14 @@ module circle(r, d, points, corner, anchor=CENTER, spin=0) {
// Function&Module: ellipse()
// Synopsis: Creates the approximation of an ellipse or a circle.
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable
// See Also: circle(), circle_2tangents(), circle_3points()
// Usage: As a Module
// ellipse(r|d=, [realign=], [circum=], [uniform=], ...) [ATTACHMENTS];
// Usage: As a Function
// path = ellipse(r|d=, [realign=], [circum=], [uniform=], ...);
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable
// See Also: circle(), circle_2tangents(), circle_3points()
// Description:
// When called as a module, creates a 2D polygon that approximates a circle or ellipse of the given size.
// When called as a function, returns a 2D list of points (path) for a polygon that approximates a circle or ellipse of the given size.
@ -494,12 +501,14 @@ function ellipse(r, d, realign=false, circum=false, uniform=false, anchor=CENTER
// Section: Polygons
// Function&Module: regular_ngon()
// Synopsis: Creates a regular N-sided polygon.
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable
// See Also: debug_polygon(), circle(), pentagon(), hexagon(), octagon(), ellipse(), star()
// Usage:
// regular_ngon(n, r|d=|or=|od=, [realign=]) [ATTACHMENTS];
// regular_ngon(n, ir=|id=, [realign=]) [ATTACHMENTS];
// regular_ngon(n, side=, [realign=]) [ATTACHMENTS];
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable
// See Also: circle(), pentagon(), hexagon(), octagon(), ellipse(), star()
// Description:
// When called as a function, returns a 2D path for a regular N-sided polygon.
// When called as a module, creates a 2D regular N-sided polygon.
@ -633,14 +642,16 @@ module regular_ngon(n=6, r, d, or, od, ir, id, side, rounding=0, realign=false,
// Function&Module: pentagon()
// Synopsis: Creates a regular pentagon.
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable
// See Also: circle(), regular_ngon(), hexagon(), octagon(), ellipse(), star()
// Usage:
// pentagon(or|od=, [realign=], [align_tip=|align_side=]) [ATTACHMENTS];
// pentagon(ir=|id=, [realign=], [align_tip=|align_side=]) [ATTACHMENTS];
// pentagon(side=, [realign=], [align_tip=|align_side=]) [ATTACHMENTS];
// Usage: as function
// path = pentagon(...);
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable
// See Also: circle(), regular_ngon(), hexagon(), octagon(), ellipse(), star()
// Description:
// When called as a function, returns a 2D path for a regular pentagon.
// When called as a module, creates a 2D regular pentagon.
@ -691,6 +702,10 @@ module pentagon(r, d, or, od, ir, id, side, rounding=0, realign=false, align_tip
// Function&Module: hexagon()
// Synopsis: Creates a regular hexagon.
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable
// See Also: circle(), regular_ngon(), pentagon(), octagon(), ellipse(), star()
// Usage: As Module
// hexagon(r/or, [realign=], <align_tip=|align_side=>, [rounding=], ...) [ATTACHMENTS];
// hexagon(d=/od=, ...) [ATTACHMENTS];
@ -698,8 +713,6 @@ module pentagon(r, d, or, od, ir, id, side, rounding=0, realign=false, align_tip
// hexagon(side=, ...) [ATTACHMENTS];
// Usage: As Function
// path = hexagon(...);
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable
// See Also: circle(), regular_ngon(), pentagon(), octagon(), ellipse(), star()
// Description:
// When called as a function, returns a 2D path for a regular hexagon.
// When called as a module, creates a 2D regular hexagon.
@ -750,6 +763,10 @@ module hexagon(r, d, or, od, ir, id, side, rounding=0, realign=false, align_tip,
// Function&Module: octagon()
// Synopsis: Creates a regular octagon.
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable
// See Also: circle(), regular_ngon(), pentagon(), hexagon(), ellipse(), star()
// Usage: As Module
// octagon(r/or, [realign=], [align_tip=|align_side=], [rounding=], ...) [ATTACHMENTS];
// octagon(d=/od=, ...) [ATTACHMENTS];
@ -757,8 +774,6 @@ module hexagon(r, d, or, od, ir, id, side, rounding=0, realign=false, align_tip,
// octagon(side=, ...) [ATTACHMENTS];
// Usage: As Function
// path = octagon(...);
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable
// See Also: circle(), regular_ngon(), pentagon(), hexagon(), ellipse(), star()
// Description:
// When called as a function, returns a 2D path for a regular octagon.
// When called as a module, creates a 2D regular octagon.
@ -808,6 +823,10 @@ module octagon(r, d, or, od, ir, id, side, rounding=0, realign=false, align_tip,
// Function&Module: right_triangle()
// Synopsis: Creates a right triangle.
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable
// See Also: square(), rect(), regular_ngon(), pentagon(), hexagon(), octagon(), star()
// Usage: As Module
// right_triangle(size, [center], ...) [ATTACHMENTS];
// Usage: As Function
@ -851,6 +870,10 @@ module right_triangle(size=[1,1], center, anchor, spin=0) {
// Function&Module: trapezoid()
// Synopsis: Creates a trapezoid with parallel top and bottom sides.
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable
// See Also: rect(), square()
// Usage: As Module
// trapezoid(h, w1, w2, [shift=], [rounding=], [chamfer=], [flip=], ...) [ATTACHMENTS];
// trapezoid(h, w1, ang=, [rounding=], [chamfer=], [flip=], ...) [ATTACHMENTS];
@ -858,8 +881,6 @@ module right_triangle(size=[1,1], center, anchor, spin=0) {
// trapezoid(w1=, w2=, ang=, [rounding=], [chamfer=], [flip=], ...) [ATTACHMENTS];
// Usage: As Function
// path = trapezoid(...);
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable
// See Also: rect(), square()
// Description:
// When called as a function, returns a 2D path for a trapezoid with parallel front and back (top and bottom) sides.
// When called as a module, creates a 2D trapezoid. You can specify the trapezoid by giving its height and the lengths
@ -1059,14 +1080,16 @@ module trapezoid(h, w1, w2, ang, shift, chamfer=0, rounding=0, flip=false, ancho
// Function&Module: star()
// Synopsis: Creates a star-shaped polygon or returns a star-shaped region.
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable
// See Also: circle(), ellipse(), regular_ngon()
//
// Usage: As Module
// star(n, r/or, ir, [realign=], [align_tip=], [align_pit=], ...) [ATTACHMENTS];
// star(n, r/or, step=, ...) [ATTACHMENTS];
// Usage: As Function
// path = star(n, r/or, ir, [realign=], [align_tip=], [align_pit=], ...);
// path = star(n, r/or, step=, ...);
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable
// See Also: circle(), ellipse()
// Description:
// When called as a function, returns the path needed to create a star polygon with N points.
// When called as a module, creates a star polygon with N points.
@ -1226,8 +1249,10 @@ function _path_add_jitter(path, dist=1/512, closed=true) =
// Module: jittered_poly()
// Synopsis: Creates a polygon with extra points for smoother twisted extrusions.
// Topics: Extrusions
// See Also: subdivide_path()
//
// Usage:
// jittered_poly(path, [dist]);
// Description:
@ -1253,9 +1278,12 @@ module jittered_poly(path, dist=1/512) {
// Function&Module: teardrop2d()
// Synopsis: Creates a 2D teardrop shape.
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable
// See Also: teardrop(), onion()
//
// Description:
// Makes a 2D teardrop shape. Useful for extruding into 3D printable holes. Uses "intersect" style anchoring.
// Makes a 2D teardrop shape. Useful for extruding into 3D printable holes as it limits overhang to 45 degrees. Uses "intersect" style anchoring.
// The cap_h parameter truncates the top of the teardrop. If cap_h is taller than the untruncated form then
// the result will be the full, untruncated shape. The segments of the bottom section of the teardrop are
// calculated to be the same as a circle or cylinder when rotated 90 degrees. (Note that this agreement is poor when `$fn=6` or `$fn=7`.
@ -1268,10 +1296,6 @@ module jittered_poly(path, dist=1/512) {
// Usage: As Function
// path = teardrop2d(r|d=, [ang], [cap_h]);
//
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable
//
// See Also: teardrop(), onion()
//
// Arguments:
// r = radius of circular part of teardrop. (Default: 1)
// ang = angle of hat walls from the Y axis (half the angle of the peak). (Default: 45 degrees)
@ -1353,12 +1377,14 @@ function teardrop2d(r, ang=45, cap_h, d, circum=false, realign=false, anchor=CEN
// Function&Module: egg()
// Synopsis: Creates an egg-shaped 2d object.
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable
// See Also: circle(), ellipse(), glued_circles()
//
// Usage: As Module
// egg(length, r1|d1=, r2|d2=, R|D=) [ATTACHMENTS];
// Usage: As Function
// path = egg(length, r1|d1=, r2|d2=, R|D=);
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable
// See Also: circle(), ellipse(), glued_circles()
// Description:
// Constructs an egg-shaped object by connecting two circles with convex arcs that are tangent to the circles.
// You specify the length of the egg, the radii of the two circles, and the desired arc radius.
@ -1440,12 +1466,14 @@ module egg(length,r1,r2,R,d1,d2,D,anchor=CENTER, spin=0)
// Function&Module: glued_circles()
// Synopsis: Creates a shape of two circles joined by a curved waist.
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable
// See Also: circle(), ellipse(), egg()
//
// Usage: As Module
// glued_circles(r/d=, [spread], [tangent], ...) [ATTACHMENTS];
// Usage: As Function
// path = glued_circles(r/d=, [spread], [tangent], ...);
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable
// See Also: circle(), ellipse(), egg()
// Description:
// When called as a function, returns a 2D path forming a shape of two circles joined by curved waist.
// When called as a module, creates a 2D shape of two circles joined by curved waist. Uses "hull" style anchoring.
@ -1508,12 +1536,14 @@ function _superformula(theta,m1,m2,n1,n2=1,n3=1,a=1,b=1) =
pow(pow(abs(cos(m1*theta/4)/a),n2)+pow(abs(sin(m2*theta/4)/b),n3),-1/n1);
// Function&Module: supershape()
// Synopsis: Creates a 2D [Superformula](https://en.wikipedia.org/wiki/Superformula) shape.
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable
// See Also: circle(), ellipse()
//
// Usage: As Module
// supershape([step],[n=], [m1=], [m2=], [n1=], [n2=], [n3=], [a=], [b=], [r=/d=]) [ATTACHMENTS];
// Usage: As Function
// path = supershape([step], [n=], [m1=], [m2=], [n1=], [n2=], [n3=], [a=], [b=], [r=/d=]);
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable
// See Also: circle(), ellipse()
// Description:
// When called as a function, returns a 2D path for the outline of the [Superformula](https://en.wikipedia.org/wiki/Superformula) shape.
// When called as a module, creates a 2D [Superformula](https://en.wikipedia.org/wiki/Superformula) shape.
@ -1589,12 +1619,14 @@ module supershape(step=0.5,n,m1=4,m2=undef,n1,n2=undef,n3=undef,a=1,b=undef, r=u
// Function&Module: reuleaux_polygon()
// Synopsis: Creates a constant-width shape that is not circular.
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable
// See Also: regular_ngon(), pentagon(), hexagon(), octagon()
//
// Usage: As Module
// reuleaux_polygon(n, r|d=, ...) [ATTACHMENTS];
// Usage: As Function
// path = reuleaux_polygon(n, r|d=, ...);
// Topics: Shapes (2D), Paths (2D), Path Generators, Attachable
// See Also: regular_ngon(), pentagon(), hexagon(), octagon()
// Description:
// Creates a 2D Reuleaux Polygon; a constant width shape that is not circular. Uses "intersect" type anchoring.
// Arguments:
@ -1657,7 +1689,9 @@ function reuleaux_polygon(n=3, r, d, anchor=CENTER, spin=0) =
// Section: Text
// Module: text()
// Synopsis: Creates an attachable block of text.
// Topics: Attachments, Text
// See Also: text3d()
// Usage:
// text(text, [size], [font], ...);
// Description:
@ -1768,6 +1802,8 @@ module text(text, size=10, font="Helvetica", halign, valign, spacing=1.0, direct
// Section: Rounding 2D shapes
// Module: round2d()
// Synopsis: Rounds the corners of 2d objects.
// Usage:
// round2d(r) [ATTACHMENTS];
// round2d(or=) [ATTACHMENTS];
@ -1797,6 +1833,8 @@ module round2d(r, or, ir)
// Module: shell2d()
// Synopsis: Creates a shell from 2D children.
//
// Usage:
// shell2d(thickness, [or], [ir])
// Description:

View file

@ -18,14 +18,16 @@ use <builtins.scad>
// Section: Cuboids, Prismoids and Pyramids
// Function&Module: cube()
// Synopsis: Creates a cube with anchors for attaching children, or returns a vnf.
// Topics: Shapes (3D), Attachable, VNF Generators
// See Also: cuboid(), prismoid()
//
// Usage: As Module (as in native OpenSCAD)
// cube(size, [center]);
// Usage: With BOSL2 Attachment extensions
// cube(size, [center], [anchor=], [spin=], [orient=]) [ATTACHMENTS];
// Usage: As Function (BOSL2 extension)
// vnf = cube(size, ...);
// See Also: cuboid(), prismoid()
// Description:
// Creates a 3D cubic object.
// This module extends the built-in cube()` module by providing support for attachments and a function form.
@ -87,6 +89,9 @@ function cube(size=1, center, anchor, spin=0, orient=UP) =
// Module: cuboid()
// Synopsis: Creates a cube with chamfering and roundovers, or returns a vnf.
// Topics: Shapes (3D), Attachable, VNF Generators
// See Also: prismoid(), rounded_prism()
//
// Usage: Standard Cubes
// cuboid(size, [anchor=], [spin=], [orient=]);
@ -120,7 +125,6 @@ function cube(size=1, center, anchor, spin=0, orient=UP) =
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
// spin = Rotate this many degrees around the Z axis. See [spin](attachments.scad#subsection-spin). Default: `0`
// orient = Vector to rotate top towards. See [orient](attachments.scad#subsection-orient). Default: `UP`
// See Also: prismoid(), rounded_prism()
// Example: Simple regular cube.
// cuboid(40);
// Example: Cube with minimum cornerpoint given.
@ -564,6 +568,9 @@ function cuboid(
// Function&Module: prismoid()
// Synopsis: Creates a rectangular prismoid shape with optional roundovers and chamfering, or returns a vnf.
// Topics: Shapes (3D), Attachable, VNF Generators
// See Also: cuboid(), rounded_prism(), trapezoid()
//
// Usage:
// prismoid(size1, size2, [h|l|height|length], [shift], [xang=], [yang=], ...) [ATTACHMENTS];
@ -601,8 +608,6 @@ function cuboid(
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP`
//
// See Also: cuboid(), rounded_prism(), trapezoid()
//
// Example: Truncated Pyramid
// prismoid(size1=[35,50], size2=[20,30], h=20);
// Example: Rectangular Pyramid
@ -768,6 +773,11 @@ function prismoid(
// Function&Module: octahedron()
// Synopsis: Creates an octahedron with axis-aligned points, or returns a vnf.
// Topics: Shapes (3D), Attachable, VNF Generators
// See Also: prismoid()
// Usage: As Module
// octahedron(size, ...) [ATTACHMENTS];
// Usage: As Function
@ -806,6 +816,10 @@ function octahedron(size=1, anchor=CENTER, spin=0, orient=UP) =
// Module: rect_tube()
// Synopsis: Creates a rectangular tube, or returns a vnf.
// Topics: Shapes (3D), Attachable, VNF Generators
// See Also: tube()
//
// Usage: Typical Rectangular Tubes
// rect_tube(h, size, isize, [center], [shift]);
// rect_tube(h, size, wall=, [center=]);
@ -1076,6 +1090,9 @@ function rect_tube(
// Function&Module: wedge()
// Synopsis: Creates a 3d triangular wedge, or returns a vnf.
// Topics: Shapes (3D), Attachable, VNF Generators
// See also: prismoid(), rounded_prism(), pie_slice()
//
// Usage: As Module
// wedge(size, [center], ...) [ATTACHMENTS];
@ -1136,7 +1153,10 @@ function wedge(size=[1,1,1], center, anchor, spin=0, orient=UP) =
// Function&Module: cylinder()
// Synopsis: Creates an attachable cylinder, or returns a vnf.
// Topics: Shapes (3D), Attachable, VNF Generators
// See Also: cyl()
//
// Usage: As Module (as in native OpenSCAD)
// cylinder(h, r=/d=, [center=]);
// cylinder(h, r1/d1=, r2/d2=, [center=]);
@ -1146,7 +1166,6 @@ function wedge(size=[1,1,1], center, anchor, spin=0, orient=UP) =
// Usage: As Function (BOSL2 extension)
// vnf = cylinder(h, r=/d=, ...);
// vnf = cylinder(h, r1/d1=, r2/d2=, ...);
// See Also: cyl()
// Description:
// Creates a 3D cylinder or conic object.
// This modules extends the built-in `cylinder()` module by adding support for attachment and by adding a function version.
@ -1220,7 +1239,10 @@ function cylinder(h, r1, r2, center, r, d, d1, d2, anchor, spin=0, orient=UP) =
// Function&Module: cyl()
//
// Synopsis: Creates an attachable cylinder with roundovers and chamfering, or returns a vnf.
// Topics: Cylinders, Textures, Rounding, Chamfers
// See Also: texture(), rotate_sweep(), cylinder()
//
// Usage: Normal Cylinders
// cyl(l|h|length|height, r, [center], [circum=], [realign=]) [ATTACHMENTS];
// cyl(l|h|length|height, d=, ...) [ATTACHMENTS];
@ -1244,7 +1266,6 @@ function cylinder(h, r1, r2, center, r, d, d1, d2, anchor, spin=0, orient=UP) =
// cyl(l|h|length|height, r1=, r2=, texture=, [tex_size=]|[tex_counts=], [tex_scale=], [tex_rot=], [tex_samples=], [tex_style=], [tex_taper=], [tex_inset=], ...);
// cyl(l|h|length|height, d1=, d2=, texture=, [tex_size=]|[tex_counts=], [tex_scale=], [tex_rot=], [tex_samples=], [tex_style=], [tex_taper=], [tex_inset=], ...);
//
// Topics: Cylinders, Textures, Rounding, Chamfers
//
// Description:
// Creates cylinders in various anchorings and orientations, with optional rounding, chamfers, or textures.
@ -1320,7 +1341,6 @@ function cylinder(h, r1, r2, center, r, d, d1, d2, anchor, spin=0, orient=UP) =
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
// orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP`
//
// See Also: texture(), rotate_sweep()
//
// Example: By Radius
// xdistribute(30) {
@ -1616,9 +1636,12 @@ module cyl(
// Module: xcyl()
// Synopsis: creates a cylinder oriented along the X axis, or returns a vnf.
// Topics: Cylinders, Textures, Rounding, Chamfers
// See Also: texture(), rotate_sweep(), cyl()
//
// Description:
// Creates a cylinder oriented along the X axis.
// Creates an attachable cylinder with roundovers and chamfering oriented along the X axis.
//
// Usage: Typical
// xcyl(l|h|length|height, r|d=, [anchor=], ...) [ATTACHMENTS];
@ -1696,9 +1719,13 @@ module xcyl(
// Module: ycyl()
// Synopsis: creates a cylinder oriented along the y axis, or returns a vnf.
// Topics: Cylinders, Textures, Rounding, Chamfers
// See Also: texture(), rotate_sweep(), cyl()
//
// Description:
// Creates a cylinder oriented along the Y axis.
// Creates an attachable cylinder with roundovers and chamfering oriented along the y axis.
//
// Usage: Typical
// ycyl(l|h|length|height, r|d=, [anchor=], ...) [ATTACHMENTS];
@ -1778,9 +1805,13 @@ module ycyl(
// Module: zcyl()
// Synopsis: creates a cylinder oriented along the Z axis, or returns a vnf.
// Topics: Cylinders, Textures, Rounding, Chamfers
// See Also: texture(), rotate_sweep(), cyl()
//
// Description:
// Creates a cylinder oriented along the Z axis.
// Creates an attachable cylinder with roundovers and chamfering oriented along the Z axis.
//
// Usage: Typical
// zcyl(l|h|length|height, r|d=, [anchor=],...) [ATTACHMENTS];
@ -1859,6 +1890,10 @@ module zcyl(
// Module: tube()
// Synopsis: Creates a cylindrical or conical tube, or returns a vnf.
// Topics: Shapes (3D), Attachable, VNF Generators
// See Also: rect_tube()
//
// Description:
// Makes a hollow tube that can be cylindrical or conical by specifying inner and outer dimensions or by giving one dimension and
@ -1954,6 +1989,9 @@ module tube(
// Function&Module: pie_slice()
// Synopsis: Creates a pie slice shape, or returns a vnf.
// Topics: Shapes (3D), Attachable, VNF Generators
// See Also: wedge()
//
// Description:
// Creates a pie slice shape.
@ -2050,14 +2088,16 @@ function pie_slice(
// Function&Module: sphere()
// Synopsis: Creates an attachable spherical object, or returns a vnf.
// Topics: Shapes (3D), Attachable, VNF Generators
// See Also: spheroid()
// Usage: As Module (native OpenSCAD)
// sphere(r|d=);
// Usage: Using BOSL2 attachments extensions
// sphere(r|d=, [anchor=], [spin=], [orient=]) [ATTACHMENTS];
// Usage: As Function (BOSL2 extension)
// vnf = sphere(r|d=, [anchor=], [spin=], [orient=]) [ATTACHMENTS];
// See Also: spheroid()
// Description:
// Creates a sphere object.
// This module extends the built-in `sphere()` module by providing support for BOSL2 anchoring and attachments, and a function form.
@ -2095,6 +2135,10 @@ function sphere(r, d, anchor=CENTER, spin=0, orient=UP) =
// Function&Module: spheroid()
// Synopsis: Creates an attachable spherical object with controllable triangulation, or returns a vnf.
// Topics: Shapes (3D), Attachable, VNF Generators
// See Also: sphere()
//
// Usage: Typical
// spheroid(r|d, [circum], [style]) [ATTACHMENTS];
// Usage: As Function
@ -2422,6 +2466,8 @@ function spheroid(r, style="aligned", d, circum=false, anchor=CENTER, spin=0, or
// Function&Module: torus()
// Synopsis: Creates an attachable torus, or returns a vnf.
// Topics: Shapes (3D), Attachable, VNF Generators
//
// Usage: As Module
// torus(r_maj|d_maj, r_min|d_min, [center], ...) [ATTACHMENTS];
@ -2439,7 +2485,7 @@ function spheroid(r, style="aligned", d, circum=false, anchor=CENTER, spin=0, or
// vnf = torus(r_min|d_min, ir|id, ...);
//
// Description:
// Creates a torus shape.
// Creates an attachable toroidal shape.
//
// Figure(2D,Med):
// module dashcirc(r,start=0,angle=359.9,dashlen=5) let(step=360*dashlen/(2*r*PI)) for(a=[start:step:start+angle]) stroke(arc(r=r,start=a,angle=step/2));
@ -2562,6 +2608,9 @@ function torus(
// Function&Module: teardrop()
// Synopsis: Creates a teardrop shape, or returns a vnf.
// Topics: Shapes (3D), Attachable, VNF Generators
// See Also: onion(), teardrop2d()
//
// Description:
// Makes a teardrop shape in the XZ plane. Useful for 3D printable holes.
@ -2701,6 +2750,9 @@ function teardrop(h, r, ang=45, cap_h, r1, r2, d, d1, d2, cap_h1, cap_h2, chamf
// Function&Module: onion()
// Synopsis: Creates an attachable onion-like shape, or returns a vnf.
// Topics: Shapes (3D), Attachable, VNF Generators
// See Also: teardrop(), teardrop2d()
//
// Description:
// Creates a sphere with a conical hat, to make a 3D teardrop.
@ -2788,7 +2840,10 @@ function onion(r, ang=45, cap_h, d, anchor=CENTER, spin=0, orient=UP) =
// Section: Text
// Module: text3d()
// Synopsis: Creates an attachable 3d text block, or returns a vnf.
// Topics: Attachments, Text
// See Also: path_text(), text()
//
// Usage:
// text3d(text, [h], [size], [font], [language=], [script=], [direction=], [atype=], [anchor=], [spin=], [orient=]);
// Description:
@ -2828,7 +2883,6 @@ function onion(r, ang=45, cap_h, d, anchor=CENTER, spin=0, orient=UP) =
// center = Center the text. Equivalent to `atype="center", anchor=CENTER`. Default: false
// spin = Rotate this many degrees around the Z axis. See [spin](attachments.scad#subsection-spin). Default: `0`
// orient = Vector to rotate top towards. See [orient](attachments.scad#subsection-orient). Default: `UP`
// See Also: path_text()
// Anchor Types:
// baseline = Anchor center is relative to text baseline
// ycenter = Anchor center is relative to the actualy y direction center of the text
@ -2894,6 +2948,10 @@ function _cut_interp(pathcut, path, data) =
// Module: path_text()
// Synopsis: Creates 2d or 3d text placed along a path, or returns a vnf.
// Topics: Text, Paths, Paths (2D), Paths (3D), Path Generators, Path Generators (2D)
// See Also, text(), text2d()
// Usage:
// path_text(path, text, [size], [thickness], [font], [lettersize=], [offset=], [reverse=], [normal=], [top=], [textmetrics=], [kern=])
// Description:
@ -3134,7 +3192,11 @@ module path_text(path, text, font, size, thickness, lettersize, offset=0, revers
// Topics: Shapes (3D), Attachable
// Module: fillet()
// Synopsis: Creates a smooth fillet between two faces, or returns a vnf.
// See Also: mask2d_roundover()
//
//
// Description:
// Creates a shape that can be unioned into a concave joint between two faces, to fillet them.
@ -3213,11 +3275,14 @@ module fillet(l=1.0, r, ang=90, overlap=0.01, d, length, h, height, anchor=CENTE
// Function&Module: heightfield()
// Synopsis: Generates a 3D surface from a 2D grid of values, or returns a vnf.
// Topics: Textures, Heightfield
// See Also: cylindrical_heightfield()
//
// Usage: As Module
// heightfield(data, [size], [bottom], [maxz], [xrange], [yrange], [style], [convexity], ...) [ATTACHMENTS];
// Usage: As Function
// vnf = heightfield(data, [size], [bottom], [maxz], [xrange], [yrange], [style], ...);
// Topics: Textures, Heightfield
// Description:
// Given a regular rectangular 2D grid of scalar values, or a function literal, generates a 3D
// surface where the height at any given point is the scalar value for that position.
@ -3236,7 +3301,6 @@ module fillet(l=1.0, r, ang=90, overlap=0.01, d, length, h, height, anchor=CENTE
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
// spin = Rotate this many degrees around the Z axis. See [spin](attachments.scad#subsection-spin). Default: `0`
// orient = Vector to rotate top towards. See [orient](attachments.scad#subsection-orient). Default: `UP`
// See Also: heightfield(), cylindrical_heightfield()
// Example:
// heightfield(size=[100,100], bottom=-20, data=[
// for (y=[-180:4:180]) [
@ -3342,11 +3406,14 @@ function heightfield(data, size=[100,100], bottom=-20, maxz=100, xrange=[-1:0.04
// Function&Module: cylindrical_heightfield()
// Synopsis: Generates a cylindrical 3d surface from a 2D grid of values, or returns a vnf.
// Topics: Extrusion, Textures, Knurling, Heightfield
// See Also: heightfield()
//
// Usage: As Function
// vnf = cylindrical_heightfield(data, l|length=|h=|height=, r|d=, [base=], [transpose=], [aspect=]);
// Usage: As Module
// cylindrical_heightfield(data, l|length=|h=|height=, r|d=, [base=], [transpose=], [aspect=]) [ATTACHMENTS];
// Topics: Extrusion, Textures, Knurling, Heightfield
// Description:
// Given a regular rectangular 2D grid of scalar values, or a function literal of signature (x,y), generates
// a cylindrical 3D surface where the height at any given point above the radius `r=`, is the scalar value
@ -3374,7 +3441,6 @@ function heightfield(data, size=[100,100], bottom=-20, maxz=100, xrange=[-1:0.04
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
// spin = Rotate this many degrees around the Z axis. See [spin](attachments.scad#subsection-spin). Default: `0`
// orient = Vector to rotate top towards. See [orient](attachments.scad#subsection-orient). Default: `UP`
// See Also: heightfield(), cylindrical_heightfield()
// Example(VPD=400;VPR=[55,0,150]):
// cylindrical_heightfield(l=100, r=30, base=5, data=[
// for (y=[-180:4:180]) [
@ -3488,10 +3554,12 @@ module cylindrical_heightfield(
// Module: ruler()
// Synopsis: Creates a ruler.
//
// Usage:
// ruler(length, width, [thickness=], [depth=], [labels=], [pipscale=], [maxscale=], [colors=], [alpha=], [unit=], [inch=]) [ATTACHMENTS];
// Description:
// Creates a ruler for checking dimensions of the model
// Creates an attachable ruler for checking dimensions of the model.
// Arguments:
// length = length of the ruler. Default 100
// width = width of the ruler. Default: size of the largest unit division

View file

@ -20,6 +20,10 @@ function _rotpart(T) = [for(i=[0:3]) [for(j=[0:3]) j<3 || i==3 ? T[i][j] : 0]];
// Function: turtle3d()
// Synopsis: Extends [turtle graphics](https://en.wikipedia.org/wiki/Turtle_graphics) to 3d. Generates a 3D path or returns a list of transforms.
// Topics: Shapes (3D), Path Generators (3D), Mini-Language
// See Also: turtle()
//
// Usage:
// turtle3d(commands, [state], [transforms], [full_state], [repeat])
// Description: