mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-03-14 02:59:42 +01:00
added shape_superformula.scad
This commit is contained in:
parent
5d01287e80
commit
caffb7a554
1
src/__private__/__to_degree.scad
Normal file
1
src/__private__/__to_degree.scad
Normal file
@ -0,0 +1 @@
|
||||
function __to_degree(phi) = 180 / 3.14159 * phi;
|
30
src/shape_superformula.scad
Normal file
30
src/shape_superformula.scad
Normal file
@ -0,0 +1,30 @@
|
||||
include <__private__/__ra_to_xy.scad>;
|
||||
include <__private__/__to_degree.scad>;
|
||||
include <__private__/__triangles_radial.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) =
|
||||
let(
|
||||
pts = [
|
||||
for(phi = [0:phi_step: 6.28318])
|
||||
let(
|
||||
angle = __to_degree(phi),
|
||||
r = _superformula_r(angle, m1, m2, n1, n2, n3, a, b)
|
||||
|
||||
)
|
||||
__ra_to_xy(r, angle)
|
||||
],
|
||||
shape_pts = concat([[0, 0]], pts, [pts[0]]),
|
||||
triangles = __triangles_radial(shape_pts)
|
||||
|
||||
)
|
||||
[
|
||||
shape_pts,
|
||||
triangles
|
||||
];
|
Loading…
x
Reference in New Issue
Block a user