mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2024-12-29 16:29:40 +00:00
Fix for #802
This commit is contained in:
parent
6a42df748b
commit
6eb2bb9689
1 changed files with 99 additions and 62 deletions
|
@ -8,61 +8,72 @@ The BOSL2 library provides a number of ways to do this:
|
|||
|
||||
```openscad-3D
|
||||
include <BOSL2/std.scad>
|
||||
left_half() sphere(d=100);
|
||||
left_half()
|
||||
sphere(d=100);
|
||||
```
|
||||
|
||||
```openscad-3D
|
||||
include <BOSL2/std.scad>
|
||||
right_half() sphere(d=100);
|
||||
right_half()
|
||||
sphere(d=100);
|
||||
```
|
||||
|
||||
```openscad-3D
|
||||
include <BOSL2/std.scad>
|
||||
front_half() sphere(d=100);
|
||||
front_half()
|
||||
sphere(d=100);
|
||||
```
|
||||
|
||||
```openscad-3D
|
||||
include <BOSL2/std.scad>
|
||||
back_half() sphere(d=100);
|
||||
back_half()
|
||||
sphere(d=100);
|
||||
```
|
||||
|
||||
```openscad-3D
|
||||
include <BOSL2/std.scad>
|
||||
bottom_half() sphere(d=100);
|
||||
bottom_half()
|
||||
sphere(d=100);
|
||||
```
|
||||
|
||||
```openscad-3D
|
||||
include <BOSL2/std.scad>
|
||||
top_half() sphere(d=100);
|
||||
top_half()
|
||||
sphere(d=100);
|
||||
```
|
||||
|
||||
You can use the `half_of()` module if you want to split space in a way not aligned with an axis:
|
||||
|
||||
```openscad-3D
|
||||
include <BOSL2/std.scad>
|
||||
half_of([-1,0,-1]) sphere(d=100);
|
||||
half_of([-1,0,-1])
|
||||
sphere(d=100);
|
||||
```
|
||||
|
||||
The plane of dissection can be shifted along the axis of any of these operators:
|
||||
|
||||
```openscad-3D
|
||||
include <BOSL2/std.scad>
|
||||
left_half(x=20) sphere(d=100);
|
||||
left_half(x=20)
|
||||
sphere(d=100);
|
||||
```
|
||||
|
||||
```openscad-3D
|
||||
include <BOSL2/std.scad>
|
||||
back_half(y=-20) sphere(d=100);
|
||||
back_half(y=-20)
|
||||
sphere(d=100);
|
||||
```
|
||||
|
||||
```openscad-3D
|
||||
include <BOSL2/std.scad>
|
||||
bottom_half(z=20) sphere(d=100);
|
||||
bottom_half(z=20)
|
||||
sphere(d=100);
|
||||
```
|
||||
|
||||
```openscad-3D
|
||||
include <BOSL2/std.scad>
|
||||
half_of([-1,0,-1], cp=[20,0,20]) sphere(d=100);
|
||||
half_of([-1,0,-1], cp=[20,0,20])
|
||||
sphere(d=100);
|
||||
```
|
||||
|
||||
By default, these operators can be applied to objects that fit in a cube 1000 on a side. If you need
|
||||
|
@ -71,7 +82,8 @@ argument:
|
|||
|
||||
```openscad-3D
|
||||
include <BOSL2/std.scad>
|
||||
bottom_half(s=2000) sphere(d=1500);
|
||||
bottom_half(s=2000)
|
||||
sphere(d=1500);
|
||||
```
|
||||
|
||||
## 2D Plane Halving
|
||||
|
@ -79,22 +91,26 @@ To cut 2D shapes in half, you will need to add the `planar=true` argument:
|
|||
|
||||
```openscad-3D
|
||||
include <BOSL2/std.scad>
|
||||
left_half(planar=true) circle(d=100);
|
||||
left_half(planar=true)
|
||||
circle(d=100);
|
||||
```
|
||||
|
||||
```openscad-3D
|
||||
include <BOSL2/std.scad>
|
||||
right_half(planar=true) circle(d=100);
|
||||
right_half(planar=true)
|
||||
circle(d=100);
|
||||
```
|
||||
|
||||
```openscad-3D
|
||||
include <BOSL2/std.scad>
|
||||
front_half(planar=true) circle(d=100);
|
||||
front_half(planar=true)
|
||||
circle(d=100);
|
||||
```
|
||||
|
||||
```openscad-3D
|
||||
include <BOSL2/std.scad>
|
||||
back_half(planar=true) circle(d=100);
|
||||
back_half(planar=true)
|
||||
circle(d=100);
|
||||
```
|
||||
|
||||
## Chained Mutators
|
||||
|
@ -115,14 +131,18 @@ The OpenSCAD `linear_extrude()` module can take a 2D shape and extrude it vertic
|
|||
|
||||
```openscad-3D
|
||||
include <BOSL2/std.scad>
|
||||
linear_extrude(height=30) zrot(45) square(40,center=true);
|
||||
linear_extrude(height=30)
|
||||
zrot(45)
|
||||
square(40,center=true);
|
||||
```
|
||||
|
||||
The `rotate_extrude()` module can take a 2D shape and rotate it around the Z axis.
|
||||
|
||||
```openscad-3D
|
||||
include <BOSL2/std.scad>
|
||||
linear_extrude(height=30) left(30) zrot(45) square(40,center=true);
|
||||
rotate_extrude()
|
||||
left(50) zrot(45)
|
||||
square(40,center=true);
|
||||
```
|
||||
|
||||
In a similar manner, the BOSL2 `cylindrical_extrude()` module can take a 2d shape and extrude it
|
||||
|
@ -185,24 +205,28 @@ The `round2d()` module lets you take a 2D shape and round inside and outside cor
|
|||
|
||||
```openscad-2D
|
||||
include <BOSL2/std.scad>
|
||||
round2d(or=8) star(6, step=2, d=100);
|
||||
round2d(or=8)
|
||||
star(6, step=2, d=100);
|
||||
```
|
||||
|
||||
```openscad-2D
|
||||
include <BOSL2/std.scad>
|
||||
round2d(ir=12) star(6, step=2, d=100);
|
||||
round2d(ir=12)
|
||||
star(6, step=2, d=100);
|
||||
```
|
||||
|
||||
```openscad-2D
|
||||
include <BOSL2/std.scad>
|
||||
round2d(or=8,ir=12) star(6, step=2, d=100);
|
||||
round2d(or=8,ir=12)
|
||||
star(6, step=2, d=100);
|
||||
```
|
||||
|
||||
You can use `r=` to effectively set both `ir=` and `or=` to the same value:
|
||||
|
||||
```openscad-2D
|
||||
include <BOSL2/std.scad>
|
||||
round2d(r=8) star(6, step=2, d=100);
|
||||
round2d(r=8)
|
||||
star(6, step=2, d=100);
|
||||
```
|
||||
|
||||
### Shell2d
|
||||
|
@ -211,71 +235,84 @@ With a positive thickness, the shell is offset outwards from the original shape:
|
|||
|
||||
```openscad-2D
|
||||
include <BOSL2/std.scad>
|
||||
shell2d(thickness=5) star(5,step=2,d=100);
|
||||
color("blue") stroke(star(5,step=2,d=100),closed=true);
|
||||
shell2d(thickness=5)
|
||||
star(5,step=2,d=100);
|
||||
color("blue")
|
||||
stroke(star(5,step=2,d=100),closed=true);
|
||||
```
|
||||
|
||||
With a negative thickness, the shell if inset from the original shape:
|
||||
|
||||
```openscad-2D
|
||||
include <BOSL2/std.scad>
|
||||
shell2d(thickness=-5) star(5,step=2,d=100);
|
||||
color("blue") stroke(star(5,step=2,d=100),closed=true);
|
||||
shell2d(thickness=-5)
|
||||
star(5,step=2,d=100);
|
||||
color("blue")
|
||||
stroke(star(5,step=2,d=100),closed=true);
|
||||
```
|
||||
|
||||
You can give a pair of thickness values if you want it both inset and outset from the original shape:
|
||||
|
||||
```openscad-2D
|
||||
include <BOSL2/std.scad>
|
||||
shell2d(thickness=[-5,5]) star(5,step=2,d=100);
|
||||
color("blue") stroke(star(5,step=2,d=100),closed=true);
|
||||
shell2d(thickness=[-5,5])
|
||||
star(5,step=2,d=100);
|
||||
color("blue")
|
||||
stroke(star(5,step=2,d=100),closed=true);
|
||||
```
|
||||
|
||||
You can add rounding to the outside by passing a radius to the `or=` argument.
|
||||
|
||||
```openscad-2D
|
||||
include <BOSL2/std.scad>
|
||||
shell2d(thickness=-5,or=5) star(5,step=2,d=100);
|
||||
shell2d(thickness=-5,or=5)
|
||||
star(5,step=2,d=100);
|
||||
```
|
||||
|
||||
If you need to pass different radii for the convex and concave corners of the outside, you can pass them as `or=[CONVEX,CONCAVE]`:
|
||||
|
||||
```openscad-2D
|
||||
include <BOSL2/std.scad>
|
||||
shell2d(thickness=-5,or=[5,10]) star(5,step=2,d=100);
|
||||
shell2d(thickness=-5,or=[5,10])
|
||||
star(5,step=2,d=100);
|
||||
```
|
||||
|
||||
A radius of 0 can be used to specify no rounding:
|
||||
|
||||
```openscad-2D
|
||||
include <BOSL2/std.scad>
|
||||
shell2d(thickness=-5,or=[5,0]) star(5,step=2,d=100);
|
||||
shell2d(thickness=-5,or=[5,0])
|
||||
star(5,step=2,d=100);
|
||||
```
|
||||
|
||||
You can add rounding to the inside by passing a radius to the `ir=` argument.
|
||||
|
||||
```openscad-2D
|
||||
include <BOSL2/std.scad>
|
||||
shell2d(thickness=-5,ir=5) star(5,step=2,d=100);
|
||||
shell2d(thickness=-5,ir=5)
|
||||
star(5,step=2,d=100);
|
||||
```
|
||||
|
||||
If you need to pass different radii for the convex and concave corners of the inside, you can pass them as `ir=[CONVEX,CONCAVE]`:
|
||||
|
||||
```openscad-2D
|
||||
include <BOSL2/std.scad>
|
||||
shell2d(thickness=-5,ir=[8,3]) star(5,step=2,d=100);
|
||||
shell2d(thickness=-5,ir=[8,3])
|
||||
star(5,step=2,d=100);
|
||||
```
|
||||
|
||||
You can use `or=` and `ir=` together to get nice combined rounding effects:
|
||||
|
||||
```openscad-2D
|
||||
include <BOSL2/std.scad>
|
||||
shell2d(thickness=-5,or=[7,2],ir=[7,2]) star(5,step=2,d=100);
|
||||
shell2d(thickness=-5,or=[7,2],ir=[7,2])
|
||||
star(5,step=2,d=100);
|
||||
```
|
||||
|
||||
```openscad-2D
|
||||
include <BOSL2/std.scad>
|
||||
shell2d(thickness=-5,or=[5,0],ir=[5,0]) star(5,step=2,d=100);
|
||||
shell2d(thickness=-5,or=[5,0],ir=[5,0])
|
||||
star(5,step=2,d=100);
|
||||
```
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue