mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-01-29 11:58:39 +01:00
add math_constans
This commit is contained in:
parent
4f117a2946
commit
d4d498fed0
56
examples/math_constans.scad
Normal file
56
examples/math_constans.scad
Normal file
@ -0,0 +1,56 @@
|
||||
use <fibonacci_lattice.scad>;
|
||||
use <hull_polyline3d.scad>;
|
||||
use <polyhedron_hull.scad>;
|
||||
|
||||
n = 150;
|
||||
radius = 12;
|
||||
constants = [
|
||||
"π3.141592653589793238462643383279502884197169399375105820974944592307816406286",
|
||||
"τ6.2831853071795864769252867665590057683943387987502116419498891846156328",
|
||||
"φ1.6180339887498948482045868343656381177203091798057628621354486227052604",
|
||||
"e2.7182818284590452353602874713526624977572470936999595749669676277240766303535"
|
||||
];
|
||||
|
||||
font_name = "Arial Black";
|
||||
font_size = 2.5;
|
||||
txt_extrude = radius * 0.5;
|
||||
txt_scale = 1.5;
|
||||
|
||||
math_constants(n, radius, constants, font_name, font_size, txt_extrude, txt_scale);
|
||||
|
||||
module math_constants(n, radius, constants, font_name, font_size, txt_extrude, txt_scale) {
|
||||
|
||||
pts = fibonacci_lattice(n, radius);
|
||||
|
||||
polyhedron_hull(pts * 0.9);
|
||||
|
||||
spirals = [for(j = [0:9])
|
||||
[for(i = j; i < len(pts); i = i + 8) pts[i]]
|
||||
];
|
||||
|
||||
module constant_on_spiral(constant, spiral) {
|
||||
for(i = [0:len(spiral) - 1]) {
|
||||
x = spiral[i][0];
|
||||
y = spiral[i][1];
|
||||
z = spiral[i][2];
|
||||
ya = atan2(z, sqrt(x * x + y * y));
|
||||
za = atan2(y, x);
|
||||
|
||||
render()
|
||||
translate(spiral[i])
|
||||
rotate([0, -ya, za])
|
||||
rotate([90, 0, -90])
|
||||
linear_extrude(txt_extrude, scale = txt_scale)
|
||||
mirror([-1, 0, 0])
|
||||
text(constant[i], size = font_size, font = font_name, valign = "center", halign = "center");
|
||||
}
|
||||
}
|
||||
|
||||
for(i = [0:2:8]) {
|
||||
constant_on_spiral(constants[i / 2], spirals[i + 1]);
|
||||
}
|
||||
|
||||
for(i = [0:2:9]) {
|
||||
hull_polyline3d(spirals[i] * 0.9, 1, $fn = 4);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user