1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-17 14:18:13 +01:00
dotSCAD/docs/lib3x-bijection_offset.md

66 lines
1.6 KiB
Markdown
Raw Normal View History

2019-05-20 15:04:13 +08:00
# bijection_offset
Move 2D outlines outward or inward by a given amount. Each point of the offsetted shape is paired with exactly one point of the original shape.
2019-05-20 15:04:23 +08:00
**Since:** 1.2.
2019-05-20 15:04:13 +08:00
## Parameters
- `pts` : Points of a shape.
- `d` : Amount to offset the shape. When negative, the shape is offset inwards.
2019-06-06 13:29:29 +08:00
- `epsilon` : An upper bound on the relative error due to rounding in floating point arithmetic. Default to 0.0001. **Since:** 1.3.
2019-05-20 15:04:13 +08:00
## Examples
2022-06-06 13:11:46 +08:00
use <bijection_offset.scad>
2019-05-20 15:04:13 +08:00
shape = [
[15, 0],
[15, 30],
[0, 20],
[-15, 40],
[-15, 0]
];
2022-04-06 17:44:11 +08:00
color("red") polygon(bijection_offset(shape, 3));
2019-05-20 15:04:13 +08:00
color("orange") polygon(bijection_offset(shape, 2));
color("yellow") polygon(bijection_offset(shape, 1));
2022-04-06 17:44:11 +08:00
color("green") polygon(shape);
color("blue") polygon(bijection_offset(shape, -1));
2019-05-20 15:04:13 +08:00
color("indigo") polygon(bijection_offset(shape, -2));
color("purple") polygon(bijection_offset(shape, -3));
2021-02-24 21:09:54 +08:00
![bijection_offset](images/lib3x-bijection_offset-1.JPG)
2019-05-20 15:04:13 +08:00
2022-06-06 13:11:46 +08:00
use <bijection_offset.scad>
use <path_extrude.scad>
use <bezier_curve.scad>
2019-05-20 15:04:13 +08:00
shape = [
[5, 0],
[3, 9],
[0, 10],
[-5, 0]
];
offsetted = bijection_offset(shape, 1);
offsetted2 = bijection_offset(shape, 2);
offsetted3 = bijection_offset(shape, 3);
t_step = 0.05;
p0 = [0, 0, 0];
p1 = [40, 60, 35];
p2 = [-50, 70, 0];
p3 = [20, 150, -35];
p4 = [30, 50, -3];
path_pts = bezier_curve(t_step,
[p0, p1, p2, p3, p4]
);
2019-05-21 21:42:53 +08:00
path_extrude(concat(offsetted, shape), path_pts, "HOLLOW");
path_extrude(concat(offsetted3, offsetted2), path_pts, "HOLLOW");
2019-05-20 15:04:13 +08:00
2021-02-24 21:09:54 +08:00
![bijection_offset](images/lib3x-bijection_offset-2.JPG)
2019-05-20 15:04:13 +08:00