1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-17 22:28:16 +01:00
dotSCAD/docs/lib3x-in_shape.md

39 lines
879 B
Markdown
Raw Normal View History

2019-06-02 21:04:05 +08:00
# in_shape
2021-04-09 11:30:40 +08:00
Checks whether a point is inside a shape.
2019-06-02 21:04:05 +08:00
2019-06-02 21:07:58 +08:00
**Since:** 1.3
2019-06-02 21:04:05 +08:00
## Parameters
- `shapt_pts` : The shape points.
- `pt` : The point to be checked.
- `include_edge` : If a point is on the edge of the shape, the function is default to return `false`. If `include_edge` is `true`, the function returns `true`.
- `epsilon` : An upper bound on the relative error due to rounding in floating point arithmetic. Default to 0.0001.
## Examples
2022-06-06 13:11:46 +08:00
use <shape_taiwan.scad>
use <in_shape.scad>
2019-06-02 21:04:05 +08:00
points = shape_taiwan(30);
%polygon(points);
n = 200;
xs = rands(-9, 9, n);
ys = rands(-16, 16, n);
pts = [
2019-06-08 08:34:38 +08:00
for(i = [0:n - 1])
2019-06-02 21:04:05 +08:00
let(p = [xs[i], ys[i]])
if(in_shape(points, p, true))
p
];
for(p = pts) {
translate(p)
circle(.2);
}
2021-02-24 21:09:54 +08:00
![in_shape](images/lib3x-in_shape-1.JPG)