mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-01-17 14:18:13 +01:00
added crystal_ball
This commit is contained in:
parent
0a60533d22
commit
0ed762361d
@ -43,6 +43,7 @@ Too many dependencies? Because OpenSCAD doesn't provide namespace management, I
|
||||
- 3D
|
||||
- [rounded_cube](https://openhome.cc/eGossip/OpenSCAD/lib-rounded_cube.html)
|
||||
- [rounded_cylinder](https://openhome.cc/eGossip/OpenSCAD/lib-rounded_cylinder.html)
|
||||
- [crystal_ball](https://openhome.cc/eGossip/OpenSCAD/lib-crystal_ball.html)
|
||||
- [line3d](https://openhome.cc/eGossip/OpenSCAD/lib-line3d.html)
|
||||
- [polyline3d](https://openhome.cc/eGossip/OpenSCAD/lib-polyline3d.html)
|
||||
- [hull_polyline3d](https://openhome.cc/eGossip/OpenSCAD/lib-hull_polyline3d.html)
|
||||
|
BIN
docs/images/lib-crystal_ball-1.JPG
Normal file
BIN
docs/images/lib-crystal_ball-1.JPG
Normal file
Binary file not shown.
After Width: | Height: | Size: 26 KiB |
49
docs/lib-crystal_ball.md
Normal file
49
docs/lib-crystal_ball.md
Normal file
@ -0,0 +1,49 @@
|
||||
# crystal_ball
|
||||
|
||||
Uses spherical coordinate system to create a crystal ball.
|
||||
|
||||
![Spherical coordinates (r, θ, φ) often used in mathematics](https://upload.wikimedia.org/wikipedia/commons/d/dc/3D_Spherical_2.svg)
|
||||
|
||||
Dependencies: `rotate_p`, `cross_sections`, `polysections`, `ring_extrude`, `shape_pie`.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `radius` : The radial distance r.
|
||||
- `theta` : The azimuthal angle. It defaults to 360. It also accepts a 2 element vector. The first element of the vector is the beginning angle in degrees, and the second element is the ending angle.
|
||||
- `phi` : The polar angle. It defaults to 180. It also accepts a 2 element vector. The first element of the vector is the beginning angle in degrees, and the second element is the ending angle.
|
||||
- `$fa`, `$fs`, `$fn` : Check [the circle module](https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_the_2D_Subsystem#circle) or [the sphere module](https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Primitive_Solids#sphere) for more details. The final fragments will be a multiple of 4 to fit edges.
|
||||
|
||||
## Examples
|
||||
|
||||
include <rotate_p.scad>;
|
||||
include <cross_sections.scad>;
|
||||
include <polysections.scad>;
|
||||
include <ring_extrude.scad>;
|
||||
include <shape_pie.scad>;
|
||||
include <crystal_ball.scad>;
|
||||
|
||||
crystal_ball(radius = 6);
|
||||
|
||||
translate([12, 0, 0])
|
||||
crystal_ball(
|
||||
radius = 6,
|
||||
theta = 270,
|
||||
$fn = 12
|
||||
);
|
||||
|
||||
translate([24, 0, 0])
|
||||
crystal_ball(
|
||||
radius = 6,
|
||||
theta = 270,
|
||||
phi = 90,
|
||||
$fn = 12
|
||||
);
|
||||
|
||||
translate([36, 0, 0])
|
||||
crystal_ball(
|
||||
radius = 6,
|
||||
theta = [-30, 270],
|
||||
phi = [30, 60]
|
||||
);
|
||||
|
||||
![crystal_ball](images/lib-crystal_ball-1.JPG)
|
35
src/crystal_ball.scad
Normal file
35
src/crystal_ball.scad
Normal file
@ -0,0 +1,35 @@
|
||||
/**
|
||||
* crystal_ball.scad
|
||||
*
|
||||
* Uses Spherical coordinate system to create a crystal ball.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
* @see https://openhome.cc/eGossip/OpenSCAD/lib-crystal_ball.html
|
||||
*
|
||||
**/
|
||||
|
||||
include <__private__/__nearest_multiple_of_4.scad>;
|
||||
include <__private__/__is_vector.scad>;
|
||||
|
||||
module crystal_ball(radius, theta = 360, phi = 180) {
|
||||
phis = __is_vector(phi) ? phi : [0, phi];
|
||||
|
||||
frags = __frags(radius);
|
||||
|
||||
shape_pts = shape_pie(
|
||||
radius,
|
||||
[90 - phis[1], 90 - phis[0]],
|
||||
$fn = __nearest_multiple_of_4(__frags(frags))
|
||||
);
|
||||
|
||||
// _hole_r = 0.0005 for avoiding warnings
|
||||
_hole_r = 0.0005;
|
||||
ring_extrude(
|
||||
shape_pts,
|
||||
angle = theta,
|
||||
radius = _hole_r,
|
||||
$fn = frags
|
||||
);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user