mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-01-29 03:47:45 +01:00
added sphere_spiral
This commit is contained in:
parent
4d8a33e1a2
commit
3224504737
@ -47,6 +47,7 @@ Some modules may depend on other modules. For example, the `polyline2d` module d
|
||||
- [bezier](https://openhome.cc/eGossip/OpenSCAD/lib-bezier.html)
|
||||
- [cylinder_spiral](https://openhome.cc/eGossip/OpenSCAD/lib-cylinder_spiral.html)
|
||||
- [archimedean_spiral](https://openhome.cc/eGossip/OpenSCAD/lib-archimedean_spiral.html)
|
||||
- [sphere_spiral](https://openhome.cc/eGossip/OpenSCAD/lib-sphere_spiral.html)
|
||||
|
||||
- Other
|
||||
- [box_extrude](https://openhome.cc/eGossip/OpenSCAD/lib-box_extrude.html)
|
||||
|
BIN
docs/images/lib-sphere_spiral-1.JPG
Normal file
BIN
docs/images/lib-sphere_spiral-1.JPG
Normal file
Binary file not shown.
After Width: | Height: | Size: 34 KiB |
BIN
docs/images/lib-sphere_spiral-2.JPG
Normal file
BIN
docs/images/lib-sphere_spiral-2.JPG
Normal file
Binary file not shown.
After Width: | Height: | Size: 47 KiB |
BIN
docs/images/lib-sphere_spiral-3.JPG
Normal file
BIN
docs/images/lib-sphere_spiral-3.JPG
Normal file
Binary file not shown.
After Width: | Height: | Size: 42 KiB |
BIN
docs/images/lib-sphere_spiral-5.JPG
Normal file
BIN
docs/images/lib-sphere_spiral-5.JPG
Normal file
Binary file not shown.
After Width: | Height: | Size: 62 KiB |
BIN
docs/images/lib-sphere_spiral-6.JPG
Normal file
BIN
docs/images/lib-sphere_spiral-6.JPG
Normal file
Binary file not shown.
After Width: | Height: | Size: 40 KiB |
71
docs/lib-sphere_spiral.md
Normal file
71
docs/lib-sphere_spiral.md
Normal file
@ -0,0 +1,71 @@
|
||||
# sphere_spiral
|
||||
|
||||
Creates all points and angles on the path of a spiral around a sphere. It returns a vector of `[[x, y, z], [ax, ay, az]]`. `[x, y, z]` is actually obtained from rotating `[radius, 0, 0]` by `[ax, ay, az]`. It depends on the `rotate_p` function. Remember to include rotate_p.scad first.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `radius` : The radius of the sphere.
|
||||
- `za_step` : The spiral rotates around the z axis. When the rotated angle increases `za_step`, a point will be calculated.
|
||||
- `z_circles` : The spiral rotates around the z axis. This parameter determines how many circles it will rotate from the top to the end. It defaults to 1.
|
||||
- `begin_angle` : The default value is 0 which means begins from the north pole of the sphere. See examples below.
|
||||
- `end_angle` : The default value is 0 which means begins from the sourth pole of the sphere. See examples below.
|
||||
|
||||
## Examples
|
||||
|
||||
include <rotate_p.scad>;
|
||||
include <hull_polyline3d.scad>;
|
||||
include <sphere_spiral.scad>;
|
||||
|
||||
points_angles = sphere_spiral(
|
||||
radius = 40,
|
||||
za_step = 10,
|
||||
z_circles = 20,
|
||||
begin_angle = 90,
|
||||
end_angle = 90
|
||||
);
|
||||
|
||||
hull_polyline3d([for(pa = points_angles) pa[0]], 1);
|
||||
|
||||
%sphere(40);
|
||||
|
||||
![sphere_spiral](images/lib-sphere_spiral-1.JPG)
|
||||
|
||||
![sphere_spiral](images/lib-sphere_spiral-2.JPG)
|
||||
|
||||
![sphere_spiral](images/lib-sphere_spiral-3.JPG)
|
||||
|
||||
include <rotate_p.scad>;
|
||||
include <sphere_spiral.scad>;
|
||||
|
||||
points_angles = sphere_spiral(
|
||||
radius = 40,
|
||||
za_step = 20,
|
||||
z_circles = 40,
|
||||
begin_angle = 900
|
||||
);
|
||||
|
||||
for(pa = points_angles) {
|
||||
translate(pa[0]) rotate(pa[1])
|
||||
rotate([90, 0, 90]) linear_extrude(1)
|
||||
text("A", valign = "center", halign = "center");
|
||||
}
|
||||
|
||||
%sphere(40);
|
||||
|
||||
![sphere_spiral](images/lib-sphere_spiral-5.JPG)
|
||||
|
||||
include <rotate_p.scad>;
|
||||
include <hull_polyline3d.scad>;
|
||||
include <sphere_spiral.scad>;
|
||||
|
||||
points_angles = sphere_spiral(
|
||||
radius = 40,
|
||||
za_step = 5
|
||||
);
|
||||
|
||||
for(a = [0:30:360]) {
|
||||
rotate(a)
|
||||
hull_polyline3d([for(pa = points_angles) pa[0]], 2);
|
||||
}
|
||||
|
||||
![sphere_spiral](images/lib-sphere_spiral-5.JPG)
|
21
src/sphere_spiral.scad
Normal file
21
src/sphere_spiral.scad
Normal file
@ -0,0 +1,21 @@
|
||||
/**
|
||||
* sphere_spiral.scad
|
||||
*
|
||||
* Creates all points and angles on the path of a spiral around a sphere.
|
||||
* It returns a vector of [[x, y, z], [ax, ay, az]]. [x, y, z] is actually
|
||||
* obtained from rotating [radius, 0, 0] by [ax, ay, az].
|
||||
* It depends on the rotate_p function. Remember to include rotate_p.scad first.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
* @see https://openhome.cc/eGossip/OpenSCAD/lib-sphere_spiral.html
|
||||
*
|
||||
**/
|
||||
|
||||
function sphere_spiral(radius, za_step, z_circles = 1, begin_angle = 0, end_angle = 0) =
|
||||
[
|
||||
for(a = [begin_angle:za_step:90 * z_circles - end_angle])
|
||||
let(ra = [0, -90 + 2 * a / z_circles, a])
|
||||
[rotate_p([radius, 0, 0], ra), ra]
|
||||
];
|
Loading…
x
Reference in New Issue
Block a user