1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-17 14:18:13 +01:00
dotSCAD/examples/spiral/bauer_text_sphere.scad

43 lines
1.7 KiB
OpenSCAD
Raw Normal View History

2022-06-06 13:11:46 +08:00
use <bauer_spiral.scad>
2020-10-26 10:20:13 +08:00
txt = "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051";
radius = 20;
font_name = "Liberation Sans:style=Bold";
font_size = 2.5;
2020-10-27 07:14:54 +08:00
txt_extrude = radius * 0.125;
txt_scale = 1.15;
ball = true;
2020-10-26 10:20:13 +08:00
$fn = 48;
2020-10-27 07:14:54 +08:00
bauer_text_sphere(radius, font_name, font_size, txt_extrude, txt_scale, ball);
2020-10-26 10:20:13 +08:00
2020-10-27 07:14:54 +08:00
module bauer_text_sphere(radius, font_name, font_size, txt_extrude, txt_scale, ball) {
2020-10-26 10:20:13 +08:00
n = len(txt);
pts = bauer_spiral(n, radius);
2020-10-27 07:14:54 +08:00
if(ball) {
sphere(radius * 0.9);
}
2020-10-26 13:05:34 +08:00
/*
Based on Bauer's spiral:
Bauer R. Distribution of points on a sphere with application to star catalogs. Journal of Guidance, Control, and Dynamics. 2000;23(1):130137
*/
2020-10-26 10:20:13 +08:00
for(i = [0:n - 1]) {
2022-04-04 18:58:32 +08:00
x = pts[i].x;
y = pts[i].y;
z = pts[i].z;
ya = atan2(z, norm([x, y]));
2020-10-26 10:20:13 +08:00
za = atan2(y, x);
render()
translate(pts[i])
rotate([0, -ya, za])
rotate([90, 0, -90])
2020-10-27 07:14:54 +08:00
linear_extrude(txt_extrude, scale = txt_scale)
2020-10-26 10:20:13 +08:00
mirror([-1, 0, 0])
text(txt[i], size = font_size, font = font_name, valign = "center", halign = "center");
}
}