mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-22 22:35:18 +02:00
extract fast fib
This commit is contained in:
15
src/__comm__/__fast_fibonacci.scad
Normal file
15
src/__comm__/__fast_fibonacci.scad
Normal file
@@ -0,0 +1,15 @@
|
||||
function __fast_fibonacci_sub(nth) =
|
||||
let(
|
||||
_f = __fast_fibonacci_2_elems(floor(nth / 2)),
|
||||
a = _f[0],
|
||||
b = _f[1],
|
||||
c = a * (b * 2 - a),
|
||||
d = a * a + b * b
|
||||
)
|
||||
nth % 2 == 0 ? [c, d] : [d, c + d];
|
||||
|
||||
function __fast_fibonacci_2_elems(nth) =
|
||||
nth == 0 ? [0, 1] : __fast_fibonacci_sub(nth);
|
||||
|
||||
function __fast_fibonacci(nth) =
|
||||
__fast_fibonacci_2_elems(nth)[0];
|
@@ -8,6 +8,8 @@
|
||||
*
|
||||
**/
|
||||
|
||||
include <__comm__/__fast_fibonacci.scad>;
|
||||
|
||||
function _fast_fibonacci_sub(nth) =
|
||||
let(
|
||||
_f = _fast_fibonacci_2_elems(floor(nth / 2)),
|
||||
@@ -31,8 +33,8 @@ function _remove_same_pts(pts1, pts2) =
|
||||
|
||||
function _golden_spiral_from_ls_or_eql_to(from, to, point_distance, rt_dir) =
|
||||
let(
|
||||
f1 = _fast_fibonacci(from),
|
||||
f2 = _fast_fibonacci(from + 1),
|
||||
f1 = __fast_fibonacci(from),
|
||||
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),
|
||||
|
Reference in New Issue
Block a user