mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-01-01 09:49:45 +00:00
Revert "Merge remote-tracking branch 'upstream/revarbat_dev'"
This reverts commitee80b1d08f
, reversing changes made to2b12659d00
.
This commit is contained in:
parent
ee80b1d08f
commit
f4a8138b37
5 changed files with 41 additions and 80 deletions
|
@ -458,9 +458,10 @@ function find_anchor(anchor, geom) =
|
||||||
eps = 1/2048,
|
eps = 1/2048,
|
||||||
points = vnf[0],
|
points = vnf[0],
|
||||||
faces = vnf[1],
|
faces = vnf[1],
|
||||||
rpts = apply(rot(from=anchor, to=RIGHT) * move(point3d(-cp)), points),
|
rpts = rot(from=anchor, to=RIGHT, p=move(point3d(-cp), p=points)),
|
||||||
hits = [
|
hits = [
|
||||||
for (face = faces) let(
|
for (i = idx(faces)) let(
|
||||||
|
face = faces[i],
|
||||||
verts = select(rpts, face)
|
verts = select(rpts, face)
|
||||||
) if (
|
) if (
|
||||||
max(subindex(verts,0)) >= -eps &&
|
max(subindex(verts,0)) >= -eps &&
|
||||||
|
@ -469,40 +470,35 @@ function find_anchor(anchor, geom) =
|
||||||
min(subindex(verts,1)) <= eps &&
|
min(subindex(verts,1)) <= eps &&
|
||||||
min(subindex(verts,2)) <= eps
|
min(subindex(verts,2)) <= eps
|
||||||
) let(
|
) let(
|
||||||
poly = select(points, face),
|
pt = polygon_line_intersection(
|
||||||
pt = polygon_line_intersection(poly, [cp,cp+anchor], bounded=[true,false], eps=eps)
|
select(points, face),
|
||||||
) if (!is_undef(pt)) let(
|
[CENTER,anchor], eps=eps
|
||||||
plane = plane_from_polygon(poly),
|
)
|
||||||
n = unit(plane_normal(plane))
|
) if (!is_undef(pt)) [norm(pt), i, pt]
|
||||||
)
|
|
||||||
[norm(pt-cp), n, pt]
|
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
assert(len(hits)>0, "Anchor vector does not intersect with the shape. Attachment failed.")
|
assert(len(hits)>0, "Anchor vector does not intersect with the shape. Attachment failed.")
|
||||||
let(
|
let(
|
||||||
furthest = max_index(subindex(hits,0)),
|
furthest = max_index(subindex(hits,0)),
|
||||||
|
pos = point3d(cp) + hits[furthest][2],
|
||||||
dist = hits[furthest][0],
|
dist = hits[furthest][0],
|
||||||
pos = hits[furthest][2],
|
nfaces = [for (hit = hits) if(approx(hit[0],dist,eps=eps)) hit[1]],
|
||||||
hitnorms = [for (hit = hits) if (approx(hit[0],dist,eps=eps)) hit[1]],
|
n = unit(
|
||||||
unorms = len(hitnorms) > 7
|
sum([
|
||||||
? unique([for (nn = hitnorms) quant(nn,1e-9)])
|
for (i = nfaces) let(
|
||||||
: [
|
faceverts = select(points, faces[i]),
|
||||||
for (i = idx(hitnorms)) let(
|
faceplane = plane_from_points(faceverts),
|
||||||
nn = hitnorms[i],
|
nrm = plane_normal(faceplane)
|
||||||
isdup = [
|
) nrm
|
||||||
for (j = [i+1:1:len(hitnorms)-1])
|
]) / len(nfaces),
|
||||||
if (approx(nn, hitnorms[j])) 1
|
UP
|
||||||
] != []
|
)
|
||||||
) if (!isdup) nn
|
|
||||||
],
|
|
||||||
n = unit(sum(unorms)),
|
|
||||||
oang = approx(point2d(n), [0,0])? 0 : atan2(n.y, n.x) + 90
|
|
||||||
)
|
)
|
||||||
[anchor, pos, n, oang]
|
[anchor, pos, n, oang]
|
||||||
) : type == "vnf_extent"? ( //vnf
|
) : type == "vnf_extent"? ( //vnf
|
||||||
let(
|
let(
|
||||||
vnf=geom[1],
|
vnf=geom[1],
|
||||||
rpts = apply(rot(from=anchor, to=RIGHT) * move(point3d(-cp)), vnf[0]),
|
rpts = rot(from=anchor, to=RIGHT, p=move(point3d(-cp), p=vnf[0])),
|
||||||
maxx = max(subindex(rpts,0)),
|
maxx = max(subindex(rpts,0)),
|
||||||
idxs = [for (i = idx(rpts)) if (approx(rpts[i].x, maxx)) i],
|
idxs = [for (i = idx(rpts)) if (approx(rpts[i].x, maxx)) i],
|
||||||
mm = pointlist_bounds(select(rpts,idxs)),
|
mm = pointlist_bounds(select(rpts,idxs)),
|
||||||
|
@ -853,7 +849,7 @@ module attachable(
|
||||||
|
|
||||||
// Module: position()
|
// Module: position()
|
||||||
// Usage:
|
// Usage:
|
||||||
// position(from) ...
|
// position(from, [overlap]) ...
|
||||||
// Description:
|
// Description:
|
||||||
// Attaches children to a parent object at an anchor point.
|
// Attaches children to a parent object at an anchor point.
|
||||||
// Arguments:
|
// Arguments:
|
||||||
|
|
|
@ -1962,4 +1962,4 @@ module bent_cutout_mask(r, thickness, path, convexity=10)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|
// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|
||||||
|
|
|
@ -102,8 +102,8 @@ module cuboid(
|
||||||
if (edges == EDGES_ALL && trimcorners) {
|
if (edges == EDGES_ALL && trimcorners) {
|
||||||
if (chamfer<0) {
|
if (chamfer<0) {
|
||||||
cube(size, center=true) {
|
cube(size, center=true) {
|
||||||
attach(TOP,overlap=0) prismoid([size.x,size.y], [size.x-2*chamfer,size.y-2*chamfer], h=-chamfer, anchor=TOP);
|
attach(TOP) prismoid([size.x,size.y], [size.x-2*chamfer,size.y-2*chamfer], h=-chamfer, anchor=TOP);
|
||||||
attach(BOT,overlap=0) prismoid([size.x,size.y], [size.x-2*chamfer,size.y-2*chamfer], h=-chamfer, anchor=TOP);
|
attach(BOT) prismoid([size.x,size.y], [size.x-2*chamfer,size.y-2*chamfer], h=-chamfer, anchor=TOP);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
isize = [for (v = size) max(0.001, v-2*chamfer)];
|
isize = [for (v = size) max(0.001, v-2*chamfer)];
|
||||||
|
|
65
skin.scad
65
skin.scad
|
@ -16,8 +16,7 @@ include <vnf.scad>
|
||||||
|
|
||||||
// Function&Module: skin()
|
// Function&Module: skin()
|
||||||
// Usage: As module:
|
// Usage: As module:
|
||||||
// skin(profiles, [slices], [refine], [method], [sampling], [caps], [closed], [z], [convexity],
|
// skin(profiles, [slices], [refine], [method], [sampling], [caps], [closed], [z]);
|
||||||
// [anchor],[cp],[spin],[orient],[extent]);
|
|
||||||
// Usage: As function:
|
// Usage: As function:
|
||||||
// vnf = skin(profiles, [slices], [refine], [method], [sampling], [caps], [closed], [z]);
|
// vnf = skin(profiles, [slices], [refine], [method], [sampling], [caps], [closed], [z]);
|
||||||
// Description:
|
// Description:
|
||||||
|
@ -118,12 +117,6 @@ include <vnf.scad>
|
||||||
// caps = true to create endcap faces when closed is false. Can be a length 2 boolean array. Default is true if closed is false.
|
// caps = true to create endcap faces when closed is false. Can be a length 2 boolean array. Default is true if closed is false.
|
||||||
// method = method for connecting profiles, one of "distance", "tangent", "direct" or "reindex". Default: "direct".
|
// method = method for connecting profiles, one of "distance", "tangent", "direct" or "reindex". Default: "direct".
|
||||||
// z = array of height values for each profile if the profiles are 2d
|
// z = array of height values for each profile if the profiles are 2d
|
||||||
// convexity = convexity setting for use with polyhedron. (module only) Default: 10
|
|
||||||
// anchor = Translate so anchor point is at the origin. (module only) Default: "origin"
|
|
||||||
// spin = Rotate this many degrees around Z axis after anchor. (module only) Default: 0
|
|
||||||
// orient = Vector to rotate top towards after spin (module only)
|
|
||||||
// extent = use extent method for computing anchors. (module only) Default: false
|
|
||||||
// cp = set centerpoint for anchor computation. (module only) Default: object centroid
|
|
||||||
// Example:
|
// Example:
|
||||||
// skin([octagon(4), circle($fn=70,r=2)], z=[0,3], slices=10);
|
// skin([octagon(4), circle($fn=70,r=2)], z=[0,3], slices=10);
|
||||||
// Example: Rotating the pentagon place the zero index at different locations, giving a twist
|
// Example: Rotating the pentagon place the zero index at different locations, giving a twist
|
||||||
|
@ -322,15 +315,11 @@ include <vnf.scad>
|
||||||
// stroke(zrot(30, p=yscale(0.5, p=circle(d=120))),width=10,closed=true);
|
// stroke(zrot(30, p=yscale(0.5, p=circle(d=120))),width=10,closed=true);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
module skin(profiles, slices, refine=1, method="direct", sampling, caps, closed=false, z, convexity=10,
|
|
||||||
anchor="origin",cp,spin=0, orient=UP, extent=false)
|
|
||||||
|
module skin(profiles, slices, refine=1, method="direct", sampling, caps, closed=false, z, convexity=10)
|
||||||
{
|
{
|
||||||
vnf = skin(profiles, slices, refine, method, sampling, caps, closed, z);
|
vnf_polyhedron(skin(profiles, slices, refine, method, sampling, caps, closed, z), convexity=convexity);
|
||||||
attachable(anchor=anchor, spin=spin, orient=orient, vnf=vnf, extent=extent, cp=is_def(cp) ? cp : vnf_centroid(vnf))
|
|
||||||
{
|
|
||||||
vnf_polyhedron(vnf,convexity=convexity);
|
|
||||||
children();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -814,12 +803,6 @@ function associate_vertices(polygons, split, curpoly=0) =
|
||||||
// transformations = list of 4x4 matrices to apply
|
// transformations = list of 4x4 matrices to apply
|
||||||
// closed = set to true to form a closed (torus) model. Default: false
|
// closed = set to true to form a closed (torus) model. Default: false
|
||||||
// caps = true to create endcap faces when closed is false. Can be a singe boolean to specify endcaps at both ends, or a length 2 boolean array. Default is true if closed is false.
|
// caps = true to create endcap faces when closed is false. Can be a singe boolean to specify endcaps at both ends, or a length 2 boolean array. Default is true if closed is false.
|
||||||
// convexity = convexity setting for use with polyhedron. (module only) Default: 10
|
|
||||||
// anchor = Translate so anchor point is at the origin. (module only) Default: "origin"
|
|
||||||
// spin = Rotate this many degrees around Z axis after anchor. (module only) Default: 0
|
|
||||||
// orient = Vector to rotate top towards after spin (module only)
|
|
||||||
// extent = use extent method for computing anchors. (module only) Default: false
|
|
||||||
// cp = set centerpoint for anchor computation. (module only) Default: object centroid
|
|
||||||
// Example: This is the "sweep-drop" example from list-comprehension-demos.
|
// Example: This is the "sweep-drop" example from list-comprehension-demos.
|
||||||
// function drop(t) = 100 * 0.5 * (1 - cos(180 * t)) * sin(180 * t) + 1;
|
// function drop(t) = 100 * 0.5 * (1 - cos(180 * t)) * sin(180 * t) + 1;
|
||||||
// function path(t) = [0, 0, 80 + 80 * cos(180 * t)];
|
// function path(t) = [0, 0, 80 + 80 * cos(180 * t)];
|
||||||
|
@ -856,16 +839,9 @@ function sweep(shape, transformations, closed=false, caps) =
|
||||||
assert(!closed || !caps, "Cannot make closed shape with caps")
|
assert(!closed || !caps, "Cannot make closed shape with caps")
|
||||||
_skin_core([for(i=[0:len(transformations)-(closed?0:1)]) apply(transformations[i%len(transformations)],path3d(shape))],caps=fullcaps);
|
_skin_core([for(i=[0:len(transformations)-(closed?0:1)]) apply(transformations[i%len(transformations)],path3d(shape))],caps=fullcaps);
|
||||||
|
|
||||||
module sweep(shape, transformations, closed=false, caps, convexity=10,
|
module sweep(shape, transformations, closed=false, caps, convexity=10) {
|
||||||
anchor="origin",cp,spin=0, orient=UP, extent=false)
|
vnf_polyhedron(sweep(shape, transformations, closed, caps), convexity=convexity);
|
||||||
{
|
}
|
||||||
vnf = sweep(shape, transformations, closed, caps);
|
|
||||||
attachable(anchor=anchor, spin=spin, orient=orient, vnf=vnf, extent=extent, cp=is_def(cp) ? cp : vnf_centroid(vnf))
|
|
||||||
{
|
|
||||||
vnf_polyhedron(vnf,convexity=convexity);
|
|
||||||
children();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Function&Module: path_sweep()
|
// Function&Module: path_sweep()
|
||||||
|
@ -930,13 +906,8 @@ module sweep(shape, transformations, closed=false, caps, convexity=10,
|
||||||
// tangent = a list of tangent vectors in case you need more accuracy (particularly at the end points of your curve)
|
// tangent = a list of tangent vectors in case you need more accuracy (particularly at the end points of your curve)
|
||||||
// relaxed = set to true with the "manual" method to relax the orthogonality requirement of cross sections to the path tangent. Default: false
|
// relaxed = set to true with the "manual" method to relax the orthogonality requirement of cross sections to the path tangent. Default: false
|
||||||
// caps = Can be a boolean or vector of two booleans. Set to false to disable caps at the two ends. Default: true
|
// caps = Can be a boolean or vector of two booleans. Set to false to disable caps at the two ends. Default: true
|
||||||
// transforms = set to true to return transforms instead of a VNF. These transforms can be manipulated and passed to sweep(). Default: false.
|
|
||||||
// convexity = convexity parameter for polyhedron(). Only accepted by the module version. Default: 10
|
// convexity = convexity parameter for polyhedron(). Only accepted by the module version. Default: 10
|
||||||
// anchor = Translate so anchor point is at the origin. (module only) Default: "origin"
|
// transforms = set to true to return transforms instead of a VNF. These transforms can be manipulated and passed to sweep(). Default: false.
|
||||||
// spin = Rotate this many degrees around Z axis after anchor. (module only) Default: 0
|
|
||||||
// orient = Vector to rotate top towards after spin (module only)
|
|
||||||
// extent = use extent method for computing anchors. (module only) Default: false
|
|
||||||
// cp = set centerpoint for anchor computation. (module only) Default: object centroid
|
|
||||||
//
|
//
|
||||||
// Example(2D): We'll use this shape in several examples
|
// Example(2D): We'll use this shape in several examples
|
||||||
// ushape = [[-10, 0],[-10, 10],[ -7, 10],[ -7, 2],[ 7, 2],[ 7, 7],[ 10, 7],[ 10, 0]];
|
// ushape = [[-10, 0],[-10, 10],[ -7, 10],[ -7, 2],[ 7, 2],[ 7, 7],[ 10, 7],[ 10, 0]];
|
||||||
|
@ -1150,19 +1121,13 @@ module sweep(shape, transformations, closed=false, caps, convexity=10,
|
||||||
// outside = [for(i=[0:len(trans)-1]) trans[i]*scale(lerp(1,1.5,i/(len(trans)-1)))];
|
// outside = [for(i=[0:len(trans)-1]) trans[i]*scale(lerp(1,1.5,i/(len(trans)-1)))];
|
||||||
// inside = [for(i=[len(trans)-1:-1:0]) trans[i]*scale(lerp(1.1,1.4,i/(len(trans)-1)))];
|
// inside = [for(i=[len(trans)-1:-1:0]) trans[i]*scale(lerp(1.1,1.4,i/(len(trans)-1)))];
|
||||||
// sweep(shape, concat(outside,inside),closed=true);
|
// sweep(shape, concat(outside,inside),closed=true);
|
||||||
module path_sweep(shape, path, method="incremental", normal, closed=false, twist=0, twist_by_length=true,
|
|
||||||
symmetry=1, last_normal, tangent, relaxed=false, caps, convexity=10,
|
|
||||||
anchor="origin",cp,spin=0, orient=UP, extent=false)
|
|
||||||
{
|
|
||||||
vnf = path_sweep(shape, path, method, normal, closed, twist, twist_by_length,
|
|
||||||
symmetry, last_normal, tangent, relaxed, caps);
|
|
||||||
attachable(anchor=anchor, spin=spin, orient=orient, vnf=vnf, extent=extent, cp=is_def(cp) ? cp : vnf_centroid(vnf))
|
|
||||||
{
|
|
||||||
vnf_polyhedron(vnf,convexity=convexity);
|
|
||||||
children();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
module path_sweep(shape, path, method="incremental", normal, closed=false, twist=0, twist_by_length=true,
|
||||||
|
symmetry=1, last_normal, tangent, relaxed=false, caps, convexity=10)
|
||||||
|
{
|
||||||
|
vnf_polyhedron(path_sweep(shape, path, method, normal, closed, twist, twist_by_length,
|
||||||
|
symmetry, last_normal, tangent, relaxed, caps), convexity=convexity);
|
||||||
|
}
|
||||||
|
|
||||||
function path_sweep(shape, path, method="incremental", normal, closed=false, twist=0, twist_by_length=true,
|
function path_sweep(shape, path, method="incremental", normal, closed=false, twist=0, twist_by_length=true,
|
||||||
symmetry=1, last_normal, tangent, relaxed=false, caps, transforms=false) =
|
symmetry=1, last_normal, tangent, relaxed=false, caps, transforms=false) =
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
BOSL_VERSION = [2,0,405];
|
BOSL_VERSION = [2,0,402];
|
||||||
|
|
||||||
|
|
||||||
// Section: BOSL Library Version Functions
|
// Section: BOSL Library Version Functions
|
||||||
|
|
Loading…
Reference in a new issue