mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-09 08:16:50 +02:00
refactor deps
This commit is contained in:
20
src/_impl/_shape_superformula_impl.scad
Normal file
20
src/_impl/_shape_superformula_impl.scad
Normal 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)
|
||||||
|
];
|
@@ -8,23 +8,7 @@
|
|||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
include <__comm__/__ra_to_xy.scad>;
|
use <_impl/_shape_superformula_impl.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
|
|
||||||
);
|
|
||||||
|
|
||||||
function shape_superformula(phi_step, m1, m2, n1, n2 = 1, n3 = 1, a = 1, b = 1) =
|
function shape_superformula(phi_step, m1, m2, n1, n2 = 1, n3 = 1, a = 1, b = 1) =
|
||||||
let(tau = PI * 2)
|
_shape_superformula_impl(phi_step, m1, m2, n1, n2, n3, a, b);
|
||||||
[
|
|
||||||
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)
|
|
||||||
];
|
|
@@ -1,5 +1,5 @@
|
|||||||
include <unittest.scad>;
|
use <unittest.scad>;
|
||||||
include <shape_superformula.scad>;
|
use <shape_superformula.scad>;
|
||||||
|
|
||||||
module test_shape_superformula() {
|
module test_shape_superformula() {
|
||||||
echo("==== test_shape_superformula ====");
|
echo("==== test_shape_superformula ====");
|
||||||
|
Reference in New Issue
Block a user