mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2024-12-29 08:19:43 +00:00
Merge pull request #740 from revarbat/revarbat_dev
Merge changes for docsgen v2
This commit is contained in:
commit
139ee0bfaa
56 changed files with 282 additions and 280 deletions
7
.github/workflows/main.yml
vendored
7
.github/workflows/main.yml
vendored
|
@ -62,3 +62,10 @@ jobs:
|
|||
export OPENSCADPATH=$(dirname $GITHUB_WORKSPACE)
|
||||
openscad-docsgen -Tmf *.scad
|
||||
|
||||
- name: Checking Tutorials
|
||||
run: |
|
||||
cd $GITHUB_WORKSPACE
|
||||
echo "::add-matcher::.github/openscad_docsgen.json"
|
||||
export OPENSCADPATH=$(dirname $GITHUB_WORKSPACE)
|
||||
openscad-mdimggen -T *.scad
|
||||
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
DocsDirectory: BOSL2.wiki/
|
||||
TargetProfile: githubwiki
|
||||
ProjectName: The Belfry OpenScad Library, v2. (BOSL2)
|
||||
GenerateDocs: Files, TOC, Index, Topics, CheatSheet
|
||||
IgnoreFiles:
|
||||
affine.scad
|
||||
foo.scad
|
||||
|
@ -7,43 +10,45 @@ IgnoreFiles:
|
|||
builtins.scad
|
||||
tmp_*.scad
|
||||
PrioritizeFiles:
|
||||
constants.scad
|
||||
transforms.scad
|
||||
distributors.scad
|
||||
mutators.scad
|
||||
attachments.scad
|
||||
primitives.scad
|
||||
shapes.scad
|
||||
shapes2d.scad
|
||||
shapes3d.scad
|
||||
drawing.scad
|
||||
masks.scad
|
||||
math.scad
|
||||
vectors.scad
|
||||
arrays.scad
|
||||
quaternions.scad
|
||||
affine.scad
|
||||
coords.scad
|
||||
geometry.scad
|
||||
edges.scad
|
||||
vnf.scad
|
||||
masks2d.scad
|
||||
masks3d.scad
|
||||
distributors.scad
|
||||
partitions.scad
|
||||
mutators.scad
|
||||
paths.scad
|
||||
regions.scad
|
||||
debug.scad
|
||||
common.scad
|
||||
strings.scad
|
||||
vnf.scad
|
||||
beziers.scad
|
||||
threading.scad
|
||||
rounding.scad
|
||||
knurling.scad
|
||||
partitions.scad
|
||||
rounding.scad
|
||||
skin.scad
|
||||
hull.scad
|
||||
triangulation.scad
|
||||
turtle3d.scad
|
||||
math.scad
|
||||
linalg.scad
|
||||
vectors.scad
|
||||
quaternions.scad
|
||||
coords.scad
|
||||
geometry.scad
|
||||
trigonometry.scad
|
||||
constants.scad
|
||||
version.scad
|
||||
comparisons.scad
|
||||
lists.scad
|
||||
utility.scad
|
||||
strings.scad
|
||||
structs.scad
|
||||
fnliterals.scad
|
||||
threading.scad
|
||||
screws.scad
|
||||
metric_screws.scad
|
||||
bottlecaps.scad
|
||||
screw_drive.scad
|
||||
DefineHeader(BulletList): Side Effects
|
||||
DefineHeader(Table:Anchor Name|Position): Extra Anchors
|
||||
DefineHeader(Table:Name|Definition): Terminology
|
||||
DefineHeader(Table;Headers=Anchor Name|Position): Extra Anchors
|
||||
DefineHeader(Table;Headers=Name|Definition): Terminology
|
||||
DefineHeader(BulletList): Requirements
|
||||
|
5
.openscad_mdimggen_rc
Normal file
5
.openscad_mdimggen_rc
Normal file
|
@ -0,0 +1,5 @@
|
|||
docs_dir: "BOSL2.wiki"
|
||||
image_root: "images/tutorials"
|
||||
file_prefix: "Tutorial-"
|
||||
source_files: "tutorials/*.md"
|
||||
|
|
@ -7,6 +7,9 @@
|
|||
// are both written to support attachment. Also included in this file are the tools to make your own "attachable" objects.
|
||||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// FileGroup: Basic Modeling
|
||||
// FileSummary: Positioning objects on or relative to other objects. Making your own objects support attachment.
|
||||
// FileFootnotes: STD=Included in std.scad
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
@ -47,7 +50,7 @@ _ANCHOR_TYPES = ["intersect","hull"];
|
|||
// all based on combinations of unit direction vectors. You can use these for anchoring and orienting
|
||||
// attachable objects. You can also them to specify edge sets for rounding or chamfering cuboids,
|
||||
// or for placing edge, face and corner masks.
|
||||
// SubSection: Anchor
|
||||
// Subsection: Anchor
|
||||
// Anchoring is specified with the `anchor` argument in most shape modules. Specifying `anchor`
|
||||
// when creating an object will translate the object so that the anchor point is at the origin
|
||||
// (0,0,0). Anchoring always occurs before spin and orientation are applied.
|
||||
|
@ -76,20 +79,20 @@ _ANCHOR_TYPES = ["intersect","hull"];
|
|||
// motors have anchors for `"screw1"`, `"screw2"`, etc. to refer to the various screwholes on the
|
||||
// stepper motor shape. The names, positions, directions, and spins of these anchors are
|
||||
// specific to the object, and are documented when they exist.
|
||||
// SubSection: Spin
|
||||
// Subsection: Spin
|
||||
// Spin is specified with the `spin` argument in most shape modules. Specifying a scalar `spin`
|
||||
// when creating an object will rotate the object counter-clockwise around the Z axis by the given
|
||||
// number of degrees. If given as a 3D vector, the object will be rotated around each of the X, Y, Z
|
||||
// axes by the number of degrees in each component of the vector. Spin is always applied after
|
||||
// anchoring, and before orientation. Since spin is applied after anchoring it is not what
|
||||
// you might think of intuitively as spinning the shape. To do that, apply `zrot()` to the shape before anchoring.
|
||||
// SubSection: Orient
|
||||
// Subsection: Orient
|
||||
// Orientation is specified with the `orient` argument in most shape modules. Specifying `orient`
|
||||
// when creating an object will rotate the object such that the top of the object will be pointed
|
||||
// at the vector direction given in the `orient` argument. Orientation is always applied after
|
||||
// anchoring and spin. The constants `UP`, `DOWN`, `FRONT`, `BACK`, `LEFT`, and `RIGHT` can be
|
||||
// added together to form the directional vector for this. ie: `LEFT+BACK`
|
||||
// SubSection: Specifying Directions
|
||||
// Subsection: Specifying Directions
|
||||
// You can use direction vectors to specify anchors for objects or to specify edges, faces, and
|
||||
// corners of cubes. You can simply specify these direction vectors numerically, but another
|
||||
// option is to use named constants for direction vectors. These constants define unit vectors
|
||||
|
@ -122,7 +125,7 @@ _ANCHOR_TYPES = ["intersect","hull"];
|
|||
// up(.12)move(TOP)atext("TOP",size=.1,h=.01,anchor=RIGHT,orient=FRONT);
|
||||
// move(TOP)atext("UP",size=.1,h=.01,anchor=RIGHT,orient=FRONT);
|
||||
// }
|
||||
// SubSection: Specifying Faces
|
||||
// Subsection: Specifying Faces
|
||||
// Modules operating on faces accept a list of faces to describe the faces to operate on. Each
|
||||
// face is given by a vector that points to that face. Attachments of cuboid objects onto their faces also
|
||||
// work by choosing an attachment face with a single vector in the same manner.
|
||||
|
@ -139,7 +142,7 @@ _ANCHOR_TYPES = ["intersect","hull"];
|
|||
// _show_cube_faces([LEFT],toplabel=["LEFT"]);
|
||||
// }
|
||||
// }
|
||||
// SubSection: Specifying Edges
|
||||
// Subsection: Specifying Edges
|
||||
// Modules operating on edges use two arguments to describe the edge set they will use: The `edges` argument
|
||||
// is a list of edge set descriptors to include in the edge set, and the `except` argument is a list of
|
||||
// edge set descriptors to remove from the edge set.
|
||||
|
@ -250,7 +253,7 @@ _ANCHOR_TYPES = ["intersect","hull"];
|
|||
// _show_edges(_edges([1,-1,1]),toplabel=["edges=[1,-1,1]"]);
|
||||
// _show_edges(_edges([TOP,BOT], TOP+RIGHT+FRONT),toplabel=["edges=[TOP,BOT]","except=TOP+RIGHT+FRONT"]);
|
||||
// }
|
||||
// SubSection: Specifying Corners
|
||||
// Subsection: Specifying Corners
|
||||
// Modules operating on corners use two arguments to describe the corner set they will use: The `corners` argument
|
||||
// is a list of corner set descriptors to include in the corner set, and the `except` argument is a list of
|
||||
// corner set descriptors to remove from the corner set.
|
||||
|
@ -502,8 +505,6 @@ module attach(from, to, overlap, norot=false)
|
|||
// Description:
|
||||
// Marks all children with the given tags, so that they will `hide()`/`show()`/`diff()` correctly.
|
||||
// This is especially useful for working with children that are not attachment enhanced, such as:
|
||||
// - `square()` (or use [`rect()`](shapes2d.scad#rect))
|
||||
// - `circle()` (or use [`oval()`](shapes2d.scad#oval))
|
||||
// - `polygon()`
|
||||
// - `text()`
|
||||
// - `projection()`
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// include <BOSL2/beziers.scad>
|
||||
// FileGroup: Advanced Modeling
|
||||
// FileSummary: Support for bezier curves and surfaces.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Terminology:
|
||||
|
@ -987,8 +989,8 @@ module trace_bezier(bez, width=1, N=3) {
|
|||
color("red") move_copies(bez)
|
||||
if ($idx % N !=0)
|
||||
if (twodim){
|
||||
rect([width/2, width*3],center=true);
|
||||
rect([width*3, width/2],center=true);
|
||||
rect([width/2, width*3]);
|
||||
rect([width*3, width/2]);
|
||||
} else {
|
||||
zcyl(d=width/2, h=width*3);
|
||||
xcyl(d=width/2, h=width*3);
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// include <BOSL2/bottlecaps.scad>
|
||||
// FileGroup: Threaded Parts
|
||||
// FileSummary: Standard bottle caps and necks.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
// Functions for comparisons with lists, ordering and sorting
|
||||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// FileGroup: Data Management
|
||||
// FileSummary: Comparisons and sorting.
|
||||
// FileFootnotes: STD=Included in std.scad
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
// Coordinate transformations and coordinate system conversions.
|
||||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// FileGroup: Math
|
||||
// FileSummary: Conversions between coordinate systems.
|
||||
// FileFootnotes: STD=Included in std.scad
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// include <BOSL2/cubetruss.scad>
|
||||
// FileGroup: Parts
|
||||
// FileSummary: Modular open-framed trusses and joiners.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$cubetruss_size = 30;
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
// Functions and modules to distribute children or copies of children.
|
||||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// FileGroup: Basic Modeling
|
||||
// FileSummary: Shortcuts for translation, rotation, etc. Can act on geometry, paths, or can return a matrix.
|
||||
// FileFootnotes: STD=Included in std.scad
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
// and helix() produces helix paths.
|
||||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// FileGroup: Basic Modeling
|
||||
// FileSummary: Attachable cubes, cylinders, spheres, ruler, and text. Many can produce a VNF.
|
||||
// FileFootnotes: STD=Included in std.scad
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
|
|
@ -4,7 +4,9 @@
|
|||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// include <BOSL2/fnliterals.scad>
|
||||
// DefineHeader(Table:Positional|Definition||Named|Definition): FunctionLiteral Args
|
||||
// FileGroup: Data Management
|
||||
// FileSummary: Function Literal Algorithms, and factories for generating function literals for builtin functions.
|
||||
// DefineHeader(Table;Headers=Positional|Definition||Named|Definition): FunctionLiteral Args
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// include <BOSL2/gears.scad>
|
||||
// FileGroup: Parts
|
||||
// FileSummary: Gears, racks, worms, and worm gears.
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
// a single endpoint or as segments, bounded by endpoints at both ends.
|
||||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// FileGroup: Math
|
||||
// FileSummary: Line and plane intersections, circles from 3 points, etc.
|
||||
// FileFootnotes: STD=Included in std.scad
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// include <BOSL2/hingesnaps.scad>
|
||||
// FileGroup: Parts
|
||||
// FileSummary: Foldable, snap-locking parts.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Section: Hinges and Snaps
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// include <BOSL2/joiners.scad>
|
||||
// FileGroup: Parts
|
||||
// FileSummary: Joiner shapes for connecting separately printed objects.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// include <BOSL2/knurling.scad>
|
||||
// FileGroup: Parts
|
||||
// FileSummary: Masks and shapes to create knurling.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
// matrix inverse.
|
||||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// FileGroup: Math
|
||||
// FileSummary: Linear Algebra: solve linear systems, construct and modify matrices.
|
||||
// FileFootnotes: STD=Included in std.scad
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Section: Matrices
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// include <BOSL2/linear_bearings.scad>
|
||||
// FileGroup: Parts
|
||||
// FileSummary: Mounts for LMxUU style linear bearings.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
// Functions for constructing and manipulating generic lists.
|
||||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// FileGroup: Data Management
|
||||
// FileSummary: Various list manipulation functions
|
||||
// FileFootnotes: STD=Included in std.scad
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Terminology:
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
// as geometry or as 2D paths.
|
||||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// FileGroup: Basic Modeling
|
||||
// FileSummary: 2D masking shapes for edge profiling: including roundover, cove, teardrop, ogee.
|
||||
// FileFootnotes: STD=Included in std.scad
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
// edges in three dimensions.
|
||||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// FileGroup: Basic Modeling
|
||||
// FileSummary: 3D masks for rounding edges and corners.
|
||||
// FileFootnotes: STD=Included in std.scad
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
|
15
math.scad
15
math.scad
|
@ -3,6 +3,9 @@
|
|||
// Math helper functions.
|
||||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// FileGroup: Math
|
||||
// FileSummary: General miscellaneous math function.
|
||||
// FileFootnotes: STD=Included in std.scad
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Section: Math Constants
|
||||
|
@ -259,6 +262,8 @@ function u_div(a,b) =
|
|||
// Section: Hyperbolic Trigonometry
|
||||
|
||||
// Function: sinh()
|
||||
// Usage:
|
||||
// a = sinh(x);
|
||||
// Description: Takes a value `x`, and returns the hyperbolic sine of it.
|
||||
function sinh(x) =
|
||||
assert(is_finite(x), "The input must be a finite number.")
|
||||
|
@ -266,6 +271,8 @@ function sinh(x) =
|
|||
|
||||
|
||||
// Function: cosh()
|
||||
// Usage:
|
||||
// a = cosh(x);
|
||||
// Description: Takes a value `x`, and returns the hyperbolic cosine of it.
|
||||
function cosh(x) =
|
||||
assert(is_finite(x), "The input must be a finite number.")
|
||||
|
@ -273,6 +280,8 @@ function cosh(x) =
|
|||
|
||||
|
||||
// Function: tanh()
|
||||
// Usage:
|
||||
// a = tanh(x);
|
||||
// Description: Takes a value `x`, and returns the hyperbolic tangent of it.
|
||||
function tanh(x) =
|
||||
assert(is_finite(x), "The input must be a finite number.")
|
||||
|
@ -280,6 +289,8 @@ function tanh(x) =
|
|||
|
||||
|
||||
// Function: asinh()
|
||||
// Usage:
|
||||
// a = asinh(x);
|
||||
// Description: Takes a value `x`, and returns the inverse hyperbolic sine of it.
|
||||
function asinh(x) =
|
||||
assert(is_finite(x), "The input must be a finite number.")
|
||||
|
@ -287,6 +298,8 @@ function asinh(x) =
|
|||
|
||||
|
||||
// Function: acosh()
|
||||
// Usage:
|
||||
// a = acosh(x);
|
||||
// Description: Takes a value `x`, and returns the inverse hyperbolic cosine of it.
|
||||
function acosh(x) =
|
||||
assert(is_finite(x), "The input must be a finite number.")
|
||||
|
@ -294,6 +307,8 @@ function acosh(x) =
|
|||
|
||||
|
||||
// Function: atanh()
|
||||
// Usage:
|
||||
// a = atanh(x);
|
||||
// Description: Takes a value `x`, and returns the inverse hyperbolic tangent of it.
|
||||
function atanh(x) =
|
||||
assert(is_finite(x), "The input must be a finite number.")
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// include <BOSL2/metric_screws.scad>
|
||||
// FileGroup: Threaded Parts
|
||||
// FileSummary: Metric screws, nuts, and screwholes.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// include <BOSL2/modular_hose.scad>
|
||||
// FileGroup: Parts
|
||||
// FileSummary: Modular flexible hose parts.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Section: Modular Hose Parts
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
// Functions and modules to mutate children in various ways.
|
||||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// FileGroup: Basic Modeling
|
||||
// FileSummary: Modules and Functions to mutate items.
|
||||
// FileFootnotes: STD=Included in std.scad
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
@ -637,7 +640,7 @@ module cylindrical_extrude(or, ir, od, id, size=1000, convexity=10, spin=0, orie
|
|||
yflip()
|
||||
intersection() {
|
||||
left(x) children();
|
||||
rect([quantup(step,pow(2,-15)),size.y],center=true);
|
||||
rect([quantup(step,pow(2,-15)),size.y]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// include <BOSL2/nema_steppers.scad>
|
||||
// FileGroup: Parts
|
||||
// FileSummary: Mounting holes for NEMA motors, and simple motor models.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// include <BOSL2/partitions.scad>
|
||||
// FileGroup: Advanced Modeling
|
||||
// FileSummary: Modules to help partition large objects into smaller assembled parts.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
// path tangents and normals, resampling of paths, and cutting paths up into smaller paths.
|
||||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// FileGroup: Advanced Modeling
|
||||
// FileSummary: Work with arbitrary 2D or 3D paths.
|
||||
// FileFootnotes: STD=Included in std.scad
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Section: Utility Functions
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// include <BOSL2/polyhedra.scad>
|
||||
// FileGroup: Parts
|
||||
// FileSummary: Platonic, Archimidean, Catalan, and stellated polyhedra.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
// Support for Quaternions.
|
||||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// FileGroup: Math
|
||||
// FileSummary: Quaternion based rotations that avoid gimbal lock issues.
|
||||
// FileFootnotes: STD=Included in std.scad
|
||||
///////////////////////////////////////////
|
||||
|
||||
|
||||
|
|
17
regions.scad
17
regions.scad
|
@ -8,6 +8,9 @@
|
|||
// region and you can decompose a region into parts.
|
||||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// FileGroup: Advanced Modeling
|
||||
// FileSummary: Offsets and boolean geometry of 2D paths and regions.
|
||||
// FileFootnotes: STD=Included in std.scad
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
@ -288,7 +291,7 @@ function force_region(poly) = is_path(poly) ? [poly] : poly;
|
|||
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `"origin"`
|
||||
// spin = Rotate this many degrees after anchor. See [spin](attachments.scad#subsection-spin). Default: `0`
|
||||
// cp = Centerpoint for determining intersection anchors or centering the shape. Determintes the base of the anchor vector. Can be "centroid", "mean", "box" or a 2D point. Default: "centroid"
|
||||
// atype = Set to "hull" or "intersect to select anchor type. Default: "hull"
|
||||
// atype = Set to "hull" or "intersect" to select anchor type. Default: "hull"
|
||||
// Example(2D): Displaying a region
|
||||
// region([circle(d=50), square(25,center=true)]);
|
||||
// Example(2D): Displaying a list of polygons that intersect each other, which is not a region
|
||||
|
@ -328,10 +331,14 @@ module region(r, anchor="origin", spin=0, cp="centroid", atype="hull")
|
|||
// point = The point to test.
|
||||
// region = The region to test against, as a list of polygon paths.
|
||||
// eps = Acceptable variance. Default: `EPSILON` (1e-9)
|
||||
// Example(2D,NoAxes): Green points are in the region, red ones are outside
|
||||
// region = [for(i=[2:8]) hexagon(r=i)];
|
||||
// region(region);
|
||||
// for(x=[-4.5:4.5],y=[-4.5:4.5]) color(point_in_region([x,y],region)==1?"green":"red") move([x,y])circle(r=.1,$fn=12);
|
||||
// Example(2D,Med): Red points are in the region.
|
||||
// region = [for(i=[2:4:10]) hexagon(r=i)];
|
||||
// color("#ff7") region(region);
|
||||
// for(x=[-10:10], y=[-10:10])
|
||||
// if (point_in_region([x,y], region)>=0)
|
||||
// move([x,y]) color("red") circle(0.15, $fn=12);
|
||||
// else
|
||||
// move([x,y]) color("#ddf") circle(0.1, $fn=12);
|
||||
function point_in_region(point, region, eps=EPSILON) =
|
||||
let(region=force_region(region))
|
||||
assert(is_region(region), "Region given to point_in_region is not a region")
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// include <BOSL2/rounding.scad>
|
||||
// FileGroup: Advanced Modeling
|
||||
// FileSummary: Round path corners, rounded prisms, rounded cutouts in tubes.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
include <beziers.scad>
|
||||
include <structs.scad>
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// include <BOSL2/screw_drive.scad>
|
||||
// FileGroup: Threaded Parts
|
||||
// FileSummary: Masks for Phillips/Torx/etc driver holes.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
@ -15,6 +17,7 @@
|
|||
// be lowered to different depths to create different sizes of recess.
|
||||
// Arguments:
|
||||
// size = The size of the bit as a number or string. "#0", "#1", "#2", "#3", or "#4"
|
||||
// ---
|
||||
// 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 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`
|
||||
|
@ -29,26 +32,24 @@
|
|||
// Specs for phillips recess here:
|
||||
// https://www.fasteners.eu/tech-info/ISO/4757/
|
||||
|
||||
_phillips_shaft = [3,4.5,6,8,10];
|
||||
_ph_bot_angle = 28.0;
|
||||
_ph_side_angle = 26.5;
|
||||
function _phillips_shaft(x) = [3,4.5,6,8,10][x];
|
||||
function _ph_bot_angle() = 28.0;
|
||||
function _ph_side_angle() = 26.5;
|
||||
|
||||
module phillips_mask(size="#2", $fn=36, anchor=BOTTOM, spin=0, orient=UP) {
|
||||
assert(in_list(size,["#0","#1","#2","#3","#4",0,1,2,3,4]));
|
||||
num = is_num(size) ? size : ord(size[1]) - ord("0");
|
||||
shaft = _phillips_shaft[num];
|
||||
shaft = _phillips_shaft(num);
|
||||
b = [0.61, 0.97, 1.47, 2.41, 3.48][num];
|
||||
e = [0.31, 0.435, 0.815, 2.005, 2.415][num];
|
||||
g = [0.81, 1.27, 2.29, 3.81, 5.08][num];
|
||||
//f = [0.33, 0.53, 0.70, 0.82, 1.23][num];
|
||||
//r = [0.30, 0.50, 0.60, 0.80, 1.00][num];
|
||||
alpha = [ 136, 138, 140, 146, 153][num];
|
||||
beta = [7.00, 7.00, 5.75, 5.75, 7.00][num];
|
||||
gamma = 92.0;
|
||||
h1 = adj_ang_to_opp(g/2, _ph_bot_angle); // height of the small conical tip
|
||||
h2 = adj_ang_to_opp((shaft-g)/2, 90-_ph_side_angle); // height of larger cone
|
||||
h1 = adj_ang_to_opp(g/2, _ph_bot_angle()); // height of the small conical tip
|
||||
h2 = adj_ang_to_opp((shaft-g)/2, 90-_ph_side_angle()); // height of larger cone
|
||||
l = h1+h2;
|
||||
h3 = adj_ang_to_opp(b/2, _ph_bot_angle); // height where cutout starts
|
||||
h3 = adj_ang_to_opp(b/2, _ph_bot_angle()); // height where cutout starts
|
||||
p0 = [0,0];
|
||||
p1 = [adj_ang_to_opp(e/2, 90-alpha/2), -e/2];
|
||||
p2 = p1 + [adj_ang_to_opp((shaft-e)/2, 90-gamma/2),-(shaft-e)/2];
|
||||
|
@ -92,13 +93,11 @@ function phillips_depth(size, d) =
|
|||
num = is_num(size) ? size : ord(size[1]) - ord("0"),
|
||||
shaft = [3,4.5,6,8,10][num],
|
||||
g = [0.81, 1.27, 2.29, 3.81, 5.08][num],
|
||||
_ph_bot_angle = 28.0,
|
||||
_ph_side_angle = 26.5,
|
||||
h1 = adj_ang_to_opp(g/2, _ph_bot_angle), // height of the small conical tip
|
||||
h2 = adj_ang_to_opp((shaft-g)/2, 90-_ph_side_angle) // height of larger cone
|
||||
h1 = adj_ang_to_opp(g/2, _ph_bot_angle()), // height of the small conical tip
|
||||
h2 = adj_ang_to_opp((shaft-g)/2, 90-_ph_side_angle()) // height of larger cone
|
||||
)
|
||||
d>=shaft || d<g ? undef :
|
||||
(d-g) / 2 / tan(_ph_side_angle) + h1;
|
||||
(d-g) / 2 / tan(_ph_side_angle()) + h1;
|
||||
|
||||
|
||||
// Function: phillips_diam()
|
||||
|
@ -114,13 +113,13 @@ function phillips_diam(size, depth) =
|
|||
assert(in_list(size,["#0","#1","#2","#3","#4",0,1,2,3,4]))
|
||||
let(
|
||||
num = is_num(size) ? size : ord(size[1]) - ord("0"),
|
||||
shaft = _phillips_shaft[num],
|
||||
shaft = _phillips_shaft(num),
|
||||
g = [0.81, 1.27, 2.29, 3.81, 5.08][num],
|
||||
h1 = adj_ang_to_opp(g/2, _ph_bot_angle), // height of the small conical tip
|
||||
h2 = adj_ang_to_opp((shaft-g)/2, 90-_ph_side_angle) // height of larger cone
|
||||
h1 = adj_ang_to_opp(g/2, _ph_bot_angle()), // height of the small conical tip
|
||||
h2 = adj_ang_to_opp((shaft-g)/2, 90-_ph_side_angle()) // height of larger cone
|
||||
)
|
||||
depth<h1 || depth>= h1+h2 ? undef :
|
||||
2 * tan(_ph_side_angle)*(depth-h1) + g;
|
||||
2 * tan(_ph_side_angle())*(depth-h1) + g;
|
||||
|
||||
|
||||
|
||||
|
@ -128,6 +127,8 @@ function phillips_diam(size, depth) =
|
|||
|
||||
|
||||
// Function: torx_outer_diam()
|
||||
// Usage:
|
||||
// diam = torx_outer_diam(size);
|
||||
// Description: Get the typical outer diameter of Torx profile.
|
||||
// Arguments:
|
||||
// size = Torx size.
|
||||
|
@ -152,6 +153,8 @@ function torx_outer_diam(size) = lookup(size, [
|
|||
|
||||
|
||||
// Function: torx_inner_diam()
|
||||
// Usage:
|
||||
// diam = torx_inner_diam(size);
|
||||
// Description: Get typical inner diameter of Torx profile.
|
||||
// Arguments:
|
||||
// size = Torx size.
|
||||
|
@ -176,6 +179,8 @@ function torx_inner_diam(size) = lookup(size, [
|
|||
|
||||
|
||||
// Function: torx_depth()
|
||||
// Usage:
|
||||
// depth = torx_depth(size);
|
||||
// Description: Gets typical drive hole depth.
|
||||
// Arguments:
|
||||
// size = Torx size.
|
||||
|
@ -200,6 +205,8 @@ function torx_depth(size) = lookup(size, [
|
|||
|
||||
|
||||
// Function: torx_tip_radius()
|
||||
// Usage:
|
||||
// rad = torx_tip_radius(size);
|
||||
// Description: Gets minor rounding radius of Torx profile.
|
||||
// Arguments:
|
||||
// size = Torx size.
|
||||
|
@ -224,6 +231,8 @@ function torx_tip_radius(size) = lookup(size, [
|
|||
|
||||
|
||||
// Function: torx_rounding_radius()
|
||||
// Usage:
|
||||
// rad = torx_rounding_radius(size);
|
||||
// Description: Gets major rounding radius of Torx profile.
|
||||
// Arguments:
|
||||
// size = Torx size.
|
||||
|
@ -249,6 +258,8 @@ function torx_rounding_radius(size) = lookup(size, [
|
|||
|
||||
|
||||
// Module: torx_mask2d()
|
||||
// Usage:
|
||||
// torx_mask2d(size);
|
||||
// Description: Creates a torx bit 2D profile.
|
||||
// Arguments:
|
||||
// size = Torx size.
|
||||
|
@ -287,11 +298,14 @@ module torx_mask2d(size) {
|
|||
|
||||
|
||||
// Module: torx_mask()
|
||||
// Usage:
|
||||
// torx_mask(size, l, [center]);
|
||||
// Description: Creates a torx bit tip.
|
||||
// Arguments:
|
||||
// size = Torx size.
|
||||
// l = Length of bit.
|
||||
// center = If true, centers bit vertically.
|
||||
// ---
|
||||
// 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 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`
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// include <BOSL2/screws.scad>
|
||||
// FileGroup: Threaded Parts
|
||||
// FileSummary: ISO (metric) and UTS screws and nuts.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
include <structs.scad>
|
||||
|
@ -783,7 +785,7 @@ module screw_head(screw_info,details=false) {
|
|||
intersection(){
|
||||
arc(points=[[-head_size2/2,0], [0,-base+head_height * (head=="button"?4/3:1)], [head_size2/2,0]]);
|
||||
square([head_size2, head_height-base]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (head=="pan flat")
|
||||
cyl(l=head_height, d=head_size, rounding2=0.2*head_size, anchor=BOTTOM);
|
||||
|
@ -1238,7 +1240,6 @@ module _rod(spec, length, tolerance, orient=UP, spin=0, anchor=CENTER)
|
|||
{
|
||||
threadspec = thread_specification(spec, internal=false, tolerance=tolerance);
|
||||
echo(d_major_mean = mean(struct_val(threadspec, "d_major")));
|
||||
echo(bolt_profile=_thread_profile(threadspec));
|
||||
|
||||
threaded_rod([mean(struct_val(threadspec, "d_minor")),
|
||||
mean(struct_val(threadspec, "d_pitch")),
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
DISPMD=0
|
||||
GEN_ARGS=()
|
||||
FILES=()
|
||||
for opt in "$@" ; do
|
||||
case "$opt" in
|
||||
-f ) GEN_ARGS+=(-f) ;;
|
||||
-d ) DISPMD=1 ;;
|
||||
-* ) echo "Unknown option $opt" >&2; exit 1 ;;
|
||||
* ) FILES+=("$opt") ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if (( ${#FILES[@]} == 0 )); then
|
||||
FILES=(Shapes2d Shapes3d Transforms Distributors Mutators Attachments Paths FractalTree)
|
||||
fi
|
||||
|
||||
# Try to cd to the BOSL2.wiki directory if run from the BOSL2 root
|
||||
if [[ "$(basename "$PWD")" != "BOSL2.wiki" ]]; then
|
||||
if ! cd BOSL2.wiki; then
|
||||
echo "BOSL2.wiki directory not found, try running from the BOSL2 or BOSL2/BOSL2.wiki directory" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
rm -f tmp_*.scad
|
||||
for base in "${FILES[@]}"; do
|
||||
base="$(basename "$base" .md)"
|
||||
mkdir -p images/tutorials
|
||||
rm -f "images/tutorials/${base}"_*.png "images/tutorials/${base}"_*.gif
|
||||
echo "${base}.md"
|
||||
../scripts/tutorial_gen.py "../tutorials/${base}.md" -o "Tutorial-${base}.md" "${GEN_ARGS[@]}" -I images/tutorials/ || exit 1
|
||||
if (( DISPMD )); then
|
||||
open -a Typora "Tutorial-${base}.md"
|
||||
fi
|
||||
done
|
||||
|
||||
|
|
@ -1,133 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import sys
|
||||
import os.path
|
||||
import argparse
|
||||
|
||||
from openscad_docsgen.imagemanager import ImageManager
|
||||
|
||||
|
||||
imgmgr = ImageManager()
|
||||
|
||||
|
||||
def img_started(req):
|
||||
print(" {}... ".format(os.path.basename(req.image_file)), end='')
|
||||
sys.stdout.flush()
|
||||
|
||||
|
||||
def img_completed(req):
|
||||
if req.success:
|
||||
if req.status == "SKIP":
|
||||
print()
|
||||
else:
|
||||
print(req.status)
|
||||
sys.stdout.flush()
|
||||
return
|
||||
out = "\n\n"
|
||||
for line in req.echos:
|
||||
out += line + "\n"
|
||||
for line in req.warnings:
|
||||
out += line + "\n"
|
||||
for line in req.errors:
|
||||
out += line + "\n"
|
||||
out += "//////////////////////////////////////////////////////////////////////\n"
|
||||
out += "// LibFile: {} Line: {} Image: {}\n".format(
|
||||
req.src_file, req.src_line, os.path.basename(req.image_file)
|
||||
)
|
||||
out += "//////////////////////////////////////////////////////////////////////\n"
|
||||
for line in req.script_lines:
|
||||
out += line + "\n"
|
||||
out += "//////////////////////////////////////////////////////////////////////\n"
|
||||
print(out, file=sys.stderr)
|
||||
sys.exit(-1)
|
||||
|
||||
|
||||
def processFile(infile, outfile=None, imgroot=""):
|
||||
if imgroot and not imgroot.endswith('/'):
|
||||
imgroot += "/"
|
||||
fileroot = os.path.splitext(os.path.basename(infile))[0]
|
||||
|
||||
outdata = []
|
||||
with open(infile, "r") as f:
|
||||
script = ["include <BOSL2/std.scad>"]
|
||||
extyp = ""
|
||||
in_script = False
|
||||
imgnum = 0
|
||||
show_script = True
|
||||
linenum = -1
|
||||
for line in f.readlines():
|
||||
linenum += 1
|
||||
line = line.rstrip("\n")
|
||||
if line.startswith("```openscad"):
|
||||
in_script = True;
|
||||
if "-" in line:
|
||||
extyp = line.split("-")[1]
|
||||
else:
|
||||
extyp = ""
|
||||
show_script = "ImgOnly" not in extyp
|
||||
script = ["include <BOSL2/std.scad>"]
|
||||
imgnum = imgnum + 1
|
||||
elif in_script:
|
||||
if line == "```":
|
||||
in_script = False
|
||||
fext = "png"
|
||||
if any(x in extyp for x in ("Anim", "Spin")):
|
||||
fext = "gif"
|
||||
imgfile = os.path.join(imgroot, "{}_{}.{}".format(fileroot, imgnum, fext))
|
||||
imgmgr.new_request(
|
||||
fileroot+".md", linenum,
|
||||
imgfile, script, extyp,
|
||||
starting_cb=img_started,
|
||||
completion_cb=img_completed
|
||||
)
|
||||
if show_script:
|
||||
outdata.append("```openscad")
|
||||
outdata.extend(script)
|
||||
outdata.append("```")
|
||||
outdata.append("![Figure {}]({})".format(imgnum, imgfile))
|
||||
show_script = True
|
||||
extyp = ""
|
||||
else:
|
||||
script.append(line)
|
||||
else:
|
||||
outdata.append(line)
|
||||
|
||||
if outfile == None:
|
||||
f = sys.stdout
|
||||
else:
|
||||
f = open(outfile, "w")
|
||||
|
||||
for line in outdata:
|
||||
print(line, file=f)
|
||||
|
||||
if outfile:
|
||||
f.close()
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(prog='docs_gen')
|
||||
parser.add_argument('-I', '--imgroot', default="",
|
||||
help='The directory to put generated images in.')
|
||||
parser.add_argument('-o', '--outfile',
|
||||
help='Output file, if different from infile.')
|
||||
parser.add_argument('infile', help='Input filename.')
|
||||
args = parser.parse_args()
|
||||
|
||||
processFile(
|
||||
args.infile,
|
||||
outfile=args.outfile,
|
||||
imgroot=args.imgroot
|
||||
)
|
||||
imgmgr.process_requests()
|
||||
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
||||
# vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|
|
@ -10,6 +10,9 @@
|
|||
// function forms that produce a path.
|
||||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// FileGroup: Basic Modeling
|
||||
// FileSummary: Attachable circles, squares, polygons, teardrop. Can make geometry or paths.
|
||||
// FileFootnotes: STD=Included in std.scad
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
use <builtins.scad>
|
||||
|
@ -109,7 +112,7 @@ module rect(size=1, rounding=0, chamfer=0, anchor=CENTER, spin=0) {
|
|||
children();
|
||||
}
|
||||
} else {
|
||||
pts = rect(size=size, rounding=rounding, chamfer=chamfer, center=true);
|
||||
pts = rect(size=size, rounding=rounding, chamfer=chamfer);
|
||||
attachable(anchor, spin, two_d=true, path=pts) {
|
||||
polygon(pts);
|
||||
children();
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
// so you can place it on a curved object.
|
||||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// FileGroup: Basic Modeling
|
||||
// FileSummary: Attachable cubes, cylinders, spheres, ruler, and text. Many can produce a VNF.
|
||||
// FileFootnotes: STD=Included in std.scad
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
use <builtins.scad>
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
// - https://github.com/openscad/list-comprehension-demos/blob/master/skin.scad
|
||||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// FileGroup: Advanced Modeling
|
||||
// FileSummary: Construct 3D shapes from a 2D cross sections of the desired shape.
|
||||
// FileFootnotes: STD=Included in std.scad
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// include <BOSL2/sliders.scad>
|
||||
// FileGroup: Parts
|
||||
// FileSummary: Simple sliders and rails.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
// String manipulation and formatting functions.
|
||||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// FileGroup: Data Management
|
||||
// FileSummary: String manipulation functions.
|
||||
// FileFootnotes: STD=Included in std.scad
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// include <BOSL2/structs.scad>
|
||||
// FileGroup: Data Management
|
||||
// FileSummary: Structure/Dictionary Manipulation
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// include <BOSL2/threading.scad>
|
||||
// FileGroup: Threaded Parts
|
||||
// FileSummary: Various types of threaded rods and nuts.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
|
|
@ -15,6 +15,9 @@
|
|||
// operate on. The exceptions are rot(), frame_map() and skew().
|
||||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// FileGroup: Basic Modeling
|
||||
// FileSummary: Shortcuts for translation, rotation, etc. Can act on geometry, paths, or can return a matrix.
|
||||
// FileFootnotes: STD=Included in std.scad
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
// all the function relations, or silly acronyms like SOHCAHTOA.
|
||||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// FileGroup: Math
|
||||
// FileSummary: Trigonometry shortcuts for when you can't recall the mnemonic SOHCAHTOA.
|
||||
// FileFootnotes: STD=Included in std.scad
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// include <BOSL2/turtle3d.scad>
|
||||
// FileGroup: Advanced Modeling
|
||||
// FileSummary: 3D turtle graphics for making paths or lists of transformations.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
include<structs.scad>
|
||||
|
||||
|
|
|
@ -958,7 +958,7 @@ stellate_cube() show_anchors(50);
|
|||
```openscad-3D
|
||||
$fn=32;
|
||||
R = difference(circle(10), right(2, circle(9)));
|
||||
linear_sweep(R,height=10,anchor_isect=true)
|
||||
linear_sweep(R,height=10,atype="hull")
|
||||
attach(RIGHT) anchor_arrow();
|
||||
```
|
||||
|
||||
|
|
|
@ -136,7 +136,7 @@ stroke(path, closed=true, endcap2="arrow2");
|
|||
```
|
||||
|
||||
```openscad-2D
|
||||
path = rect([40,30], rounding=5, center=true);
|
||||
path = rect([40,30], rounding=5);
|
||||
stroke(path, closed=true, endcap2="arrow2");
|
||||
```
|
||||
|
||||
|
@ -151,7 +151,7 @@ stroke(path, closed=true, endcap2="arrow2");
|
|||
```
|
||||
|
||||
```openscad-2D
|
||||
path = oval(d=[50,30]);
|
||||
path = ellipse(d=[50,30]);
|
||||
stroke(path, closed=true, endcap2="arrow2");
|
||||
```
|
||||
|
||||
|
|
|
@ -28,13 +28,13 @@ You can use it in the same way you use `square()`, but it also provides
|
|||
extended functionality. For example, it allows you to round the corners:
|
||||
|
||||
```openscad-2D
|
||||
rect([60,40], center=true, rounding=10);
|
||||
rect([60,40], rounding=10);
|
||||
```
|
||||
|
||||
Or chamfer them:
|
||||
|
||||
```openscad-2D
|
||||
rect([60,40], center=true, chamfer=10);
|
||||
rect([60,40], chamfer=10);
|
||||
```
|
||||
|
||||
You can even specify *which* corners get rounded or chamfered. If you pass a
|
||||
|
@ -52,18 +52,18 @@ translate([ 50, 50]) text3d("I");
|
|||
translate([-50, 50]) text3d("II");
|
||||
translate([-50,-50]) text3d("III");
|
||||
translate([ 50,-50]) text3d("IV");
|
||||
rect([90,80], center=true);
|
||||
rect([90,80]);
|
||||
```
|
||||
|
||||
If a size is given as `0`, then there is no rounding and/or chamfering for
|
||||
that quadrant's corner:
|
||||
|
||||
```openscad-2D
|
||||
rect([60,40], center=true, rounding=[0,5,10,15]);
|
||||
rect([60,40], rounding=[0,5,10,15]);
|
||||
```
|
||||
|
||||
```openscad-2D
|
||||
rect([60,40], center=true, chamfer=[0,5,10,15]);
|
||||
rect([60,40], chamfer=[0,5,10,15]);
|
||||
```
|
||||
|
||||
You can give both `rounding=` and `chamfer=` arguments to mix rounding and
|
||||
|
@ -71,15 +71,14 @@ chamfering, but only if you specify per corner. If you want a rounding in
|
|||
a corner, specify a 0 chamfer for that corner, and vice versa:
|
||||
|
||||
```openscad-2D
|
||||
rect([60,40], center=true, rounding=[5,0,10,0], chamfer=[0,5,0,15]);
|
||||
rect([60,40], rounding=[5,0,10,0], chamfer=[0,5,0,15]);
|
||||
```
|
||||
|
||||
#### Anchors and Spin
|
||||
Another way that `rect()` is enhanced over `square()`, is that you can anchor,
|
||||
spin and attach it.
|
||||
|
||||
The `anchor=` argument is an alternative to `center=`, which allows more
|
||||
alignment options. It takes a vector as a value, pointing roughly towards
|
||||
The `anchor=` argument takes a vector as a value, pointing roughly towards
|
||||
the side or corner you want to align to the origin. For example, to align
|
||||
the center of the back edge to the origin, set the anchor to `[0,1]`:
|
||||
|
||||
|
@ -145,7 +144,7 @@ rect([60,40], anchor=BACK, spin=30);
|
|||
Anchor points double as attachment points, so that you can attach other shapes:
|
||||
|
||||
```openscad-2D
|
||||
rect([60,40],center=true)
|
||||
rect([60,40])
|
||||
show_anchors();
|
||||
```
|
||||
|
||||
|
@ -164,7 +163,7 @@ circle(d=100);
|
|||
circle(d=100, $fn=8);
|
||||
```
|
||||
|
||||
The BOSL2 library also provides an enhanced equivalent of `circle()` called `oval()`.
|
||||
The BOSL2 library also provides an enhanced equivalent of `circle()` called `ellipse()`.
|
||||
You can use it in the same way you use `circle()`, but it also provides extended
|
||||
functionality. For example, it allows more control over its size and orientation.
|
||||
|
||||
|
@ -172,22 +171,22 @@ Since a circle in OpenSCAD can only be approximated by a regular polygon with
|
|||
a number of straight sides, this can lead to size and shape inaccuracies.
|
||||
To counter this, the `realign=` and `circum=` arguments are also provided.
|
||||
|
||||
The `realign=` argument, if set `true`, rotates the `oval()` by half the angle
|
||||
The `realign=` argument, if set `true`, rotates the `ellipse()` by half the angle
|
||||
between the sides:
|
||||
|
||||
```openscad-2D
|
||||
oval(d=100, $fn=8, realign=true);
|
||||
ellipse(d=100, $fn=8, realign=true);
|
||||
```
|
||||
|
||||
The `circum=` argument, if true, makes it so that the polygon forming the
|
||||
`oval()` circumscribes the ideal circle instead of inscribing it.
|
||||
`ellipse()` circumscribes the ideal circle instead of inscribing it.
|
||||
|
||||
Inscribing the ideal circle:
|
||||
|
||||
```openscad-2D
|
||||
difference() {
|
||||
circle(d=100, $fn=360);
|
||||
oval(d=100, $fn=8);
|
||||
ellipse(d=100, $fn=8);
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -195,39 +194,39 @@ Circumscribing the ideal circle:
|
|||
|
||||
```openscad-2D
|
||||
difference() {
|
||||
oval(d=100, $fn=8, circum=true);
|
||||
ellipse(d=100, $fn=8, circum=true);
|
||||
circle(d=100, $fn=360);
|
||||
}
|
||||
```
|
||||
|
||||
The `oval()` module, as its name suggests, can be given separate X and Y radii
|
||||
The `ellipse()` module, as its name suggests, can be given separate X and Y radii
|
||||
or diameters. To do this, just give `r=` or `d=` with a list of two radii or
|
||||
diameters:
|
||||
|
||||
```openscad-2D
|
||||
oval(r=[30,20]);
|
||||
ellipse(r=[30,20]);
|
||||
```
|
||||
|
||||
```openscad-2D
|
||||
oval(d=[60,40]);
|
||||
ellipse(d=[60,40]);
|
||||
```
|
||||
|
||||
Another way that `oval()` is enhanced over `circle()`, is that you can anchor,
|
||||
Another way that `ellipse()` is enhanced over `circle()`, is that you can anchor,
|
||||
spin and attach it.
|
||||
|
||||
```openscad-2D
|
||||
oval(r=50, anchor=BACK);
|
||||
ellipse(r=50, anchor=BACK);
|
||||
```
|
||||
|
||||
```openscad-2D
|
||||
oval(r=50, anchor=FRONT+RIGHT);
|
||||
ellipse(r=50, anchor=FRONT+RIGHT);
|
||||
```
|
||||
|
||||
Using spin on a circle may not make initial sense, until you remember that
|
||||
anchoring is performed before spin:
|
||||
|
||||
```openscad-2D
|
||||
oval(r=50, anchor=FRONT, spin=-30);
|
||||
ellipse(r=50, anchor=FRONT, spin=-30);
|
||||
```
|
||||
|
||||
|
||||
|
@ -349,7 +348,7 @@ They also have somewhat different attachment behavior:
|
|||
|
||||
```openscad-2D
|
||||
color("green") stroke(circle(d=50), closed=true);
|
||||
oval(d=50,$fn=5)
|
||||
ellipse(d=50,$fn=5)
|
||||
attach(LEFT) color("blue") anchor_arrow2d();
|
||||
```
|
||||
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
// Utility functions used in argument processing.
|
||||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// FileGroup: Data Management
|
||||
// FileSummary: Helpers for argument processing.
|
||||
// FileFootnotes: STD=Included in std.scad
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
|
39
vectors.scad
39
vectors.scad
|
@ -3,6 +3,9 @@
|
|||
// Vector math functions.
|
||||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// FileGroup: Math
|
||||
// FileSummary: Vector math functions.
|
||||
// FileFootnotes: STD=Included in std.scad
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
@ -63,6 +66,8 @@ function add_scalar(v,s) =
|
|||
|
||||
|
||||
// Function: v_mul()
|
||||
// Usage:
|
||||
// v3 = v_mul(v1, v2);
|
||||
// Description:
|
||||
// Element-wise multiplication. Multiplies each element of `v1` by the corresponding element of `v2`.
|
||||
// Both `v1` and `v2` must be the same length. Returns a vector of the products.
|
||||
|
@ -77,6 +82,8 @@ function v_mul(v1, v2) =
|
|||
|
||||
|
||||
// Function: v_div()
|
||||
// Usage:
|
||||
// v3 = v_div(v1, v2);
|
||||
// Description:
|
||||
// Element-wise vector division. Divides each element of vector `v1` by
|
||||
// the corresponding element of vector `v2`. Returns a vector of the quotients.
|
||||
|
@ -91,6 +98,8 @@ function v_div(v1, v2) =
|
|||
|
||||
|
||||
// Function: v_abs()
|
||||
// Usage:
|
||||
// v2 = v_abs(v);
|
||||
// Description: Returns a vector of the absolute value of each element of vector `v`.
|
||||
// Arguments:
|
||||
// v = The vector to get the absolute values of.
|
||||
|
@ -102,6 +111,8 @@ function v_abs(v) =
|
|||
|
||||
|
||||
// Function: v_floor()
|
||||
// Usage:
|
||||
// v2 = v_floor(v);
|
||||
// Description:
|
||||
// Returns the given vector after performing a `floor()` on all items.
|
||||
function v_floor(v) =
|
||||
|
@ -110,6 +121,8 @@ function v_floor(v) =
|
|||
|
||||
|
||||
// Function: v_ceil()
|
||||
// Usage:
|
||||
// v2 = v_ceil(v);
|
||||
// Description:
|
||||
// Returns the given vector after performing a `ceil()` on all items.
|
||||
function v_ceil(v) =
|
||||
|
@ -118,6 +131,8 @@ function v_ceil(v) =
|
|||
|
||||
|
||||
// Function: v_lookup()
|
||||
// Usage:
|
||||
// v2 = v_ceil(x, v);
|
||||
// Description:
|
||||
// Works just like the built-in function [`lookup()`](https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Mathematical_Functions#lookup), except that it can also interpolate between vector result values of the same length.
|
||||
// Arguments:
|
||||
|
@ -147,7 +162,7 @@ function v_lookup(x, v) =
|
|||
|
||||
// Function: unit()
|
||||
// Usage:
|
||||
// unit(v, [error]);
|
||||
// v = unit(v, [error]);
|
||||
// Description:
|
||||
// Returns the unit length normalized version of vector v. If passed a zero-length vector,
|
||||
// asserts an error unless `error` is given, in which case the value of `error` is returned.
|
||||
|
@ -180,10 +195,10 @@ function v_theta(v) =
|
|||
|
||||
// Function: vector_angle()
|
||||
// Usage:
|
||||
// vector_angle(v1,v2);
|
||||
// vector_angle([v1,v2]);
|
||||
// vector_angle(PT1,PT2,PT3);
|
||||
// vector_angle([PT1,PT2,PT3]);
|
||||
// ang = vector_angle(v1,v2);
|
||||
// ang = vector_angle([v1,v2]);
|
||||
// ang = vector_angle(PT1,PT2,PT3);
|
||||
// ang = vector_angle([PT1,PT2,PT3]);
|
||||
// Description:
|
||||
// If given a single list of two vectors, like `vector_angle([V1,V2])`, returns the angle between the two vectors V1 and V2.
|
||||
// If given a single list of three points, like `vector_angle([A,B,C])`, returns the angle between the line segments AB and BC.
|
||||
|
@ -222,10 +237,10 @@ function vector_angle(v1,v2,v3) =
|
|||
|
||||
// Function: vector_axis()
|
||||
// Usage:
|
||||
// vector_axis(v1,v2);
|
||||
// vector_axis([v1,v2]);
|
||||
// vector_axis(PT1,PT2,PT3);
|
||||
// vector_axis([PT1,PT2,PT3]);
|
||||
// axis = vector_axis(v1,v2);
|
||||
// axis = vector_axis([v1,v2]);
|
||||
// axis = vector_axis(PT1,PT2,PT3);
|
||||
// axis = vector_axis([PT1,PT2,PT3]);
|
||||
// Description:
|
||||
// If given a single list of two vectors, like `vector_axis([V1,V2])`, returns the vector perpendicular the two vectors V1 and V2.
|
||||
// If given a single list of three points, like `vector_axis([A,B,C])`, returns the vector perpendicular to the plane through a, B and C.
|
||||
|
@ -487,7 +502,7 @@ function _bt_tree(points, ind, leafsize=25) =
|
|||
|
||||
// Function: vector_nearest()
|
||||
// Usage:
|
||||
// indices = vector_nearest(query, k, target)
|
||||
// indices = vector_nearest(query, k, target);
|
||||
// See Also: vector_search(), vector_search_tree()
|
||||
// Description:
|
||||
// Search `target` for the `k` points closest to point `query`.
|
||||
|
@ -560,8 +575,8 @@ function _insert_sorted(list, k, new) =
|
|||
|
||||
function _insert_many(list, k, newlist,i=0) =
|
||||
i==len(newlist)
|
||||
? list
|
||||
: assert(is_vector(newlist[i],2), "The tree is invalid.")
|
||||
? list
|
||||
: assert(is_vector(newlist[i],2), "The tree is invalid.")
|
||||
_insert_many(_insert_sorted(list,k,newlist[i]),k,newlist,i+1);
|
||||
|
||||
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
// File that provides functions to manage versioning.
|
||||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// FileGroup: Data Management
|
||||
// FileSummary: Parse and compare semantic versions.
|
||||
// FileFootnotes: STD=Included in std.scad
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
|
13
vnf.scad
13
vnf.scad
|
@ -6,6 +6,9 @@
|
|||
// reversed faces.
|
||||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// FileGroup: Advanced Modeling
|
||||
// FileSummary: Vertices 'n' Faces structure. Makes polyhedron() easier to use.
|
||||
// FileFootnotes: STD=Included in std.scad
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
@ -1067,8 +1070,8 @@ function _triangulate_planar_convex_polygons(polys) =
|
|||
// bent2 = vnf_bend(vnf2, axis="Y");
|
||||
// vnf_polyhedron([bent1,bent2]);
|
||||
// Example(3D):
|
||||
// rgn = union(rect([100,20],center=true),
|
||||
// rect([20,100],center=true));
|
||||
// rgn = union(rect([100,20]),
|
||||
// rect([20,100]));
|
||||
// vnf0 = linear_sweep(zrot(45,p=rgn), height=10);
|
||||
// vnf1 = up(50, p=vnf0);
|
||||
// vnf2 = down(50, p=vnf0);
|
||||
|
@ -1077,7 +1080,7 @@ function _triangulate_planar_convex_polygons(polys) =
|
|||
// vnf_polyhedron([bent1,bent2]);
|
||||
// Example(3D): Bending Around X Axis.
|
||||
// rgnr = union(
|
||||
// rect([20,100],center=true),
|
||||
// rect([20,100]),
|
||||
// back(50, p=trapezoid(w1=40, w2=0, h=20, anchor=FRONT))
|
||||
// );
|
||||
// vnf0 = xrot(00,p=linear_sweep(rgnr, height=10));
|
||||
|
@ -1087,7 +1090,7 @@ function _triangulate_planar_convex_polygons(polys) =
|
|||
// vnf_polyhedron([bent1]);
|
||||
// Example(3D): Bending Around Y Axis.
|
||||
// rgn = union(
|
||||
// rect([20,100],center=true),
|
||||
// rect([20,100]),
|
||||
// back(50, p=trapezoid(w1=40, w2=0, h=20, anchor=FRONT))
|
||||
// );
|
||||
// rgnr = zrot(-90, p=rgn);
|
||||
|
@ -1098,7 +1101,7 @@ function _triangulate_planar_convex_polygons(polys) =
|
|||
// vnf_polyhedron([bent1]);
|
||||
// Example(3D): Bending Around Z Axis.
|
||||
// rgn = union(
|
||||
// rect([20,100],center=true),
|
||||
// rect([20,100]),
|
||||
// back(50, p=trapezoid(w1=40, w2=0, h=20, anchor=FRONT))
|
||||
// );
|
||||
// rgnr = zrot(90, p=rgn);
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// include <BOSL2/walls.scad>
|
||||
// FileGroup: Parts
|
||||
// FileSummary: Walls and structural elements that 3D print without support.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// include <BOSL2/wiring.scad>
|
||||
// FileGroup: Parts
|
||||
// FileSummary: Routed bundles of wires.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue