mirror of
https://github.com/revarbat/BOSL2.git
synced 2025-08-14 19:34:11 +02:00
Merge pull request #1569 from adrianVmariano/master
vnf doc fixes, vnf bounds & restore() bugfix
This commit is contained in:
@@ -5061,7 +5061,7 @@ module restore(desc)
|
|||||||
req_children($children);
|
req_children($children);
|
||||||
if (is_undef(desc)){
|
if (is_undef(desc)){
|
||||||
T = matrix_inverse($transform);
|
T = matrix_inverse($transform);
|
||||||
$parent_geom = ["prismoid", [CTR, UP, 0]];
|
$parent_geom = attach_geom([0,0,0]);
|
||||||
multmatrix(T) children();
|
multmatrix(T) children();
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
@@ -370,7 +370,7 @@ function vector_perp(v,w) =
|
|||||||
// Function: pointlist_bounds()
|
// Function: pointlist_bounds()
|
||||||
// Synopsis: Returns the min and max bounding coordinates for the given list of points.
|
// Synopsis: Returns the min and max bounding coordinates for the given list of points.
|
||||||
// Topics: Geometry, Bounding Boxes, Bounds
|
// Topics: Geometry, Bounding Boxes, Bounds
|
||||||
// See Also: closest_point()
|
// See Also: closest_point(), vnf_bounds()
|
||||||
// Usage:
|
// Usage:
|
||||||
// pt_pair = pointlist_bounds(pts);
|
// pt_pair = pointlist_bounds(pts);
|
||||||
// Description:
|
// Description:
|
||||||
|
37
vnf.scad
37
vnf.scad
@@ -1245,6 +1245,8 @@ module vnf_wireframe(vnf, width=1)
|
|||||||
|
|
||||||
// Section: Operations on VNFs
|
// Section: Operations on VNFs
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Function: vnf_volume()
|
// Function: vnf_volume()
|
||||||
// Synopsis: Returns the volume of a VNF.
|
// Synopsis: Returns the volume of a VNF.
|
||||||
// Topics: VNF Manipulation
|
// Topics: VNF Manipulation
|
||||||
@@ -1305,6 +1307,29 @@ function _vnf_centroid(vnf,eps=EPSILON) =
|
|||||||
assert(!approx(pos[0],0, eps), "The vnf has self-intersections.")
|
assert(!approx(pos[0],0, eps), "The vnf has self-intersections.")
|
||||||
pos[1]/pos[0]/4;
|
pos[1]/pos[0]/4;
|
||||||
|
|
||||||
|
// Function: vnf_bounds()
|
||||||
|
// Synopsis: Returns the min and max bounding coordinates for the VNF.
|
||||||
|
// Topics: VNF Manipulation, Bounding Boxes, Bounds
|
||||||
|
// See Also: pointlist_bounds()
|
||||||
|
// Usage:
|
||||||
|
// min_max = vnf_bounds(vnf, [fast]);
|
||||||
|
// Description:
|
||||||
|
// Finds the bounds of the VNF. By default the calculation skips any points listed in the VNF vertex list
|
||||||
|
// that are not used by the VNF. However, this calculation may be slow on large VNFS. If you set `fast=true`
|
||||||
|
// then the calculation uses all the points listed in the VNF, regardless of whether they appear in the
|
||||||
|
// actual object. The returned list has the form `[[MINX, MINY, MINZ], [MAXX, MAXY, MAXZ]]`.
|
||||||
|
// Arguments:
|
||||||
|
// vnf = vnf to get the bounds of
|
||||||
|
// fast = if true then ignore face data and process all vertices; if false only look at vertices actually used in the geometry. Default: false
|
||||||
|
// Example:
|
||||||
|
// echo(vnf_bounds(cube([2,3,4],center=true))); // Displays [[-1, -1.5, -2], [1, 1.5, 2]]
|
||||||
|
function vnf_bounds(vnf,fast=false) =
|
||||||
|
assert(is_vnf(vnf), "Invalid VNF")
|
||||||
|
fast ? pointlist_bounds(vnf[0])
|
||||||
|
: let(
|
||||||
|
vert = vnf[0]
|
||||||
|
)
|
||||||
|
pointlist_bounds([for(face=vnf[1]) each select(vert,face)]);
|
||||||
|
|
||||||
// Function: projection()
|
// Function: projection()
|
||||||
// Synopsis: Returns projection or intersection of vnf with XY plane
|
// Synopsis: Returns projection or intersection of vnf with XY plane
|
||||||
@@ -1690,9 +1715,10 @@ function vnf_bend(vnf,r,d,axis="Z") =
|
|||||||
|
|
||||||
// Function&Module: vnf_hull()
|
// Function&Module: vnf_hull()
|
||||||
// Synopsis: Compute convex hull of VNF or 3d path
|
// Synopsis: Compute convex hull of VNF or 3d path
|
||||||
// Usage:
|
// Usage: (as a function)
|
||||||
// vnf_hull = hull_vnf(vnf);
|
// vnf_hull = hull_vnf(vnf);
|
||||||
// hull_vnf(vnf,[fast]);
|
// Usage: (as a module)
|
||||||
|
// vnf_hull(vnf,[fast]);
|
||||||
// Description:
|
// Description:
|
||||||
// Given a VNF or a list of 3d points, compute the convex hull
|
// Given a VNF or a list of 3d points, compute the convex hull
|
||||||
// and return it as a VNF. This differs from {{hull()}} and {{hull3d_faces()}}, which
|
// and return it as a VNF. This differs from {{hull()}} and {{hull3d_faces()}}, which
|
||||||
@@ -1701,6 +1727,10 @@ function vnf_bend(vnf,r,d,axis="Z") =
|
|||||||
// VNF, which may be many more points than are needed to represent the convex hull.
|
// VNF, which may be many more points than are needed to represent the convex hull.
|
||||||
// This is not usually a problem, but you can run the somewhat slow {{vnf_drop_unused_points()}}
|
// This is not usually a problem, but you can run the somewhat slow {{vnf_drop_unused_points()}}
|
||||||
// function to fix this if necessary.
|
// function to fix this if necessary.
|
||||||
|
// .
|
||||||
|
// If you call this as a module with a VNF it invokes hull() on the polyhedron described by the VNF.
|
||||||
|
// The `fast` argument is ignored in this case. If you call this as a module on a list of points then
|
||||||
|
// it calls {{hull_points()}} and passes the `fast` argument.
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// region = region or path listing points to compute the hull from.
|
// region = region or path listing points to compute the hull from.
|
||||||
// fast = (module only) if input is a point list (not a VNF) use a fasterer cheat that may handle more points, but could emit warnings. Ignored if input is a VNF. Default: false.
|
// fast = (module only) if input is a point list (not a VNF) use a fasterer cheat that may handle more points, but could emit warnings. Ignored if input is a VNF. Default: false.
|
||||||
@@ -1718,6 +1748,9 @@ function vnf_bend(vnf,r,d,axis="Z") =
|
|||||||
// color("red")move_copies(h)
|
// color("red")move_copies(h)
|
||||||
// sphere(r=0.5,$fn=12);
|
// sphere(r=0.5,$fn=12);
|
||||||
// vnf_polyhedron(vnf_hull(h));
|
// vnf_polyhedron(vnf_hull(h));
|
||||||
|
// Example(3D): As a module with a VNF as input
|
||||||
|
// vnf = torus(d_maj=4, d_min=4);
|
||||||
|
// vnf_hull(vnf);
|
||||||
function vnf_hull(vnf) =
|
function vnf_hull(vnf) =
|
||||||
assert(is_vnf(vnf) || is_path(vnf,3),"Input must be a VNF or a 3d path")
|
assert(is_vnf(vnf) || is_path(vnf,3),"Input must be a VNF or a 3d path")
|
||||||
let(
|
let(
|
||||||
|
Reference in New Issue
Block a user