mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-11 01:04:07 +02:00
added shape_pie
This commit is contained in:
@@ -28,8 +28,8 @@ Too many dependencies? Because OpenSCAD doesn't provide namespace management, I
|
||||
## Documentation
|
||||
|
||||
- 2D
|
||||
- [pie](https://openhome.cc/eGossip/OpenSCAD/lib-pie.html)
|
||||
- [arc](https://openhome.cc/eGossip/OpenSCAD/lib-arc.html)
|
||||
- [arc](https://openhome.cc/eGossip/OpenSCAD/lib-arc.html)
|
||||
- [pie](https://openhome.cc/eGossip/OpenSCAD/lib-pie.html)
|
||||
- [ellipse](https://openhome.cc/eGossip/OpenSCAD/lib-ellipse.html)
|
||||
- [rounded_square](https://openhome.cc/eGossip/OpenSCAD/lib-rounded_square.html)
|
||||
- [line2d](https://openhome.cc/eGossip/OpenSCAD/lib-line2d.html)
|
||||
@@ -80,7 +80,8 @@ Too many dependencies? Because OpenSCAD doesn't provide namespace management, I
|
||||
- [sphere_spiral_extrude](https://openhome.cc/eGossip/OpenSCAD/lib-sphere_spiral_extrude.html)
|
||||
|
||||
- Shape
|
||||
- [shape_ellipse](https://openhome.cc/eGossip/OpenSCAD/lib-shape_ellipse.html)
|
||||
- [shape_pie](https://openhome.cc/eGossip/OpenSCAD/lib-shape_pie.html)
|
||||
- [shape_ellipse](https://openhome.cc/eGossip/OpenSCAD/lib-shape_ellipse.html)
|
||||
- [shape_square](https://openhome.cc/eGossip/OpenSCAD/lib-shape_square.html)
|
||||
- [shape_pentagram](https://openhome.cc/eGossip/OpenSCAD/lib-shape_pentagram.html)
|
||||
|
||||
|
BIN
docs/images/lib-shape_pie-1.JPG
Normal file
BIN
docs/images/lib-shape_pie-1.JPG
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
35
docs/lib-shape_pie.md
Normal file
35
docs/lib-shape_pie.md
Normal file
@@ -0,0 +1,35 @@
|
||||
# shape_pie
|
||||
|
||||
Returns shape points and triangle indexes of a pie (circular sector) shape. They can be used with xxx_extrude modules of dotSCAD. The shape points can be also used with the built-in polygon module.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `radius` : The radius of the circle.
|
||||
- `angles` : A 2 element vector which defines the central angle. The first element of the vector is the beginning angle in degrees, and the second element is the ending angle.
|
||||
- `$fa`, `$fs`, `$fn` : Check [the circle module](https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_the_2D_Subsystem#circle) for more details.
|
||||
|
||||
## Examples
|
||||
|
||||
include <shape_pie.scad>;
|
||||
|
||||
shape_pts_tris = shape_pie(10, [45, 315], $fn = 24);
|
||||
|
||||

|
||||
|
||||
include <shape_pie.scad>;
|
||||
include <helix.scad>;
|
||||
include <rotate_p.scad>;
|
||||
include <cross_sections.scad>;
|
||||
include <polysections.scad>;
|
||||
include <helix_extrude.scad>;
|
||||
|
||||
shape_pts_tris = shape_pie(10, [45, 315], $fn = 8);
|
||||
|
||||
helix_extrude(shape_pts_tris[0],
|
||||
radius = 40,
|
||||
levels = 5,
|
||||
level_dist = 20,
|
||||
triangles = shape_pts_tris[1]
|
||||
);
|
||||
|
||||

|
40
src/shape_pie.scad
Normal file
40
src/shape_pie.scad
Normal file
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* shape_pie.scad
|
||||
*
|
||||
* Returns shape points and triangle indexes of a pie (circular sector) shape.
|
||||
* They can be used with xxx_extrude modules of dotSCAD.
|
||||
* The shape points can be also used with the built-in polygon module.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
* @see https://openhome.cc/eGossip/OpenSCAD/lib-shape_pie.html
|
||||
*
|
||||
**/
|
||||
|
||||
include <__private__/__frags.scad>;
|
||||
|
||||
function shape_pie(radius, angles) =
|
||||
let(
|
||||
frags = __frags(radius),
|
||||
a_step = 360 / frags,
|
||||
leng = radius * cos(a_step / 2),
|
||||
m = floor(angles[0] / a_step) + 1,
|
||||
n = floor(angles[1] / a_step),
|
||||
edge_r_begin = leng / cos((m - 0.5) * a_step - angles[0]),
|
||||
edge_r_end = leng / cos((n + 0.5) * a_step - angles[1]),
|
||||
shape_pts = concat(
|
||||
[[0, 0], edge_r_begin * [cos(angles[0]), sin(angles[0])]],
|
||||
[
|
||||
for(i = [m:n])
|
||||
let(a = a_step * i)
|
||||
radius * [cos(a), sin(a)]
|
||||
],
|
||||
[edge_r_end * [cos(angles[1]), sin(angles[1])]]
|
||||
),
|
||||
triangles = [for(i = [1:len(shape_pts) - 2]) [0, i, i + 1]]
|
||||
)
|
||||
[
|
||||
shape_pts,
|
||||
triangles
|
||||
];
|
Reference in New Issue
Block a user