Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Richard Milewski
2024-10-01 11:40:05 -07:00
5 changed files with 412 additions and 134 deletions

View File

@@ -223,15 +223,6 @@ include <BOSL2/std.scad>
cube([20,20,40], center=true, spin=45);
```
You can also spin around other axes, or multiple axes at once, by giving 3 angles (in degrees) to
`spin=` as a vector, like [Xang,Yang,Zang]. Similarly to `rotate()`,
the rotations apply in the order given, X-axis spin, then Y-axis, then Z-axis:
```openscad-3D
include <BOSL2/std.scad>
cube([20,20,40], center=true, spin=[10,20,30]);
```
This example shows a cylinder which has been anchored at its FRONT,
with a rotated copy in gray. The rotation is performed around the
origin, but the cylinder is off the origin, so the rotation **does**
@@ -666,13 +657,13 @@ To show all the standard cardinal anchor points, you can use the [show_anchors()
```openscad-3D;Big
include <BOSL2/std.scad>
cube(40, center=true)
cube(20, center=true)
show_anchors();
```
```openscad-3D;Big
include <BOSL2/std.scad>
cylinder(h=40, d=40, center=true)
cylinder(h=25, d=25, center=true)
show_anchors();
```
@@ -687,9 +678,10 @@ For large objects, you can again change the size of the arrows with the `s=` arg
```openscad-3D;Big
include <BOSL2/std.scad>
prismoid(150,60,100)
show_anchors(s=35);
show_anchors(s=45);
```
## Parent-Child Anchor Attachment (Double Argument Attachment)
The `attach()` module has two different modes of operation,
@@ -1058,6 +1050,55 @@ cylinder(d1=30,d2=15,h=25)
cylinder(d1=30,d2=15,h=25);
```
Is is also possible to attach to edges and corners of the parent
object. The anchors for edges spin the child so its BACK direction is
aligned with the edge. If the edge belongs to a top or bottom
horizontal face, then the BACK directions will point clockwise around
the face, as seen from outside the shape. (This is the same direction
required for construction of valid faces in OpenSCAD.) Otherwise, the
BACK direction will point upwards.
Examine the red flags below, where only edge anchors appear on a
prismoid. The top face shows the red flags pointing clockwise.
The sloped side edges point along the edges, generally upward, and
the bottom ones appear to point counter-clockwise, but if we viewed
the shape from the bottom they would also appear clockwise.
```openscad-3D;Big
include <BOSL2/std.scad>
prismoid([100,175],[55,88], h=55)
for(i=[-1:1], j=[-1:1], k=[-1:1])
let(anchor=[i,j,k])
if (sum(v_abs(anchor))==2)
attach(anchor,BOT)anchor_arrow(40);
```
In this example cylinders sink half-way into the top edges of the
prismoid:
```openscad-3D;Big
include <BOSL2/std.scad>
$fn=16;
r=6;
prismoid([100,175],[55,88], h=55){
attach([TOP+RIGHT,TOP+LEFT],LEFT,overlap=r/2) cyl(r=r,l=88+2*r,rounding=r);
attach([TOP+FWD,TOP+BACK],LEFT,overlap=r/2) cyl(r=r,l=55+2*r, rounding=r);
}
```
This type of edge attachment is useful for attaching 3d edge masks to
edges:
```openscad-3D;Big
include <BOSL2/std.scad>
$fn=32;
diff()
cuboid(75)
attach([FRONT+LEFT, FRONT+RIGHT, BACK+LEFT, BACK+RIGHT],
FWD+LEFT,inside=true)
rounding_edge_mask(l=76, r1=8,r2=28);
```
## Parent Anchor Attachment (Single Argument Attachment)
The second form of attachment is parent anchor attachment, which just
@@ -1238,7 +1279,7 @@ cube(100, center=true)
}
```
Remember that tags are inherited by children. In this case, we need to explicitly
Remember that tags applied with `tag()` are inherited by children. In this case, we need to explicitly
untag the first cylinder (or change its tag to something else), or it
will inherit the "keep" tag and get kept.
@@ -1252,6 +1293,16 @@ tag("keep")cube(100, center=true)
}
```
You can apply a tag that is not propagated to the children using
`tag_this()`. The above example could then be redone:
diff("hole", "keep")
tag_this("keep")cube(100, center=true)
attach([RIGHT,TOP]) {
cylinder(d=95, h=5);
tag("hole") cylinder(d=50, h=11, anchor=CTR);
}
You can of course apply `tag()` to several children.
@@ -1321,7 +1372,8 @@ intersection is computed between the union of the `intersect` tagged objects and
the objects that don't match any listed tags. Finally the objects listed in `keep` are union
ed with the result.
In this example the parent is intersected with a conical bounding shape.
In this example the parent (untagged) is intersected with a conical
bounding shape, which is tagged with the intersect tag.
```openscad-3D
include <BOSL2/std.scad>
@@ -1619,7 +1671,7 @@ arguments of `attachable()`.
In the most basic form, where the shape is fully cuboid, with top and bottom of the same size,
and directly over one another, you can just use `size=`.
```openscad-3D
```openscad-3D;Big
include <BOSL2/std.scad>
module cubic_barbell(s=100, anchor=CENTER, spin=0, orient=UP) {
attachable(anchor,spin,orient, size=[s*3,s,s]) {
@@ -1637,7 +1689,7 @@ When the shape is prismoidal, where the top is a different size from the bottom,
the `size2=` argument as well. While `size=` takes all three axes sizes, the `size2=` argument
only takes the [X,Y] sizes of the top of the shape.
```openscad-3D
```openscad-3D;Big
include <BOSL2/std.scad>
module prismoidal(size=[100,100,100], scale=0.5, anchor=CENTER, spin=0, orient=UP) {
attachable(anchor,spin,orient, size=size, size2=[size.x, size.y]*scale) {
@@ -1659,7 +1711,7 @@ When the top of the prismoid can be shifted away from directly above the bottom,
the `shift=` argument. The `shift=` argument takes an [X,Y] vector of the offset of the center
of the top from the XY center of the bottom of the shape.
```openscad-3D
```openscad-3D;Big
include <BOSL2/std.scad>
module prismoidal(size=[100,100,100], scale=0.5, shift=[0,0], anchor=CENTER, spin=0, orient=UP) {
attachable(anchor,spin,orient, size=size, size2=[size.x, size.y]*scale, shift=shift) {
@@ -1681,7 +1733,7 @@ In the case that the prismoid is not oriented vertically, (ie, where the `shift=
arguments should refer to a plane other than XY) you can use the `axis=` argument. This lets
you make prismoids naturally oriented forwards/backwards or sideways.
```openscad-3D
```openscad-3D;Big
include <BOSL2/std.scad>
module yprismoidal(
size=[100,100,100], scale=0.5, shift=[0,0],
@@ -1710,7 +1762,7 @@ yprismoidal([100,60,30], scale=1.5, shift=[20,20]) show_anchors(20);
### Cylindrical Attachables
To make a cylindrical shape attachable, you use the `l`, and `r`/`d`, args of `attachable()`.
```openscad-3D
```openscad-3D;Big
include <BOSL2/std.scad>
module twistar(l,r,d, anchor=CENTER, spin=0, orient=UP) {
r = get_radius(r=r,d=d,dflt=1);
@@ -1759,7 +1811,7 @@ ytwistar(l=100, r=40) show_anchors(20);
To make a conical shape attachable, you use the `l`, `r1`/`d1`, and `r2`/`d2`, args of
`attachable()`.
```openscad-3D
```openscad-3D;Big
include <BOSL2/std.scad>
module twistar(l, r,r1,r2, d,d1,d2, anchor=CENTER, spin=0, orient=UP) {
r1 = get_radius(r1=r1,r=r,d1=d1,d=d,dflt=1);
@@ -1776,7 +1828,7 @@ twistar(l=100, r1=40, r2=20) show_anchors(20);
If the cone is ellipsoidal in shape, you can pass the unequal X/Y sizes as a 2-item vectors
to the `r1=`/`r2=` or `d1=`/`d2=` arguments.
```openscad-3D
```openscad-3D;Big
include <BOSL2/std.scad>
module ovalish(l,rx1,ry1,rx2,ry2, anchor=CENTER, spin=0, orient=UP) {
attachable(anchor,spin,orient, r1=[rx1,ry1], r2=[rx2,ry2], l=l) {
@@ -1797,7 +1849,7 @@ ovalish(l=100, rx1=50, ry1=30, rx2=30, ry2=50) show_anchors(20);
For conical shapes that are not oriented vertically, use the `axis=` argument to indicate the
direction of the primary shape axis:
```openscad-3D
```openscad-3D;Big
include <BOSL2/std.scad>
module ytwistar(l, r,r1,r2, d,d1,d2, anchor=CENTER, spin=0, orient=UP) {
r1 = get_radius(r1=r1,r=r,d1=d1,d=d,dflt=1);
@@ -1815,7 +1867,7 @@ ytwistar(l=100, r1=40, r2=20) show_anchors(20);
### Spherical Attachables
To make a spherical shape attachable, you use the `r`/`d` args of `attachable()`.
```openscad-3D
```openscad-3D;Big
include <BOSL2/std.scad>
module spikeball(r, d, anchor=CENTER, spin=0, orient=UP) {
r = get_radius(r=r,d=d,dflt=1);
@@ -2019,7 +2071,8 @@ override the position. If you omit the other list items then the
value drived from the standard anchor will be used. Below we override
position of the FWD anchor:
```
```openscad-3D;Big
include<BOSL2/std.scad>
module cubic_barbell(s=100, anchor=CENTER, spin=0, orient=UP) {
override = [
[FWD, [[0,-s/8,0]]]
@@ -2039,7 +2092,8 @@ Note how the FWD anchor is now rooted on the cylindrical portion. If
you wanted to also change its direction and spin you could do it like
this:
```
```openscad-3D;Big
include<BOSL2/std.scad>
module cubic_barbell(s=100, anchor=CENTER, spin=0, orient=UP) {
override = [
[FWD, [[0,-s/8,0], FWD+LEFT, 225]]
@@ -2062,7 +2116,9 @@ The third entry gives a spin override, whose effect is shown by the
position of the red flag on the arrow. If you want to override all of
the x=0 anchors to be on the cylinder, with their standard directions,
you can do that by supplying a list:
```
```openscad-3D;Big
include<BOSL2/std.scad>
module cubic_barbell(s=100, anchor=CENTER, spin=0, orient=UP) {
override = [
for(j=[-1:1:1], k=[-1:1:1])
@@ -2086,7 +2142,8 @@ the default, or a `[position, direction, spin]` triple to override the
default. As before, you can omit values to keep their default.
Here is the same example using a function literal for the override:
```
```openscad-3D;Big
include<BOSL2/std.scad>
module cubic_barbell(s=100, anchor=CENTER, spin=0, orient=UP) {
override = function (anchor)
anchor.x!=0 || anchor==CTR ? undef // Keep these

View File

@@ -47,22 +47,13 @@ include <BOSL2/std.scad>
cube([50,40,20], anchor=TOP+FRONT+LEFT);
```
You can use `spin=` to rotate around the Z axis:
You can use `spin=` to rotate around the Z axis **after** anchoring:
```openscad-3D
include <BOSL2/std.scad>
cube([50,40,20], anchor=FRONT, spin=30);
```
3D objects also gain the ability to use an extra trick with `spin=`;
if you pass a list of `[X,Y,Z]` rotation angles to `spin=`, it will
rotate by the three given axis angles, similar to using `rotate()`:
```openscad-3D
include <BOSL2/std.scad>
cube([50,40,20], anchor=FRONT, spin=[15,0,30]);
```
3D objects also can be given an `orient=` argument as a vector, pointing
to where the top of the shape should be rotated towards.