Merge pull request #827 from adrianVmariano/master

usage fixes
This commit is contained in:
Revar Desmera 2022-04-03 12:52:17 -07:00 committed by GitHub
commit 4404dfde45
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 200 additions and 32 deletions

View file

@ -140,7 +140,7 @@ function _point_left_of_line2d(point, line, eps=EPSILON) =
// Function: is_collinear() // Function: is_collinear()
// Usage: // Usage:
// test = is_collinear(a, [b, c], [eps]); // bool = is_collinear(a, [b, c], [eps]);
// Topics: Geometry, Points, Collinearity // Topics: Geometry, Points, Collinearity
// Description: // Description:
// Returns true if the points `a`, `b` and `c` are co-linear or if the list of points `a` is collinear. // Returns true if the points `a`, `b` and `c` are co-linear or if the list of points `a` is collinear.
@ -161,7 +161,7 @@ function is_collinear(a, b, c, eps=EPSILON) =
// Function: point_line_distance() // Function: point_line_distance()
// Usage: // Usage:
// pt = point_line_distance(line, pt, bounded); // dist = point_line_distance(line, pt, [bounded]);
// Topics: Geometry, Points, Lines, Distance // Topics: Geometry, Points, Lines, Distance
// Description: // Description:
// Finds the shortest distance from the point `pt` to the specified line, segment or ray. // Finds the shortest distance from the point `pt` to the specified line, segment or ray.
@ -421,7 +421,7 @@ function line_from_points(points, fast=false, eps=EPSILON) =
// Function: is_coplanar() // Function: is_coplanar()
// Usage: // Usage:
// test = is_coplanar(points,[eps]); // bool = is_coplanar(points,[eps]);
// Topics: Geometry, Coplanarity // Topics: Geometry, Coplanarity
// Description: // Description:
// Returns true if the given 3D points are non-collinear and are on a plane. // Returns true if the given 3D points are non-collinear and are on a plane.
@ -765,6 +765,7 @@ function plane_line_angle(plane, line) =
// Given a plane definition `[A,B,C,D]`, where `Ax+By+Cz=D`, and a list of 2d or // Given a plane definition `[A,B,C,D]`, where `Ax+By+Cz=D`, and a list of 2d or
// 3d points, return the closest 3D orthogonal projection of the points on the plane. // 3d points, return the closest 3D orthogonal projection of the points on the plane.
// In other words, for every point given, returns the closest point to it on the plane. // In other words, for every point given, returns the closest point to it on the plane.
// If points is a single point then returns a single point result.
// Arguments: // Arguments:
// plane = The `[A,B,C,D]` plane definition where `Ax+By+Cz=D` is the formula of the plane. // plane = The `[A,B,C,D]` plane definition where `Ax+By+Cz=D` is the formula of the plane.
// points = List of points to project // points = List of points to project
@ -824,7 +825,7 @@ function _pointlist_greatest_distance(points,plane) =
// Function: are_points_on_plane() // Function: are_points_on_plane()
// Usage: // Usage:
// test = are_points_on_plane(points, plane, [eps]); // bool = are_points_on_plane(points, plane, [eps]);
// Topics: Geometry, Planes, Points // Topics: Geometry, Planes, Points
// Description: // Description:
// Returns true if the given 3D points are on the given plane. // Returns true if the given 3D points are on the given plane.
@ -841,7 +842,7 @@ function are_points_on_plane(points, plane, eps=EPSILON) =
/// Internal Function: is_point_above_plane() /// Internal Function: is_point_above_plane()
/// Usage: /// Usage:
/// test = _is_point_above_plane(plane, point); /// bool = _is_point_above_plane(plane, point);
/// Topics: Geometry, Planes /// Topics: Geometry, Planes
// Description: // Description:
/// Given a plane as [A,B,C,D] where the cartesian equation for that plane /// Given a plane as [A,B,C,D] where the cartesian equation for that plane
@ -860,7 +861,7 @@ function _is_point_above_plane(plane, point) =
// Function: circle_line_intersection() // Function: circle_line_intersection()
// Usage: // Usage:
// isect = circle_line_intersection(c,<r|d>,[line],[bounded],[eps]); // isect = circle_line_intersection(c, r|d=, line, [bounded], [eps=]);
// Topics: Geometry, Circles, Lines, Intersection // Topics: Geometry, Circles, Lines, Intersection
// Description: // Description:
// Find intersection points between a 2d circle and a line, ray or segment specified by two points. // Find intersection points between a 2d circle and a line, ray or segment specified by two points.
@ -903,7 +904,7 @@ function _circle_or_sphere_line_intersection(c,r,line,bounded=false,d,eps=EPSILO
// Function: circle_circle_intersection() // Function: circle_circle_intersection()
// Usage: // Usage:
// pts = circle_circle_tangents(c1, r1|d1, c2, r2|d2, [eps]); // pts = circle_circle_tangents(c1, r1|d1=, c2, r2|d2=, [eps]);
// Topics: Geometry, Circles // Topics: Geometry, Circles
// Description: // Description:
// Compute the intersection points of two circles. Returns a list of the intersection points, which // Compute the intersection points of two circles. Returns a list of the intersection points, which
@ -969,10 +970,10 @@ function circle_circle_intersection(c1,r1,c2,r2,eps=EPSILON,d1,d2) =
// Function&Module: circle_2tangents() // Function&Module: circle_2tangents()
// Usage: As Function // Usage: As Function
// circ = circle_2tangents(pt1, pt2, pt3, r|d, [tangents]); // circ = circle_2tangents(pt1, pt2, pt3, r|d=, [tangents=]);
// Topics: Geometry, Circles, Tangents // Topics: Geometry, Circles, Tangents
// Usage: As Module // Usage: As Module
// circle_2tangents(pt1, pt2, pt3, r|d, [h], [center]); // circle_2tangents(pt1, pt2, pt3, r|d=, [h=], [center=]);
// Description: // Description:
// Given a pair of rays with a common origin, and a known circle radius/diameter, finds // Given a pair of rays with a common origin, and a known circle radius/diameter, finds
// the centerpoint for the circle of that size that touches both rays tangentally. // the centerpoint for the circle of that size that touches both rays tangentally.
@ -998,6 +999,7 @@ function circle_circle_intersection(c1,r1,c2,r2,eps=EPSILON,d1,d2) =
// pt2 = The starting point of both rays. // pt2 = The starting point of both rays.
// pt3 = A point that the second ray passes though. // pt3 = A point that the second ray passes though.
// r = The radius of the circle to find. // r = The radius of the circle to find.
// ---
// d = The diameter of the circle to find. // d = The diameter of the circle to find.
// h = Height of the cylinder to create, when called as a module. // h = Height of the cylinder to create, when called as a module.
// center = When called as a module, center the cylinder if true, Default: false // center = When called as a module, center the cylinder if true, Default: false
@ -1063,6 +1065,7 @@ function circle_2tangents(pt1, pt2, pt3, r, d, tangents=false) =
module circle_2tangents(pt1, pt2, pt3, r, d, h, center=false) { module circle_2tangents(pt1, pt2, pt3, r, d, h, center=false) {
no_children($children);
c = circle_2tangents(pt1=pt1, pt2=pt2, pt3=pt3, r=r, d=d); c = circle_2tangents(pt1=pt1, pt2=pt2, pt3=pt3, r=r, d=d);
assert(!is_undef(c), "Cannot find circle when both rays are collinear."); assert(!is_undef(c), "Cannot find circle when both rays are collinear.");
cp = c[0]; n = c[1]; cp = c[0]; n = c[1];
@ -1147,6 +1150,7 @@ function circle_3points(pt1, pt2, pt3) =
module circle_3points(pt1, pt2, pt3, h, center=false) { module circle_3points(pt1, pt2, pt3, h, center=false) {
no_children($children);
c = circle_3points(pt1, pt2, pt3); c = circle_3points(pt1, pt2, pt3);
assert(!is_undef(c[0]), "Points cannot be collinear."); assert(!is_undef(c[0]), "Points cannot be collinear.");
cp = c[0]; r = c[1]; n = c[2]; cp = c[0]; r = c[1]; n = c[2];
@ -1161,16 +1165,17 @@ module circle_3points(pt1, pt2, pt3, h, center=false) {
// Function: circle_point_tangents() // Function: circle_point_tangents()
// Usage: // Usage:
// tangents = circle_point_tangents(r|d, cp, pt); // tangents = circle_point_tangents(r|d=, cp, pt);
// Topics: Geometry, Circles, Tangents // Topics: Geometry, Circles, Tangents
// Description: // Description:
// Given a 2d circle and a 2d point outside that circle, finds the 2d tangent point(s) on the circle for a // Given a 2d circle and a 2d point outside that circle, finds the 2d tangent point(s) on the circle for a
// line passing through the point. Returns a list of zero or more 2D tangent points. // line passing through the point. Returns a list of zero or more 2D tangent points.
// Arguments: // Arguments:
// r = Radius of the circle. // r = Radius of the circle.
// d = Diameter of the circle.
// cp = The coordinates of the 2d circle centerpoint. // cp = The coordinates of the 2d circle centerpoint.
// pt = The coordinates of the 2d external point. // pt = The coordinates of the 2d external point.
// ---
// d = Diameter of the circle.
// Example(3D): // Example(3D):
// cp = [-10,-10]; r = 30; pt = [30,10]; // cp = [-10,-10]; r = 30; pt = [30,10];
// tanpts = circle_point_tangents(r=r, cp=cp, pt=pt); // tanpts = circle_point_tangents(r=r, cp=cp, pt=pt);
@ -1178,7 +1183,7 @@ module circle_3points(pt1, pt2, pt3, h, center=false) {
// color("cyan") for(tp=tanpts) {stroke([tp,pt]); stroke([tp,cp]);} // color("cyan") for(tp=tanpts) {stroke([tp,pt]); stroke([tp,cp]);}
// color("red") move_copies(tanpts) circle(d=3,$fn=12); // color("red") move_copies(tanpts) circle(d=3,$fn=12);
// color("blue") move_copies([cp,pt]) circle(d=3,$fn=12); // color("blue") move_copies([cp,pt]) circle(d=3,$fn=12);
function circle_point_tangents(r, d, cp, pt) = function circle_point_tangents(r, cp, pt, d) =
assert(is_finite(r) || is_finite(d), "Invalid radius or diameter." ) assert(is_finite(r) || is_finite(d), "Invalid radius or diameter." )
assert(is_path([cp, pt],dim=2), "Invalid center point or external point.") assert(is_path([cp, pt],dim=2), "Invalid center point or external point.")
let( let(
@ -1196,7 +1201,7 @@ function circle_point_tangents(r, d, cp, pt) =
// Function: circle_circle_tangents() // Function: circle_circle_tangents()
// Usage: // Usage:
// segs = circle_circle_tangents(c1, r1|d1, c2, r2|d2); // segs = circle_circle_tangents(c1, r1|d1=, c2, r2|d2=);
// Topics: Geometry, Circles, Tangents // Topics: Geometry, Circles, Tangents
// Description: // Description:
// Computes 2d lines tangents to a pair of circles in 2d. Returns a list of line endpoints [p1,p2] where // Computes 2d lines tangents to a pair of circles in 2d. Returns a list of line endpoints [p1,p2] where
@ -1281,7 +1286,7 @@ function circle_circle_tangents(c1,r1,c2,r2,d1,d2) =
/// Internal Function: _noncollinear_triple() /// Internal Function: _noncollinear_triple()
/// Usage: /// Usage:
/// test = _noncollinear_triple(points); /// bool = _noncollinear_triple(points);
/// Topics: Geometry, Noncollinearity /// Topics: Geometry, Noncollinearity
/// Description: /// Description:
/// Finds the indices of three non-collinear points from the pointlist `points`. /// Finds the indices of three non-collinear points from the pointlist `points`.
@ -1319,11 +1324,9 @@ function _noncollinear_triple(points,error=true,eps=EPSILON) =
// Section: Sphere Calculations // Section: Sphere Calculations
// Function: sphere_line_intersection() // Function: sphere_line_intersection()
// Usage: // Usage:
// isect = sphere_line_intersection(c,<r|d>,[line],[bounded],[eps]); // isect = sphere_line_intersection(c,r|d=,line,[bounded],[eps=]);
// Topics: Geometry, Spheres, Lines, Intersection // Topics: Geometry, Spheres, Lines, Intersection
// Description: // Description:
// Find intersection points between a sphere and a line, ray or segment specified by two points. // Find intersection points between a sphere and a line, ray or segment specified by two points.
@ -1348,7 +1351,7 @@ function sphere_line_intersection(c,r,line,bounded=false,d,eps=EPSILON) =
// Function: polygon_area() // Function: polygon_area()
// Usage: // Usage:
// area = polygon_area(poly); // area = polygon_area(poly, [signed]);
// Topics: Geometry, Polygons, Area // Topics: Geometry, Polygons, Area
// Description: // Description:
// Given a 2D or 3D simple planar polygon, returns the area of that polygon. // Given a 2D or 3D simple planar polygon, returns the area of that polygon.
@ -1474,7 +1477,7 @@ function polygon_normal(poly) =
// Function: point_in_polygon() // Function: point_in_polygon()
// Usage: // Usage:
// test = point_in_polygon(point, poly, [nonzero], [eps]) // bool = point_in_polygon(point, poly, [nonzero], [eps])
// Topics: Geometry, Polygons // Topics: Geometry, Polygons
// Description: // Description:
// This function tests whether the given 2D point is inside, outside or on the boundary of // This function tests whether the given 2D point is inside, outside or on the boundary of
@ -1832,7 +1835,7 @@ function _merge_segments(insegs,outsegs, eps, i=1) =
// report an error for this case. // report an error for this case.
// Arguments: // Arguments:
// poly = Array of the polygon vertices. // poly = Array of the polygon vertices.
// ind = A list indexing the vertices of the polygon in `poly`. // ind = If given, a list of indices indexing the vertices of the polygon in `poly`. Default: use all the points of poly
// error = If false, returns `undef` when the polygon cannot be triangulated; otherwise, issues an assert error. Default: true. // error = If false, returns `undef` when the polygon cannot be triangulated; otherwise, issues an assert error. Default: true.
// eps = A maximum tolerance in geometrical tests. Default: EPSILON // eps = A maximum tolerance in geometrical tests. Default: EPSILON
// Example(2D,NoAxes): a simple polygon; see from above // Example(2D,NoAxes): a simple polygon; see from above
@ -1991,7 +1994,7 @@ function _none_inside(idxs,poly,p0,p1,p2,eps,i=0) =
// Function: is_polygon_clockwise() // Function: is_polygon_clockwise()
// Usage: // Usage:
// test = is_polygon_clockwise(poly); // bool = is_polygon_clockwise(poly);
// Topics: Geometry, Polygons, Clockwise // Topics: Geometry, Polygons, Clockwise
// See Also: clockwise_polygon(), ccw_polygon(), reverse_polygon() // See Also: clockwise_polygon(), ccw_polygon(), reverse_polygon()
// Description: // Description:
@ -2181,7 +2184,7 @@ function align_polygon(reference, poly, angles, cp, trans, return_ind=false) =
// Function: are_polygons_equal() // Function: are_polygons_equal()
// Usage: // Usage:
// b = are_polygons_equal(poly1, poly2, [eps]) // bool = are_polygons_equal(poly1, poly2, [eps])
// Description: // Description:
// Returns true if poly1 and poly2 are the same polongs // Returns true if poly1 and poly2 are the same polongs
// within given epsilon tolerance. // within given epsilon tolerance.
@ -2236,7 +2239,7 @@ function ___is_polygon_in_list(poly, polys, i) =
// Function: hull() // Function: hull()
// Usage: // Usage:
// hull(points); // face_list_or_index_list = hull(points);
// Description: // Description:
// Takes a list of 2D or 3D points (but not both in the same list) and returns either the list of // Takes a list of 2D or 3D points (but not both in the same list) and returns either the list of
// indexes into `points` that forms the 2D convex hull perimeter path, or the list of faces that // indexes into `points` that forms the 2D convex hull perimeter path, or the list of faces that
@ -2272,6 +2275,7 @@ function hull(points) =
// pts = [for (phi = [30:60:150], theta = [0:60:359]) spherical_to_xyz(10, theta, phi)]; // pts = [for (phi = [30:60:150], theta = [0:60:359]) spherical_to_xyz(10, theta, phi)];
// hull_points(pts); // hull_points(pts);
module hull_points(points, fast=false) { module hull_points(points, fast=false) {
no_children($children);
assert(is_path(points)) assert(is_path(points))
assert(len(points)>=3, "Point list must contain 3 points") assert(len(points)>=3, "Point list must contain 3 points")
if (len(points[0])==2) if (len(points[0])==2)
@ -2309,7 +2313,7 @@ function _is_cw(a,b,c,all) =
// Function: hull2d_path() // Function: hull2d_path()
// Usage: // Usage:
// hull2d_path(points,all) // index_list = hull2d_path(points,all)
// Description: // Description:
// Takes a list of arbitrary 2D points, and finds the convex hull polygon to enclose them. // Takes a list of arbitrary 2D points, and finds the convex hull polygon to enclose them.
// Returns a path as a list of indices into `points`. // Returns a path as a list of indices into `points`.
@ -2371,7 +2375,7 @@ function _hull_collinear(points) =
// Function: hull3d_faces() // Function: hull3d_faces()
// Usage: // Usage:
// hull3d_faces(points) // faces = hull3d_faces(points)
// Description: // Description:
// Takes a list of arbitrary 3D points, and finds the convex hull polyhedron to enclose // Takes a list of arbitrary 3D points, and finds the convex hull polyhedron to enclose
// them. Returns a list of triangular faces, where each face is a list of indexes into the given `points` // them. Returns a list of triangular faces, where each face is a list of indexes into the given `points`
@ -2482,7 +2486,7 @@ function _find_first_noncoplanar(plane, points, i=0) =
// Function: is_polygon_convex() // Function: is_polygon_convex()
// Usage: // Usage:
// test = is_polygon_convex(poly); // bool = is_polygon_convex(poly, [eps]);
// Topics: Geometry, Convexity, Test // Topics: Geometry, Convexity, Test
// Description: // Description:
// Returns true if the given 2D or 3D polygon is convex. // Returns true if the given 2D or 3D polygon is convex.
@ -2527,7 +2531,7 @@ function is_polygon_convex(poly,eps=EPSILON) =
// Function: convex_distance() // Function: convex_distance()
// Usage: // Usage:
// dist = convex_distance(pts1, pts2,[eps=]); // dist = convex_distance(points1, points2,eps);
// Topics: Geometry, Convexity, Distance // Topics: Geometry, Convexity, Distance
// See also: // See also:
// convex_collision(), hull() // convex_collision(), hull()
@ -2586,7 +2590,7 @@ function _GJK_distance(points1, points2, eps=EPSILON, lbd, d, simplex=[]) =
// Function: convex_collision() // Function: convex_collision()
// Usage: // Usage:
// test = convex_collision(pts1, pts2, [eps=]); // bool = convex_collision(points1, points2, [eps]);
// Topics: Geometry, Convexity, Collision, Intersection // Topics: Geometry, Convexity, Collision, Intersection
// See also: // See also:
// convex_distance(), hull() // convex_distance(), hull()

View file

@ -12,6 +12,8 @@
// Section: Standard (UTS/ISO) Threading // Section: Standard (UTS/ISO) Threading
// Module: threaded_rod() // Module: threaded_rod()
// Usage:
// threaded_rod(d, l, pitch, [internal=], ...) [ATTACHMENTS];
// Description: // Description:
// Constructs a standard ISO (metric) or UTS (English) threaded rod. These threads are close to triangular, // Constructs a standard ISO (metric) or UTS (English) threaded rod. These threads are close to triangular,
// with a 60 degree thread angle. You can give the outer diameter and get the "basic form" or you can // with a 60 degree thread angle. You can give the outer diameter and get the "basic form" or you can
@ -57,6 +59,16 @@
// threaded_nut(od=4.5/8*INCH,id=d,h=3/8*INCH,pitch=pitch,starts=starts,anchor=BOTTOM); // threaded_nut(od=4.5/8*INCH,id=d,h=3/8*INCH,pitch=pitch,starts=starts,anchor=BOTTOM);
// threaded_nut(od=4.5/8*INCH,id=d,h=3/8*INCH,pitch=pitch,starts=starts,left_handed=true,anchor=BOTTOM); // threaded_nut(od=4.5/8*INCH,id=d,h=3/8*INCH,pitch=pitch,starts=starts,left_handed=true,anchor=BOTTOM);
// } // }
function threaded_rod(
d, l, pitch,
left_handed=false,
bevel,bevel1,bevel2,starts=1,
internal=false,
d1, d2,
higbee, higbee1, higbee2,
anchor, spin, orient
) = no_function("threaded_rod");
module threaded_rod( module threaded_rod(
d, l, pitch, d, l, pitch,
left_handed=false, left_handed=false,
@ -115,6 +127,8 @@ module threaded_rod(
// Module: threaded_nut() // Module: threaded_nut()
// Usage:
// threaded_nut(od, id, h, pitch,...) [ATTACHMENTS];
// Description: // Description:
// Constructs a hex nut for an ISO (metric) or UTS (English) threaded rod. // Constructs a hex nut for an ISO (metric) or UTS (English) threaded rod.
// Arguments: // Arguments:
@ -135,6 +149,11 @@ module threaded_rod(
// Examples(Med): // Examples(Med):
// threaded_nut(od=16, id=8, h=8, pitch=1.25, $slop=0.05, $fa=1, $fs=1); // threaded_nut(od=16, id=8, h=8, pitch=1.25, $slop=0.05, $fa=1, $fs=1);
// threaded_nut(od=16, id=8, h=8, pitch=1.25, left_handed=true, bevel=true, $slop=0.1, $fa=1, $fs=1); // threaded_nut(od=16, id=8, h=8, pitch=1.25, left_handed=true, bevel=true, $slop=0.1, $fa=1, $fs=1);
function threaded_nut(
od, id, h,
pitch, starts=1, left_handed=false, bevel, bevel1, bevel2, id1,id2,
anchor, spin, orient
)=no_function("threaded_nut");
module threaded_nut( module threaded_nut(
od, id, h, od, id, h,
pitch, starts=1, left_handed=false, bevel, bevel1, bevel2, id1,id2, pitch, starts=1, left_handed=false, bevel, bevel1, bevel2, id1,id2,
@ -180,6 +199,8 @@ module threaded_nut(
// Module: trapezoidal_threaded_rod() // Module: trapezoidal_threaded_rod()
// Usage:
// trapezoidal_threaded_rod(d, l, pitch, [thread_angle], [thread_depth], [internal=], ...) [ATTACHMENTS];
// Description: // Description:
// Constructs a threaded rod with a symmetric trapezoidal thread. Trapezoidal threads are used for lead screws because // Constructs a threaded rod with a symmetric trapezoidal thread. Trapezoidal threads are used for lead screws because
// they are one of the strongest symmetric profiles. This tooth shape is stronger than a similarly // they are one of the strongest symmetric profiles. This tooth shape is stronger than a similarly
@ -256,6 +277,17 @@ module threaded_nut(
// cube(50, center=true); // cube(50, center=true);
// trapezoidal_threaded_rod(d=40, l=51, pitch=5, thread_angle=30, internal=true, orient=RIGHT, $fn=36); // trapezoidal_threaded_rod(d=40, l=51, pitch=5, thread_angle=30, internal=true, orient=RIGHT, $fn=36);
// } // }
function trapezoidal_threaded_rod(
d, l, pitch,
thread_angle=30,
thread_depth=undef,
left_handed=false,
bevel,bevel1,bevel2,
starts=1,
internal=false,
higbee, higbee1, higbee2,d1,d2,
center, anchor, spin, orient
) = no_function("trapezoidal_threaded_rod");
module trapezoidal_threaded_rod( module trapezoidal_threaded_rod(
d, l, pitch, d, l, pitch,
thread_angle=30, thread_angle=30,
@ -289,6 +321,8 @@ module trapezoidal_threaded_rod(
// Module: trapezoidal_threaded_nut() // Module: trapezoidal_threaded_nut()
// Usage:
// trapezoidal_threaded_nut(od, id, h, pitch, [thread_angle], [thread_depth], ...) [ATTACHMENTS];
// Description: // Description:
// Constructs a hex nut for a symmetric trapzoidal threaded rod. // Constructs a hex nut for a symmetric trapzoidal threaded rod.
// By default produces the nominal dimensions // By default produces the nominal dimensions
@ -316,6 +350,17 @@ module trapezoidal_threaded_rod(
// trapezoidal_threaded_nut(od=16, id=8, h=8, pitch=2, bevel=true, $slop=0.05, anchor=UP); // trapezoidal_threaded_nut(od=16, id=8, h=8, pitch=2, bevel=true, $slop=0.05, anchor=UP);
// trapezoidal_threaded_nut(od=17.4, id=10, h=10, pitch=2, $slop=0.1, left_handed=true); // trapezoidal_threaded_nut(od=17.4, id=10, h=10, pitch=2, $slop=0.1, left_handed=true);
// trapezoidal_threaded_nut(od=17.4, id=10, h=10, pitch=2, starts=3, $fa=1, $fs=1, $slop=0.15); // trapezoidal_threaded_nut(od=17.4, id=10, h=10, pitch=2, starts=3, $fa=1, $fs=1, $slop=0.15);
function trapezoidal_threaded_rod(
d, l, pitch,
thread_angle=30,
thread_depth=undef,
left_handed=false,
bevel,bevel1,bevel2,
starts=1,
internal=false,
higbee, higbee1, higbee2,d1,d2,
center, anchor, spin, orient
) = no_function("trapezoidal_threaded_nut");
module trapezoidal_threaded_nut( module trapezoidal_threaded_nut(
od, od,
id, id,
@ -350,6 +395,8 @@ module trapezoidal_threaded_nut(
// Module: acme_threaded_rod() // Module: acme_threaded_rod()
// Usage:
// acme_threaded_rod(d, l, tpi|pitch=, [internal=], ...) [ATTACHMENTS];
// Description: // Description:
// Constructs an ACME trapezoidal threaded screw rod. This form has a 29 degree thread angle with a // Constructs an ACME trapezoidal threaded screw rod. This form has a 29 degree thread angle with a
// symmetric trapezoidal thread. // symmetric trapezoidal thread.
@ -378,6 +425,15 @@ module trapezoidal_threaded_nut(
// Examples(Med): // Examples(Med):
// acme_threaded_rod(d=3/8*INCH, l=20, pitch=1/8*INCH, $fn=32); // acme_threaded_rod(d=3/8*INCH, l=20, pitch=1/8*INCH, $fn=32);
// acme_threaded_rod(d=10, l=30, pitch=2, starts=3, $fa=1, $fs=1); // acme_threaded_rod(d=10, l=30, pitch=2, starts=3, $fa=1, $fs=1);
function acme_threaded_rod(
d, l, tpi, pitch,
starts=1,
left_handed=false,
bevel,bevel1,bevel2,
internal=false,
higbee, higbee1, higbee2,
anchor, spin, orient
) = no_function("acme_threaded_rod");
module acme_threaded_rod( module acme_threaded_rod(
d, l, tpi, pitch, d, l, tpi, pitch,
starts=1, starts=1,
@ -406,6 +462,8 @@ module acme_threaded_rod(
// Module: acme_threaded_nut() // Module: acme_threaded_nut()
// Usage:
// acme_threaded_nut(od, id, h, tpi|pitch=, ...) [ATTACHMENTS];
// Description: // Description:
// Constructs a hex nut for an ACME threaded screw rod. // Constructs a hex nut for an ACME threaded screw rod.
// Arguments: // Arguments:
@ -426,6 +484,13 @@ module acme_threaded_rod(
// Examples(Med): // Examples(Med):
// acme_threaded_nut(od=16, id=3/8*INCH, h=8, tpi=8, $slop=0.05); // acme_threaded_nut(od=16, id=3/8*INCH, h=8, tpi=8, $slop=0.05);
// acme_threaded_nut(od=16, id=1/2*INCH, h=10, tpi=12, starts=3, $slop=0.1, $fa=1, $fs=1); // acme_threaded_nut(od=16, id=1/2*INCH, h=10, tpi=12, starts=3, $slop=0.1, $fa=1, $fs=1);
function acme_threaded_nut(
od, id, h, tpi, pitch,
starts=1,
left_handed=false,
bevel,bevel1,bevel2,
anchor, spin, orient
) = no_function("acme_threaded_nut");
module acme_threaded_nut( module acme_threaded_nut(
od, id, h, tpi, pitch, od, id, h, tpi, pitch,
starts=1, starts=1,
@ -455,6 +520,8 @@ module acme_threaded_nut(
// Section: Pipe Threading // Section: Pipe Threading
// Module: npt_threaded_rod() // Module: npt_threaded_rod()
// Usage:
// npt_threaded_rod(size, [internal=], ...) [ATTACHMENTS];
// Description: // Description:
// Constructs a standard NPT pipe end threading. If `internal=true`, creates a mask for making // Constructs a standard NPT pipe end threading. If `internal=true`, creates a mask for making
// internal pipe threads. Tapers smaller upwards if `internal=false`. Tapers smaller downwards // internal pipe threads. Tapers smaller upwards if `internal=false`. Tapers smaller downwards
@ -490,6 +557,14 @@ module acme_threaded_nut(
// cyl(d=3/4*INCH, l=42, $fn=32); // cyl(d=3/4*INCH, l=42, $fn=32);
// } // }
// } // }
function npt_threaded_rod(
size=1/2,
left_handed=false,
bevel,bevel1,bevel2,
hollow=false,
internal=false,
anchor, spin, orient
)=no_function("npt_threaded_rod");
module npt_threaded_rod( module npt_threaded_rod(
size=1/2, size=1/2,
left_handed=false, left_handed=false,
@ -564,6 +639,8 @@ module npt_threaded_rod(
// Section: Buttress Threading // Section: Buttress Threading
// Module: buttress_threaded_rod() // Module: buttress_threaded_rod()
// Usage:
// buttress_threaded_rod(d, l, pitch, [internal=], ...) [ATTACHMENTS];
// Description: // Description:
// Constructs a simple buttress threaded rod with a 45 degree angle. The buttress thread or sawtooth thread has low friction and high loading // Constructs a simple buttress threaded rod with a 45 degree angle. The buttress thread or sawtooth thread has low friction and high loading
// in one direction at the cost of higher friction and inferior loading in the other direction. Buttress threads are sometimes used on // in one direction at the cost of higher friction and inferior loading in the other direction. Buttress threads are sometimes used on
@ -593,6 +670,17 @@ module npt_threaded_rod(
// Examples(Med): // Examples(Med):
// buttress_threaded_rod(d=10, l=20, pitch=1.25, left_handed=true, $fa=1, $fs=1); // buttress_threaded_rod(d=10, l=20, pitch=1.25, left_handed=true, $fa=1, $fs=1);
// buttress_threaded_rod(d=25, l=20, pitch=2, $fa=1, $fs=1); // buttress_threaded_rod(d=25, l=20, pitch=2, $fa=1, $fs=1);
function buttress_threaded_rod(
d=10, l=100, pitch=2,
left_handed=false,
bevel,bevel1,bevel2,
internal=false,
higbee=0,
higbee1,
higbee2,
d1,d2,
anchor, spin, orient
) = no_function("buttress_threaded_rod");
module buttress_threaded_rod( module buttress_threaded_rod(
d=10, l=100, pitch=2, d=10, l=100, pitch=2,
left_handed=false, left_handed=false,
@ -631,6 +719,8 @@ module buttress_threaded_rod(
// Module: buttress_threaded_nut() // Module: buttress_threaded_nut()
// Usage:
// buttress_threaded_nut(od, id, h, pitch, ...) [ATTACHMENTS];
// Description: // Description:
// Constructs a hex nut for a simple buttress threaded screw rod. // Constructs a hex nut for a simple buttress threaded screw rod.
// Arguments: // Arguments:
@ -649,6 +739,12 @@ module buttress_threaded_rod(
// $slop = The printer-specific slop value, which adds clearance (`4*$slop`) to internal threads. // $slop = The printer-specific slop value, which adds clearance (`4*$slop`) to internal threads.
// Examples(Med): // Examples(Med):
// buttress_threaded_nut(od=16, id=8, h=8, pitch=1.25, left_handed=true, $slop=0.05, $fa=1, $fs=1); // buttress_threaded_nut(od=16, id=8, h=8, pitch=1.25, left_handed=true, $slop=0.05, $fa=1, $fs=1);
function buttress_threaded_nut(
od=16, id=10, h=10,
pitch=2, left_handed=false,
bevel,bevel1,bevel2,
anchor, spin, orient
) = no_function("buttress_threaded_nut");
module buttress_threaded_nut( module buttress_threaded_nut(
od=16, id=10, h=10, od=16, id=10, h=10,
pitch=2, left_handed=false, pitch=2, left_handed=false,
@ -679,6 +775,8 @@ module buttress_threaded_nut(
// Section: Square Threading // Section: Square Threading
// Module: square_threaded_rod() // Module: square_threaded_rod()
// Usage:
// square_threaded_rod(d, l, pitch, [internal=], ...) [ATTACHMENTS];
// Description: // Description:
// Constructs a square profile threaded screw rod. The greatest advantage of square threads is that they have the least friction and a much higher intrinsic efficiency than trapezoidal threads. // Constructs a square profile threaded screw rod. The greatest advantage of square threads is that they have the least friction and a much higher intrinsic efficiency than trapezoidal threads.
// They produce no radial load on the nut. However, square threads cannot carry as much load as trapezoidal threads. // They produce no radial load on the nut. However, square threads cannot carry as much load as trapezoidal threads.
@ -707,6 +805,16 @@ module buttress_threaded_nut(
// square_threaded_rod(d=10, l=15, pitch=2, orient=BACK); // square_threaded_rod(d=10, l=15, pitch=2, orient=BACK);
// Examples(Med): // Examples(Med):
// square_threaded_rod(d=10, l=20, pitch=2, starts=2, $fn=32); // square_threaded_rod(d=10, l=20, pitch=2, starts=2, $fn=32);
function square_threaded_rod(
d, l, pitch,
left_handed=false,
bevel,bevel1,bevel2,
starts=1,
internal=false,
higbee=0, higbee1, higbee2,
d1,d2,
anchor, spin, orient
) = no_function("square_threaded_rod");
module square_threaded_rod( module square_threaded_rod(
d, l, pitch, d, l, pitch,
left_handed=false, left_handed=false,
@ -738,6 +846,8 @@ module square_threaded_rod(
// Module: square_threaded_nut() // Module: square_threaded_nut()
// Usage:
// square_threaded_nut(od, id, h, pitch, ...) [ATTACHMENTS];
// Description: // Description:
// Constructs a hex nut for a square profile threaded screw rod. // Constructs a hex nut for a square profile threaded screw rod.
// Arguments: // Arguments:
@ -757,6 +867,14 @@ module square_threaded_rod(
// $slop = The printer-specific slop value, which adds clearance (`4*$slop`) to internal threads. // $slop = The printer-specific slop value, which adds clearance (`4*$slop`) to internal threads.
// Examples(Med): // Examples(Med):
// square_threaded_nut(od=16, id=10, h=10, pitch=2, starts=2, $slop=0.1, $fn=32); // square_threaded_nut(od=16, id=10, h=10, pitch=2, starts=2, $slop=0.1, $fn=32);
function square_threaded_nut(
od, id, h,
pitch,
left_handed=false,
bevel,bevel1,bevel2,
starts=1,
anchor, spin, orient
) = no_function("square_threaded_nut");
module square_threaded_nut( module square_threaded_nut(
od, id, h, od, id, h,
pitch, pitch,
@ -782,6 +900,8 @@ module square_threaded_nut(
// Section: Ball Screws // Section: Ball Screws
// Module: ball_screw_rod() // Module: ball_screw_rod()
// Usage:
// ball_screw_rod(d, l, pitch, [ball_diam], [ball_arc], [internal=], ...) [ATTACHMENTS];
// Description: // Description:
// Constructs a ball screw rod. This type of rod is used with ball bearings. // Constructs a ball screw rod. This type of rod is used with ball bearings.
// Arguments: // Arguments:
@ -811,6 +931,15 @@ module square_threaded_nut(
// ball_screw_rod(d=15, l=20, pitch=8, ball_diam=5, ball_arc=120, $fa=1, $fs=0.5); // ball_screw_rod(d=15, l=20, pitch=8, ball_diam=5, ball_arc=120, $fa=1, $fs=0.5);
// ball_screw_rod(d=15, l=20, pitch=5, ball_diam=4, ball_arc=120, $fa=1, $fs=0.5); // ball_screw_rod(d=15, l=20, pitch=5, ball_diam=4, ball_arc=120, $fa=1, $fs=0.5);
// ball_screw_rod(d=15, l=20, pitch=5, ball_diam=4, ball_arc=120, left_handed=true, $fa=1, $fs=0.5); // ball_screw_rod(d=15, l=20, pitch=5, ball_diam=4, ball_arc=120, left_handed=true, $fa=1, $fs=0.5);
function ball_screw_rod(
d, l, pitch,
ball_diam=5, ball_arc=100,
starts=1,
left_handed=false,
internal=false,
bevel,bevel1,bevel2,
anchor, spin, orient
) = no_function("ball_screw_rod");
module ball_screw_rod( module ball_screw_rod(
d, l, pitch, d, l, pitch,
ball_diam=5, ball_arc=100, ball_diam=5, ball_arc=100,
@ -846,6 +975,8 @@ module ball_screw_rod(
// Section: Generic Threading // Section: Generic Threading
// Module: generic_threaded_rod() // Module: generic_threaded_rod()
// Usage:
// generic_threaded_rod(d, l, pitch, profile, [internal=], ...) [ATTACHMENTS];
// Description: // Description:
// Constructs a generic threaded rod using an arbitrary thread profile that you supply. The rod can be tapered (e.g. for pipe threads). // Constructs a generic threaded rod using an arbitrary thread profile that you supply. The rod can be tapered (e.g. for pipe threads).
// For specific thread types use other modules that supply the appropriate profile. // For specific thread types use other modules that supply the appropriate profile.
@ -911,6 +1042,17 @@ module ball_screw_rod(
// [ 7/16, -depth/pitch*1.07] // [ 7/16, -depth/pitch*1.07]
// ]; // ];
// generic_threaded_rod(d=10, l=40, pitch=2, profile=profile); // generic_threaded_rod(d=10, l=40, pitch=2, profile=profile);
function generic_threaded_rod(
d, l, pitch, profile,
left_handed=false,
bevel,
bevel1, bevel2,
starts=1,
internal=false,
d1, d2,
higbee, higbee1, higbee2,
center, anchor, spin, orient
) = no_function("generic_threaded_rod");
module generic_threaded_rod( module generic_threaded_rod(
d, l, pitch, profile, d, l, pitch, profile,
left_handed=false, left_handed=false,
@ -1062,6 +1204,8 @@ module generic_threaded_rod(
// Module: generic_threaded_nut() // Module: generic_threaded_nut()
// Usage:
// generic_threaded_nut(od, id, h, pitch, profile, ...) [ATTACHMENTS];
// Description: // Description:
// Constructs a hexagonal nut for an generic threaded rod using a user-supplied thread profile. // Constructs a hexagonal nut for an generic threaded rod using a user-supplied thread profile.
// See generic_threaded_rod for details on the profile specification. // See generic_threaded_rod for details on the profile specification.
@ -1083,6 +1227,18 @@ module generic_threaded_rod(
// spin = Rotate this many degrees around the Z axis after anchor. See [spin](attachments.scad#subsection-spin). Default: `0` // 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` // orient = Vector to rotate top towards, after spin. See [orient](attachments.scad#subsection-orient). Default: `UP`
// $slop = The printer-specific slop value, which adds clearance (`4*$slop`) to internal threads. // $slop = The printer-specific slop value, which adds clearance (`4*$slop`) to internal threads.
function generic_threaded_nut(
od,
id,
h,
pitch,
profile,
left_handed=false,
starts=1,
bevel,bevel1,bevel2,
id1,id2,
anchor, spin, orient
) = no_function("generic_threaded_nut");
module generic_threaded_nut( module generic_threaded_nut(
od, od,
id, id,
@ -1208,6 +1364,12 @@ module generic_threaded_nut(
// thread_helix(d=10, pitch=2, thread_depth=0.75, flank_angle=15, turns=2.5, higbee=1, $fn=72); // thread_helix(d=10, pitch=2, thread_depth=0.75, flank_angle=15, turns=2.5, higbee=1, $fn=72);
// thread_helix(d=10, pitch=2, thread_depth=0.75, flank_angle=15, turns=2, higbee=2, internal=true, $fn=72); // thread_helix(d=10, pitch=2, thread_depth=0.75, flank_angle=15, turns=2, higbee=2, internal=true, $fn=72);
// thread_helix(d=10, pitch=2, thread_depth=0.75, flank_angle=15, turns=1, left_handed=true, higbee=1, $fn=36); // thread_helix(d=10, pitch=2, thread_depth=0.75, flank_angle=15, turns=1, left_handed=true, higbee=1, $fn=36);
function thread_helix(
d, pitch, thread_depth, flank_angle, turns=2,
profile, starts=1, left_handed=false, internal=false,
d1, d2, higbee, higbee1, higbee2,
anchor, spin, orient
) = no_function("thread_helix");
module thread_helix( module thread_helix(
d, pitch, thread_depth, flank_angle, turns=2, d, pitch, thread_depth, flank_angle, turns=2,
profile, starts=1, left_handed=false, internal=false, profile, starts=1, left_handed=false, internal=false,

View file

@ -17,13 +17,14 @@
// Function: is_vector() // Function: is_vector()
// Usage: // Usage:
// is_vector(v, [length], ...); // bool = is_vector(v, [length], [zero=], [all_nonzero=], [eps=]);
// Description: // Description:
// Returns true if v is a list of finite numbers. // Returns true if v is a list of finite numbers.
// Arguments: // Arguments:
// v = The value to test to see if it is a vector. // v = The value to test to see if it is a vector.
// length = If given, make sure the vector is `length` items long. // length = If given, make sure the vector is `length` items long.
// zero = If false, require that the length/`norm()` of the vector is not approximately zero. If true, require the length/`norm()` of the vector to be approximately zero-length. Default: `undef` (don't check vector length/`norm()`.) // ---
// zero = If false, require that the `norm()` of the vector is not approximately zero. If true, require the `norm()` of the vector to be approximately zero. Default: `undef` (don't check vector `norm()`.)
// all_nonzero = If true, requires all elements of the vector to be more than `eps` different from zero. Default: `false` // all_nonzero = If true, requires all elements of the vector to be more than `eps` different from zero. Default: `false`
// eps = The minimum vector length that is considered non-zero. Default: `EPSILON` (`1e-9`) // eps = The minimum vector length that is considered non-zero. Default: `EPSILON` (`1e-9`)
// Example: // Example:
@ -73,7 +74,8 @@ function add_scalar(v,s) =
// v3 = v_mul(v1, v2); // v3 = v_mul(v1, v2);
// Description: // Description:
// Element-wise multiplication. Multiplies each element of `v1` by the corresponding element of `v2`. // 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. // Both `v1` and `v2` must be the same length. Returns a vector of the products. Note that
// the items in `v1` and `v2` can be anything that OpenSCAD will multiply.
// Arguments: // Arguments:
// v1 = The first vector. // v1 = The first vector.
// v2 = The second vector. // v2 = The second vector.
@ -135,7 +137,7 @@ function v_ceil(v) =
// Function: v_lookup() // Function: v_lookup()
// Usage: // Usage:
// v2 = v_ceil(x, v); // v2 = v_lookup(x, v);
// Description: // 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. // 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: // Arguments: