Updated Cube Rounding Tutorial

This commit is contained in:
Richard Milewski 2024-03-16 11:43:23 -07:00
parent d0330113fa
commit 1dfe8f82f0

View file

@ -12,7 +12,6 @@ There are four different 3d shape primitives that you can use to make cube-like
* [**rounded_prism()**](https://github.com/BelfrySCAD/BOSL2/wiki/rounding.scad#functionmodule-rounded_prism) - Makes a rounded 3d object by connecting two polygons with the same vertex count. Rounded_prism supports continuous curvature rounding. (See [Types of Roundovers](https://github.com/BelfrySCAD/BOSL2/wiki/rounding.scad#section-types-of-roundovers)).
BOSL2 provides two different methods for rounding the edges of these cube-like primitives.
* **Built-in Rounding** - The [cuboid()](https://github.com/BelfrySCAD/BOSL2/wiki/shapes3d.scad#module-cuboid), [prismoid()](https://github.com/BelfrySCAD/BOSL2/wiki/shapes3d.scad#functionmodule-prismoid), and [rounded_prism()](https://github.com/BelfrySCAD/BOSL2/wiki/rounding.scad#functionmodule-rounded_prism) all have built-in arguments for rounding some or all of their edges.
@ -25,7 +24,6 @@ Cube-like objects have six named faces: **LEFT, RIGHT, TOP, BOT, FWD, BACK**.
Each of those face names is a vector pointing to the face. e.g. UP is [0,0,1], and FWD is [0,-1,0]. By adding two of those vectors we can specify an edge. For example, TOP + RIGHT is the same as [0,0,1] + [0,1,0] = [0,1,1].
![](https://github.com/BelfrySCAD/BOSL2/wiki/images/attachments/subsection-specifying-edges_fig1.png)
See [Specifying Edges](https://github.com/BelfrySCAD/BOSL2/wiki/attachments.scad#subsection-specifying-edges) for more details.
@ -46,7 +44,6 @@ include <BOSL2/std.scad>
cuboid([100,80,60], rounding=20, edges = "Z");
```
You can round all the edges on one of the faces. Here we're rounding only the top edges:
```openscad-3D
@ -61,7 +58,6 @@ include <BOSL2/std.scad>
cuboid([100,80,60], rounding=20, teardrop = 45, edges = BOTTOM);
```
It is possible to round one or more of the edges while leaving others unrounded:
```openscad-3D
@ -112,7 +108,6 @@ include <BOSL2/std.scad>
cuboid([100,80,60], rounding=-20, edges = BOTTOM);
```
### Chamfering
Chamfering the edges of the cuboid() can be done in a manner similar to rounding:
@ -145,8 +140,8 @@ include <BOSL2/std.scad>
prismoid(100, 80, rounding1=[0,50,0,50], rounding2=[40,0,40,0], h=50);
```
## Masking Edges of the Cuboid, Cube and Prismoid
### 2D Edge Masking with [edge_profile()](https://github.com/BelfrySCAD/BOSL2/wiki/attachments.scad#module-edge_profile) and [edge_profile_asym()](https://github.com/BelfrySCAD/BOSL2/wiki/attachments.scad#module-edge_profile_asym)
One limitation of using rounding arguments in [cuboid()](https://github.com/BelfrySCAD/BOSL2/wiki/shapes3d.scad#module-cuboid) is that all the rounded edges must have the same rounding radius. Using masking we have the flexibility to apply different edge treatments to the same cube. Masking can also be used on the [cube()](https://github.com/BelfrySCAD/BOSL2/wiki/shapes3d.scad#functionmodule-cube) and [prismoid()](https://github.com/BelfrySCAD/BOSL2/wiki/shapes3d.scad#functionmodule-prismoid) shapes.
@ -184,7 +179,7 @@ cuboid(50){
}
```
See [mask2d_roundover()](https://github.com/BelfrySCAD/BOSL2/wiki/masks2d.scad#functionmodule-mask2d_roundover) for additional mask parameters. Here we use the *inset* parameter in mask2d_roundover:
See [mask2d_roundover()](https://github.com/BelfrySCAD/BOSL2/wiki/masks2d.scad#functionmodule-mask2d_roundover) for additional mask parameters. Here we use the *inset* parameter to produce a bead.
```openscad-3D
include <BOSL2/std.scad>
@ -194,7 +189,55 @@ diff()
mask2d_roundover(h=12, inset=4);
```
In addition to the simple roundover mask, there are masks for [cove](https://github.com/BelfrySCAD/BOSL2/wiki/masks2d.scad#functionmodule-mask2d_cove), [chamfer](https://github.com/BelfrySCAD/BOSL2/wiki/masks2d.scad#functionmodule-mask2d_chamfer), [rabbet](https://github.com/BelfrySCAD/BOSL2/wiki/masks2d.scad#functionmodule-mask2d_rabbet), [dovetail](https://github.com/BelfrySCAD/BOSL2/wiki/masks2d.scad#functionmodule-mask2d_dovetail), [teardrop](https://github.com/BelfrySCAD/BOSL2/wiki/masks2d.scad#functionmodule-mask2d_teardrop) and [ogee](https://github.com/BelfrySCAD/BOSL2/wiki/masks2d.scad#functionmodule-mask2d_ogee) edges.
You can use [edge-profile()](https://github.com/BelfrySCAD/BOSL2/wiki/attachments.scad#module-edge_profile) to round the top or bottom of a [prismoid()](https://github.com/BelfrySCAD/BOSL2/wiki/shapes3d.scad#functionmodule-prismoid). Because the side faces of a [prismoid()](https://github.com/BelfrySCAD/BOSL2/wiki/shapes3d.scad#functionmodule-prismoid) are not strictly vertical, it's is necessary to increase the length of the masks using the *excess* parameter in [edge_profile()](https://github.com/BelfrySCAD/BOSL2/wiki/attachments.scad#module-edge_profile), and to set the mask\_angle to $edge\_angle in [mask2d\_roundover()](https://github.com/BelfrySCAD/BOSL2/wiki/masks2d.scad#functionmodule-mask2d_roundover).
```openscad-3D
include<BOSL2/std.scad>
diff()
prismoid(size1=[35,50], size2=[30,30], h=20, rounding1 = 8, rounding2 = 0)
edge_profile([TOP+LEFT, TOP+RIGHT], excess = 5)
mask2d_roundover(r = 15, mask_angle = $edge_angle, $fn = 64);
```
Instead of specifying the rounding radius, you can specify the height of edge rounding.
```openscad-3D
include<BOSL2/std.scad>
diff()
cube(30)
edge_profile([TOP+LEFT, TOP+RIGHT])
mask2d_roundover(h = 12, $fn = 64);
```
Rounding heights larger than an adjacent edge/2 will produce a ridge line on the top surface.
```openscad-3D
include<BOSL2/std.scad>
diff()
cube(30)
edge_profile([TOP+LEFT, TOP+RIGHT])
mask2d_roundover(h = 20, $fn = 64);
```
The [mask2d_teardrop()](https://github.com/BelfrySCAD/BOSL2/wiki/masks2d.scad#functionmodule-mask2d_teardrop) mask can be used to round the bottom of a cube-like object. It limits the overhang angle to 45° or a value you specify in with the **angle** argument.
```
include<BOSL2/std.scad>
diff()
prismoid([30,20], [40,30], rounding = 2, h = 20, $fn = 64)
edge_profile(BOT, excess = 15)
mask2d_teardrop(h = 5, mask_angle = $edge_angle, $fn = 64);
```
```openscad-3d; ImgOnly VPR=[85,0,5]
include<BOSL2/std.scad>
diff()
prismoid([30,20], [40,30], rounding = 2, h = 20, $fn = 64)
edge_profile(BOT, excess = 15)
mask2d_teardrop(h = 5, mask_angle = $edge_angle, $fn = 64);
```
In addition to the simple [roundover](https://github.com/BelfrySCAD/BOSL2/wiki/masks2d.scad#functionmodule-mask2d_roundover) mask, and the [teardrop](https://github.com/BelfrySCAD/BOSL2/wiki/masks2d.scad#functionmodule-mask2d_teardrop) mask, there are masks for [cove](https://github.com/BelfrySCAD/BOSL2/wiki/masks2d.scad#functionmodule-mask2d_cove), [chamfer](https://github.com/BelfrySCAD/BOSL2/wiki/masks2d.scad#functionmodule-mask2d_chamfer), [rabbet](https://github.com/BelfrySCAD/BOSL2/wiki/masks2d.scad#functionmodule-mask2d_rabbet), [dovetail](https://github.com/BelfrySCAD/BOSL2/wiki/masks2d.scad#functionmodule-mask2d_dovetail) and [ogee](https://github.com/BelfrySCAD/BOSL2/wiki/masks2d.scad#functionmodule-mask2d_ogee) edges.
The mask2d_ogee() only works on [cube()](https://github.com/BelfrySCAD/BOSL2/wiki/shapes3d.scad#functionmodule-cube) and [cuboid()](https://github.com/BelfrySCAD/BOSL2/wiki/shapes3d.scad#module-cuboid) shapes, or a [prismoid()](https://github.com/BelfrySCAD/BOSL2/wiki/shapes3d.scad#functionmodule-prismoid) where size2 >= size1 in both the X and Y dimensions.
@ -210,22 +253,83 @@ diff()
]);
```
You can use [edge-profile()](https://github.com/BelfrySCAD/BOSL2/wiki/attachments.scad#module-edge_profile) to round the top or bottom of a [prismoid()](https://github.com/BelfrySCAD/BOSL2/wiki/shapes3d.scad#functionmodule-prismoid). Because the side faces of a [prismoid()](https://github.com/BelfrySCAD/BOSL2/wiki/shapes3d.scad#functionmodule-prismoid) are not strictly vertical, it's is necessary to increase the length of the masks using the *excess* parameter in [edge_profile()](https://github.com/BelfrySCAD/BOSL2/wiki/attachments.scad#module-edge_profile), and to set the mask\_angle to $edge\_angle in [mask2d\_roundover()](https://github.com/BelfrySCAD/BOSL2/wiki/masks2d.scad#functionmodule-mask2d_roundover).
Prismoids, espcecially prismoids with substantial shift, require careful selection of mask2d_roundover() arguments. Here we're setting radius = 5 and mask_angle = $edge_angle.
```openscad-3D
```
include<BOSL2/std.scad>
diff()
prismoid(size1=[35,50], size2=[30,30], h=20, rounding1 = 8, rounding2 = 0)
edge_profile([TOP+LEFT, TOP+RIGHT], excess = 5)
mask2d_roundover(r = 15, mask_angle = $edge_angle);
prismoid([30,20], [50,60], h=20, shift=[30,40])
edge_profile(TOP, excess=35)
mask2d_roundover(r=5, mask_angle=$edge_angle, $fn=128);
```
```openscad-3D; ImgOnly VPT=[16,16,12] VPD=185 VPR=[84,0,82]
include<BOSL2/std.scad>
diff()
prismoid([30,20], [50,60], h=20, shift=[30,40])
edge_profile(TOP, excess=35)
mask2d_roundover(r=5, mask_angle=$edge_angle, $fn=128);
```
Specifying rounding height rather than rounding radius produces a different shape.
```openscad-3D; ImgOnly VPT=[16,16,12] VPD=185 VPR=[84,0,82]
include<BOSL2/std.scad>
diff()
prismoid([30,20], [50,60], h=20, shift=[30,40])
edge_profile(TOP, excess=35)
mask2d_roundover(h=5, mask_angle=$edge_angle, $fn=128);
```
```
include<BOSL2/std.scad>
diff()
prismoid([30,20], [50,60], h=20, shift=[30,40])
edge_profile(TOP, excess=35)
mask2d_roundover(h=5, mask_angle=$edge_angle, $fn=128);
```
The quarter_round argument works well for edges with acute angles, but leaves a ledge on the edges with obtuse angles.
```openscad-3D; ImgOnly VPT=[16,16,12] VPD=185 VPR=[84,0,82]
include<BOSL2/std.scad>
diff()
prismoid([30,20], [50,60], h=20, shift=[30,40])
edge_profile(TOP, excess=35)
mask2d_roundover(r=5, mask_angle=$edge_angle, quarter_round = true, $fn=128);
```
```
include<BOSL2/std.scad>
diff()
prismoid([30,20], [50,60], h=20, shift=[30,40])
edge_profile(TOP, excess=35)
mask2d_roundover(r=5, mask_angle=$edge_angle, quarter_round = true, $fn=128);
```
A work-around is to use quarter_round only on the edges with acute angles.
```openscad-3D; ImgOnly VPT=[16,16,12] VPD=185 VPR=[84,0,82]
include<BOSL2/std.scad>
diff()
prismoid([30,20], [50,60], h=20, shift=[30,40])
edge_profile(TOP, excess=35)
mask2d_roundover(r=5, mask_angle=$edge_angle, quarter_round = $edge_angle<90, $fn=128);
```
```
include<BOSL2/std.scad>
diff()
prismoid([30,20], [50,60], h=20, shift=[30,40])
edge_profile(TOP, excess=35)
mask2d_roundover(r=5, mask_angle=$edge_angle, quarter_round = $edge_angle<90, $fn=128);
```
### 3D Edge and Corner Masking
BOSL2 contains a number of 3d edge and corner masks in addition to the 2d edge profiles shown above.
The 3d edge masks have the advantage of being able to vary the rounding radius along the edge. 3d edge masks, such as[ rounding\_edge_mask()](https://github.com/BelfrySCAD/BOSL2/wiki/masks3d.scad#module-rounding_edge_mask), can be attached using [edge_mask()](https://github.com/BelfrySCAD/BOSL2/wiki/attachments.scad#module-edge_mask). The 3D edge masks have a default tag of "remove" to enable differencing them away from your cube using [diff()](https://github.com/BelfrySCAD/BOSL2/wiki/attachments.scad#module-diff).
The 3d edge masks have the advantage of being able to vary the rounding radius along the edge. 3d edge masks, such as[rounding_edge_mask()](https://github.com/BelfrySCAD/BOSL2/wiki/masks3d.scad#module-rounding_edge_mask), can be attached using [edge_mask()](https://github.com/BelfrySCAD/BOSL2/wiki/attachments.scad#module-edge_mask). The 3D edge masks have a default tag of "remove" to enable differencing them away from your cube using [diff()](https://github.com/BelfrySCAD/BOSL2/wiki/attachments.scad#module-diff).
```openscad-3D
include <BOSL2/std.scad>
@ -285,12 +389,13 @@ diff()
}
```
## Rounded Prism
You can construct cube-like objects, as well as a variety of other prisms using [rounded_prism()](https://github.com/BelfrySCAD/BOSL2/wiki/rounding.scad#functionmodule-rounded_prism). In this tutorial we're concentrating on rounding cubes, but [rounded_prism()](https://github.com/BelfrySCAD/BOSL2/wiki/rounding.scad#functionmodule-rounded_prism) has capabilities that extend well beyond cube-like objects. See the [rounded_prism()](https://github.com/BelfrySCAD/BOSL2/wiki/rounding.scad#functionmodule-rounded_prism) examples to learn more.
A feature unique to [rounded_prism()](https://github.com/BelfrySCAD/BOSL2/wiki/rounding.scad#functionmodule-rounded_prism) is that it uses continuous curvature rounding. Rather than using constant radius arcs, continuous curvature rounding uses 4th-order Bezier curves. For complete details on how this works see [Types of Roundovers](https://github.com/BelfrySCAD/BOSL2/wiki/rounding.scad#section-types-of-roundovers).
Two parameters control the roundover, k and joint. The joint parameter is the distance from where the rounding starts to the unrounded edge. The k parameter ranges from 0 to 1 with a default of 0.5. Larger values give a more abrupt transition and smaller ones a more gradual transition.
Parameters of a "smooth" roundover, with k=0.75.
@ -303,10 +408,8 @@ Parameters of a "smooth" roundover, with k=0.15. The transition is so gradual th
The joint parameter is specified separately for the top, bottom and side edges; joint\_top, joint\_bot, and joint_sides.
If you want a very smooth roundover, set the joint parameter as large as possible and then adjust the k value down low enough to achieve a sufficiently large roundover. Joint parameters usually need to be < side/2.
```openscad-3D
include <BOSL2/std.scad>
include <BOSL2/rounding.scad>