mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-13 02:04:16 +02:00
added circle_path
This commit is contained in:
@@ -24,4 +24,5 @@ I've been using OpenSCAD for years and created some funny things. Some of them i
|
|||||||
- [bend](https://openhome.cc/eGossip/OpenSCAD/lib-bend.html)
|
- [bend](https://openhome.cc/eGossip/OpenSCAD/lib-bend.html)
|
||||||
|
|
||||||
- Path
|
- Path
|
||||||
|
- [circle_path](https://openhome.cc/eGossip/OpenSCAD/lib-circle_path.html)
|
||||||
- [bezier](https://openhome.cc/eGossip/OpenSCAD/lib-bezier.html)
|
- [bezier](https://openhome.cc/eGossip/OpenSCAD/lib-bezier.html)
|
||||||
|
BIN
docs/images/lib-circle_path-1.JPG
Normal file
BIN
docs/images/lib-circle_path-1.JPG
Normal file
Binary file not shown.
After Width: | Height: | Size: 33 KiB |
27
docs/lib-circle_path.md
Normal file
27
docs/lib-circle_path.md
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
# circle_path
|
||||||
|
|
||||||
|
Sometimes you need all points on the path of a circle. Here's the function. Its `$fa`, `$fs` and `$fn` parameters are consistent with the `circle` module.
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
- `radius` : The radius of the circle.
|
||||||
|
- `$fa`, `$fs`, `$fn` : Check [the circle module](https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_the_2D_Subsystem#circle) for more details.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
$fn = 24;
|
||||||
|
|
||||||
|
points = circle_path(radius = 50);
|
||||||
|
polygon(points);
|
||||||
|
|
||||||
|
leng = len(points);
|
||||||
|
step_angle = 360 / leng;
|
||||||
|
for(i = [0:leng - 1]) {
|
||||||
|
translate(points[i])
|
||||||
|
rotate([90, 0, 90 + i * step_angle])
|
||||||
|
linear_extrude(1, center = true)
|
||||||
|
text("A", valign = "center", halign = "center");
|
||||||
|
}
|
||||||
|
|
||||||
|

|
||||||
|
|
23
src/circle_path.scad
Normal file
23
src/circle_path.scad
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
/**
|
||||||
|
* circle_path.scad
|
||||||
|
*
|
||||||
|
* Sometimes you need all points on the path of a circle. Here's
|
||||||
|
* the function. Its $fa, $fs and $fn parameters are consistent
|
||||||
|
* with the circle module.
|
||||||
|
*
|
||||||
|
* @copyright Justin Lin, 2017
|
||||||
|
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||||
|
*
|
||||||
|
* @see https://openhome.cc/eGossip/OpenSCAD/lib-circle_path.html
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
|
||||||
|
function _frags(radius) = $fn > 0 ?
|
||||||
|
($fn >= 3 ? $fn : 3) :
|
||||||
|
max(min(360 / $fa, radius * 2 * 3.14159 / $fs), 5);
|
||||||
|
|
||||||
|
function circle_path(radius) =
|
||||||
|
[
|
||||||
|
for(a = [0 : 360 / _frags(radius) : 360 - 360 / _frags(radius)])
|
||||||
|
[radius * cos(a), radius * sin(a)]
|
||||||
|
];
|
Reference in New Issue
Block a user