mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-09-02 03:02:34 +02:00
added rotate_p
This commit is contained in:
BIN
docs/images/lib-rotate_p-1.JPG
Normal file
BIN
docs/images/lib-rotate_p-1.JPG
Normal file
Binary file not shown.
After Width: | Height: | Size: 32 KiB |
BIN
docs/images/lib-rotate_p-2.JPG
Normal file
BIN
docs/images/lib-rotate_p-2.JPG
Normal file
Binary file not shown.
After Width: | Height: | Size: 32 KiB |
57
docs/lib-rotate_p.md
Normal file
57
docs/lib-rotate_p.md
Normal file
@@ -0,0 +1,57 @@
|
||||
# rotate_p
|
||||
|
||||
Rotates a point `a` degrees around an arbitrary axis. The rotation is applied in the following order: `x`, `y`, `z`.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `point` : The point `[x, y, z]`.
|
||||
- `a` : An array `[deg_x, deg_y, deg_z]`. The same as the `a` parameter of the built-in `rotate`.
|
||||
|
||||
## Examples
|
||||
|
||||
You can use the code below to create a line.
|
||||
|
||||
hull() {
|
||||
sphere(1);
|
||||
rotate([0, -45, 45])
|
||||
translate([20, 0, 0])
|
||||
sphere(1);
|
||||
}
|
||||
|
||||
The following code have the same effect.
|
||||
|
||||
point = [20, 0, 0];
|
||||
a = [0, -45, 45];
|
||||
|
||||
hull() {
|
||||
sphere(1);
|
||||
translate(rotate_p(point, a))
|
||||
rotate(a)
|
||||
sphere(1);
|
||||
}
|
||||
|
||||

|
||||
|
||||
The `rotate_p` function is useful in some situations. For examples, you probably want to get all points on the path of a spiral around a sphere.
|
||||
|
||||
radius = 40;
|
||||
step_angle = 10;
|
||||
z_circles = 20;
|
||||
|
||||
points_angles = [for(a = [0:step_angle:90 * z_circles])
|
||||
rotate_p(
|
||||
[radius, 0, 0],
|
||||
[0, -90 + 2 * a / z_circles, a]
|
||||
)
|
||||
];
|
||||
|
||||
// Once you get all points on the path, you can place anything at each point.
|
||||
// I just place a sphere as a simple demonstration.
|
||||
for(pa = points_angles) {
|
||||
translate(pa[0])
|
||||
sphere(1);
|
||||
}
|
||||
|
||||
%sphere(radius);
|
||||
|
||||

|
Reference in New Issue
Block a user