1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-07-31 20:10:36 +02:00

refactor deps

This commit is contained in:
Justin Lin
2020-01-27 16:20:33 +08:00
parent e6274d6202
commit e98fd39278
3 changed files with 24 additions and 20 deletions

View File

@@ -0,0 +1,20 @@
use <__comm__/__ra_to_xy.scad>;
use <__comm__/__to_degree.scad>;
function _superformula_r(angle, m1, m2, n1, n2 = 1, n3 = 1, a = 1, b = 1) =
pow(
pow(abs(cos(m1 * angle / 4) / a), n2) +
pow(abs(sin(m2 * angle / 4) / b), n3),
- 1 / n1
);
function _shape_superformula_impl(phi_step, m1, m2, n1, n2 = 1, n3 = 1, a = 1, b = 1) =
let(tau = PI * 2)
[
for(phi = 0; phi <= tau; phi = phi + phi_step)
let(
angle = __to_degree(phi),
r = _superformula_r(angle, m1, m2, n1, n2, n3, a, b)
)
__ra_to_xy(r, angle)
];

View File

@@ -8,23 +8,7 @@
*
**/
include <__comm__/__ra_to_xy.scad>;
include <__comm__/__to_degree.scad>;
function _superformula_r(angle, m1, m2, n1, n2 = 1, n3 = 1, a = 1, b = 1) =
pow(
pow(abs(cos(m1 * angle / 4) / a), n2) +
pow(abs(sin(m2 * angle / 4) / b), n3),
- 1 / n1
);
use <_impl/_shape_superformula_impl.scad>;
function shape_superformula(phi_step, m1, m2, n1, n2 = 1, n3 = 1, a = 1, b = 1) =
let(tau = PI * 2)
[
for(phi = 0; phi <= tau; phi = phi + phi_step)
let(
angle = __to_degree(phi),
r = _superformula_r(angle, m1, m2, n1, n2, n3, a, b)
)
__ra_to_xy(r, angle)
];
_shape_superformula_impl(phi_step, m1, m2, n1, n2, n3, a, b);

View File

@@ -1,5 +1,5 @@
include <unittest.scad>;
include <shape_superformula.scad>;
use <unittest.scad>;
use <shape_superformula.scad>;
module test_shape_superformula() {
echo("==== test_shape_superformula ====");