2017-05-23 08:27:36 +08:00
|
|
|
/**
|
|
|
|
* crystal_ball.scad
|
|
|
|
*
|
|
|
|
* @copyright Justin Lin, 2017
|
|
|
|
* @license https://opensource.org/licenses/lgpl-3.0.html
|
|
|
|
*
|
2021-02-17 18:08:06 +08:00
|
|
|
* @see https://openhome.cc/eGossip/OpenSCAD/lib3x-crystal_ball.html
|
2017-05-23 08:27:36 +08:00
|
|
|
*
|
|
|
|
**/
|
|
|
|
|
2022-06-06 13:11:46 +08:00
|
|
|
use <__comm__/__nearest_multiple_of_4.scad>
|
|
|
|
use <__comm__/__frags.scad>
|
|
|
|
use <shape_arc.scad>
|
|
|
|
use <shape_pie.scad>
|
|
|
|
use <ring_extrude.scad>
|
2017-05-23 08:27:36 +08:00
|
|
|
|
2019-10-04 09:05:14 +08:00
|
|
|
module crystal_ball(radius, theta = 360, phi = 180, thickness) {
|
2019-06-11 08:39:57 +08:00
|
|
|
phis = is_num(phi) ? [0, phi] : phi;
|
2017-05-23 08:27:36 +08:00
|
|
|
|
|
|
|
frags = __frags(radius);
|
|
|
|
|
2019-10-04 09:05:14 +08:00
|
|
|
angle = [90 - phis[1], 90 - phis[0]];
|
|
|
|
|
|
|
|
shape_pts = is_undef(thickness) ?
|
2020-01-27 10:18:36 +08:00
|
|
|
shape_pie(
|
2019-10-04 09:05:14 +08:00
|
|
|
radius,
|
|
|
|
angle ,
|
|
|
|
$fn = __nearest_multiple_of_4(frags)
|
|
|
|
) :
|
2020-01-27 10:18:36 +08:00
|
|
|
shape_arc(
|
2019-10-04 09:05:14 +08:00
|
|
|
radius,
|
|
|
|
angle,
|
|
|
|
width = thickness,
|
|
|
|
width_mode = "LINE_INWARD",
|
|
|
|
$fn = __nearest_multiple_of_4(frags)
|
|
|
|
);
|
2017-05-23 09:13:26 +08:00
|
|
|
|
2017-05-23 08:27:36 +08:00
|
|
|
ring_extrude(
|
|
|
|
shape_pts,
|
|
|
|
angle = theta,
|
2019-06-11 09:30:07 +08:00
|
|
|
radius = 0,
|
2017-05-23 08:27:36 +08:00
|
|
|
$fn = frags
|
|
|
|
);
|
2017-06-02 10:26:11 +08:00
|
|
|
|
|
|
|
// hook for testing
|
|
|
|
test_crystal_ball_pie(shape_pts);
|
|
|
|
}
|
|
|
|
|
|
|
|
// override it to test
|
|
|
|
module test_crystal_ball_pie(shape_pts) {
|
|
|
|
|
2017-05-23 08:27:36 +08:00
|
|
|
}
|