1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-03-14 02:59:42 +01:00

use circle_shape

This commit is contained in:
Justin Lin 2020-03-17 11:26:51 +08:00
parent ac98beb1c5
commit f0b8da8a25
4 changed files with 30 additions and 7 deletions

View File

@ -1,6 +1,6 @@
use <__comm__/__fast_fibonacci.scad>;
use <rotate_p.scad>;
use <circle_path.scad>;
use <circle_shape.scad>;
function _fast_fibonacci_sub(nth) =
let(
@ -29,7 +29,7 @@ function _golden_spiral_from_ls_or_eql_to(from, to, point_distance, rt_dir) =
f2 = __fast_fibonacci(from + 1),
fn = floor(f1 * 6.28312 / point_distance),
$fn = fn + 4 - (fn % 4),
circle_pts = circle_path(radius = f1, n = $fn / 4 + 1),
circle_pts = circle_shape(radius = f1, n = $fn / 4 + 1),
len_pts = len(circle_pts),
a_step = 360 / $fn * rt_dir,
range_i = [0:len_pts - 1],

22
src/circle_shape.scad Normal file
View File

@ -0,0 +1,22 @@
/**
* circle_shape.scad
*
* @copyright Justin Lin, 2017
* @license https://opensource.org/licenses/lgpl-3.0.html
*
* @see https://openhome.cc/eGossip/OpenSCAD/lib2x-circle_shape.html
*
**/
use <__comm__/__frags.scad>;
function circle_shape(radius, n) =
let(
_frags = __frags(radius),
step_a = 360 / _frags,
end_a = 360 - step_a * ((is_undef(n) || n > _frags) ? 1 : _frags - n + 1)
)
[
for(a = 0; a <= end_a; a = a + step_a)
[radius * cos(a), radius * sin(a)]
];

View File

@ -1,5 +1,5 @@
use <shape_starburst.scad>;
use <circle_path.scad>;
use <circle_shape.scad>;
use <rotate_p.scad>;
use <experimental/loft.scad>;
@ -15,16 +15,16 @@ translate([30, 0, 0])
difference() {
loft(
[
[for(p = circle_path(10, $fn = 3)) [p[0], p[1], 15]],
[for(p = circle_path(15, $fn = 24)) [p[0], p[1], 0]]
[for(p = circle_shape(10, $fn = 3)) [p[0], p[1], 15]],
[for(p = circle_shape(15, $fn = 24)) [p[0], p[1], 0]]
],
slices = 4
);
loft(
[
[for(p = circle_path(8, $fn = 3)) [p[0], p[1], 15.1]],
[for(p = circle_path(13, $fn = 24)) [p[0], p[1], -0.1]]
[for(p = circle_shape(8, $fn = 3)) [p[0], p[1], 15.1]],
[for(p = circle_shape(13, $fn = 24)) [p[0], p[1], -0.1]]
],
slices = 4
);

View File

@ -1,5 +1,6 @@
- deprecate `polysections`, use `sweep`.
- deprecate `trianglate`, use `tri_ear_clipping`.
- deprecate `circle_path`, `use circle_shape`.
Preview