2020-03-25 06:16:16 +00:00
|
|
|
# Basic Shapes Tutorial
|
|
|
|
|
2021-04-12 07:41:12 +00:00
|
|
|
<!-- TOC -->
|
|
|
|
|
2020-04-29 05:59:32 +00:00
|
|
|
## Primitives
|
2020-12-28 10:10:50 +00:00
|
|
|
There are 3 built-in 3D primitive shapes that OpenSCAD provides: `cube()`, `cylinder()`,
|
|
|
|
and `sphere()`. The BOSL2 library extends and provides alternative to these shapes so
|
2020-04-29 05:59:32 +00:00
|
|
|
that they support more features, and more ways to simply reorient them.
|
2020-03-25 06:16:16 +00:00
|
|
|
|
2020-05-06 08:36:06 +00:00
|
|
|
|
|
|
|
### 3D Cubes
|
2020-12-28 10:10:50 +00:00
|
|
|
BOSL2 overrides the built-in `cube()` module. It still can be used as you expect from the built-in:
|
2020-04-29 05:59:32 +00:00
|
|
|
|
2020-05-05 22:11:08 +00:00
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cube(100);
|
2020-03-25 06:16:16 +00:00
|
|
|
```
|
2020-04-29 05:59:32 +00:00
|
|
|
|
2020-05-05 22:11:08 +00:00
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cube(100, center=true);
|
2020-03-25 06:16:16 +00:00
|
|
|
```
|
2020-04-29 05:59:32 +00:00
|
|
|
|
2020-05-05 22:11:08 +00:00
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cube([50,40,20], center=true);
|
2020-03-25 06:16:16 +00:00
|
|
|
```
|
|
|
|
|
2020-05-06 08:36:06 +00:00
|
|
|
It is also enhanced to allow you to anchor, spin, orient, and attach it.
|
|
|
|
|
2020-12-28 10:10:50 +00:00
|
|
|
You can use `anchor=` similarly to how you use it with `rect()` or `oval()`,
|
2020-05-06 08:36:06 +00:00
|
|
|
except you can also anchor vertically in 3D, allowing anchoring to faces, edges,
|
|
|
|
and corners:
|
2020-04-29 05:59:32 +00:00
|
|
|
|
2020-05-05 22:11:08 +00:00
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cube([50,40,20], anchor=BOTTOM);
|
2020-03-25 06:16:16 +00:00
|
|
|
```
|
2020-04-29 05:59:32 +00:00
|
|
|
|
2020-05-05 22:11:08 +00:00
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cube([50,40,20], anchor=TOP+BACK);
|
2020-03-25 06:16:16 +00:00
|
|
|
```
|
2020-04-29 05:59:32 +00:00
|
|
|
|
2020-05-05 22:11:08 +00:00
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cube([50,40,20], anchor=TOP+FRONT+LEFT);
|
2020-03-25 06:16:16 +00:00
|
|
|
```
|
|
|
|
|
2020-05-06 08:36:06 +00:00
|
|
|
You can use `spin=` to rotate around the Z axis:
|
2020-04-29 05:59:32 +00:00
|
|
|
|
2020-05-05 22:11:08 +00:00
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cube([50,40,20], anchor=FRONT, spin=30);
|
2020-03-25 06:16:16 +00:00
|
|
|
```
|
|
|
|
|
2020-05-06 08:36:06 +00:00
|
|
|
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
|
2020-03-25 06:16:16 +00:00
|
|
|
rotate by the three given axis angles, similar to using `rotate()`:
|
2020-04-29 05:59:32 +00:00
|
|
|
|
2020-05-05 22:11:08 +00:00
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cube([50,40,20], anchor=FRONT, spin=[15,0,30]);
|
2020-03-25 06:16:16 +00:00
|
|
|
```
|
|
|
|
|
2020-05-06 08:36:06 +00:00
|
|
|
3D objects also can be given an `orient=` argument as a vector, pointing
|
|
|
|
to where the top of the shape should be rotated towards.
|
2020-04-29 05:59:32 +00:00
|
|
|
|
2020-05-05 22:11:08 +00:00
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cube([50,40,20], orient=UP+BACK+RIGHT);
|
2020-03-25 06:16:16 +00:00
|
|
|
```
|
|
|
|
|
2020-05-06 08:36:06 +00:00
|
|
|
If you use `anchor=`, `spin=`, and `orient=` together, the anchor is performed
|
2020-03-25 06:16:16 +00:00
|
|
|
first, then the spin, then the orient:
|
2020-04-29 05:59:32 +00:00
|
|
|
|
2020-05-06 08:36:06 +00:00
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cube([50,40,20], anchor=FRONT);
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cube([50,40,20], anchor=FRONT, spin=45);
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
2020-05-05 22:11:08 +00:00
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cube([50,40,20], anchor=FRONT, spin=45, orient=UP+FWD+RIGHT);
|
2020-03-25 06:16:16 +00:00
|
|
|
```
|
|
|
|
|
2020-05-06 08:36:06 +00:00
|
|
|
BOSL2 provides a `cuboid()` module that expands on `cube()`, by providing
|
|
|
|
rounding and chamfering of edges. You can use it similarly to `cube()`,
|
|
|
|
except that `cuboid()` centers by default.
|
|
|
|
|
|
|
|
You can round the edges with the `rounding=` argument:
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cuboid([100,80,60], rounding=20);
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Similarly, you can chamfer the edges with the `chamfer=` argument:
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cuboid([100,80,60], chamfer=10);
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
You can round only some edges, by using the `edges=` arguments. It can be
|
|
|
|
given a few types of arguments. If you gave it a vector pointed at a face,
|
|
|
|
it will only round the edges surrounding that face:
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cuboid([100,80,60], rounding=20, edges=TOP);
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cuboid([100,80,60], rounding=20, edges=RIGHT);
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
If you give `edges=` a vector pointing at a corner, it will round all edges
|
|
|
|
that meet at that corner:
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cuboid([100,80,60], rounding=20, edges=RIGHT+FRONT+TOP);
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cuboid([100,80,60], rounding=20, edges=LEFT+FRONT+TOP);
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
If you give `edges=` a vector pointing at an edge, it will round only that edge:
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cuboid([100,80,60], rounding=10, edges=FRONT+TOP);
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cuboid([100,80,60], rounding=10, edges=RIGHT+FRONT);
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
If you give the string "X", "Y", or "Z", then all edges aligned with the specified
|
|
|
|
axis will be rounded:
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cuboid([100,80,60], rounding=10, edges="X");
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cuboid([100,80,60], rounding=10, edges="Y");
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cuboid([100,80,60], rounding=10, edges="Z");
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
If you give a list of edge specs, then all edges referenced in the list will
|
|
|
|
be rounded:
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cuboid([100,80,60], rounding=10, edges=[TOP,"Z",BOTTOM+RIGHT]);
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
The default value for `edges=` is `EDGES_ALL`, which is all edges. You can also
|
|
|
|
give an `except_edges=` argument that specifies edges to NOT round:
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cuboid([100,80,60], rounding=10, except_edges=BOTTOM+RIGHT);
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
You can give the `except_edges=` argument any type of argument that you can
|
|
|
|
give to `edges=`:
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cuboid([100,80,60], rounding=10, except_edges=[BOTTOM,"Z",TOP+RIGHT]);
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
You can give both `edges=` and `except_edges=`, to simplify edge specs:
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cuboid([100,80,60], rounding=10, edges=[TOP,FRONT], except_edges=TOP+FRONT);
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
You can specify what edges to chamfer similarly:
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cuboid([100,80,60], chamfer=10, edges=[TOP,FRONT], except_edges=TOP+FRONT);
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
### 3D Cylinder
|
|
|
|
BOSL2 overrides the built-in `cylinder()` module. It still can be used as you
|
|
|
|
expect from the built-in:
|
2020-04-29 05:59:32 +00:00
|
|
|
|
2020-05-05 22:11:08 +00:00
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cylinder(r=50,h=50);
|
2020-03-25 06:16:16 +00:00
|
|
|
```
|
2020-04-29 05:59:32 +00:00
|
|
|
|
2020-05-05 22:11:08 +00:00
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cylinder(r=50,h=50,center=true);
|
2020-03-25 06:16:16 +00:00
|
|
|
```
|
2020-04-29 05:59:32 +00:00
|
|
|
|
2020-05-05 22:11:08 +00:00
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cylinder(d=100,h=50,center=true);
|
2020-03-25 06:16:16 +00:00
|
|
|
```
|
2020-04-29 05:59:32 +00:00
|
|
|
|
2020-05-05 22:11:08 +00:00
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cylinder(d1=100,d2=80,h=50,center=true);
|
2020-03-25 06:16:16 +00:00
|
|
|
```
|
|
|
|
|
2020-05-06 08:36:06 +00:00
|
|
|
You can also anchor, spin, orient, and attach like the `cuboid()` module:
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cylinder(r=50, h=50, anchor=TOP+FRONT);
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cylinder(r=50, h=50, anchor=BOTTOM+LEFT);
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cylinder(r=50, h=50, anchor=BOTTOM+LEFT, spin=30);
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cylinder(r=50, h=50, anchor=BOTTOM, orient=UP+BACK+RIGHT);
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
BOSL2 provides a `cyl()` module that expands on `cylinder()`, by providing
|
|
|
|
rounding and chamfering of edges. You can use it similarly to `cylinder()`,
|
|
|
|
except that `cyl()` centers the cylinder by default.
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cyl(r=60, l=100);
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cyl(d=100, l=100);
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cyl(d=100, l=100, anchor=TOP);
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
You can round the edges with the `rounding=` argument:
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cyl(d=100, l=100, rounding=20);
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Similarly, you can chamfer the edges with the `chamfer=` argument:
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cyl(d=100, l=100, chamfer=10);
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
You can specify rounding and chamfering for each end individually:
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cyl(d=100, l=100, rounding1=20);
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cyl(d=100, l=100, rounding2=20);
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cyl(d=100, l=100, chamfer1=10);
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cyl(d=100, l=100, chamfer2=10);
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
You can even mix and match rounding and chamfering:
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cyl(d=100, l=100, rounding1=20, chamfer2=10);
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
cyl(d=100, l=100, rounding2=20, chamfer1=10);
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
### 3D Spheres
|
|
|
|
BOSL2 overrides the built-in `sphere()` module. It still can be used as you
|
|
|
|
expect from the built-in:
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
sphere(r=50);
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
sphere(d=100);
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
You can anchor, spin, and orient `sphere()`s, much like you can with `cylinder()`
|
|
|
|
and `cube()`:
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
sphere(d=100, anchor=FRONT);
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
sphere(d=100, anchor=FRONT, spin=30);
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
sphere(d=100, anchor=BOTTOM, orient=RIGHT+TOP);
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
BOSL2 also provides `spheroid()`, which enhances `sphere()` with a few features
|
|
|
|
like the `circum=` and `style=` arguments:
|
|
|
|
|
|
|
|
You can use the `circum=true` argument to force the sphere to circumscribe the
|
|
|
|
ideal sphere, as opposed to the default inscribing:
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
spheroid(d=100, circum=true);
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
The `style=` argument can choose the way that the sphere will be constructed:
|
|
|
|
The "orig" style matches the `sphere()` built-in's construction.
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
spheroid(d=100, style="orig", $fn=20);
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
2020-05-06 08:51:55 +00:00
|
|
|
The "aligned" style will ensure that there is a vertex at each axis extrema,
|
2020-05-06 08:36:06 +00:00
|
|
|
so long as `$fn` is a multiple of 4.
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
spheroid(d=100, style="aligned", $fn=20);
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
The "stagger" style will stagger the triangulation of the vertical rows:
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
spheroid(d=100, style="stagger", $fn=20);
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
2020-12-28 10:10:50 +00:00
|
|
|
The "icosa" style will make for roughly equal-sized triangles for the entire
|
|
|
|
sphere surface, based on subdividing an icosahedron. This style will round the
|
|
|
|
effective `$fn` to a multiple of 5 when constructing the spheroid:
|
2020-05-06 08:36:06 +00:00
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
spheroid(d=100, style="icosa", $fn=20);
|
2020-05-06 08:36:06 +00:00
|
|
|
```
|
|
|
|
|
2020-12-28 10:10:50 +00:00
|
|
|
The "octa" style will also make for roughly equal-sized triangles for the entire
|
|
|
|
sphere surface, but based on subdividing an octahedron. This is useful in that it
|
|
|
|
guarantees vertices at the axis extrema. This style will round the effective `$fn`
|
|
|
|
to a multiple of 4 when constructing the spheroid:
|
|
|
|
|
|
|
|
```openscad-3D
|
2022-02-09 02:40:58 +00:00
|
|
|
include <BOSL2/std.scad>
|
2021-04-18 02:17:44 +00:00
|
|
|
spheroid(d=100, style="octa", $fn=20);
|
2020-12-28 10:10:50 +00:00
|
|
|
```
|
2020-05-06 08:36:06 +00:00
|
|
|
|