mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-10 00:36:40 +02:00
added bend
This commit is contained in:
BIN
docs/images/lib-bend-1.JPG
Normal file
BIN
docs/images/lib-bend-1.JPG
Normal file
Binary file not shown.
After Width: | Height: | Size: 43 KiB |
BIN
docs/images/lib-bend-2.JPG
Normal file
BIN
docs/images/lib-bend-2.JPG
Normal file
Binary file not shown.
After Width: | Height: | Size: 34 KiB |
BIN
docs/images/lib-bend-3.JPG
Normal file
BIN
docs/images/lib-bend-3.JPG
Normal file
Binary file not shown.
After Width: | Height: | Size: 34 KiB |
51
docs/lib-bend.md
Normal file
51
docs/lib-bend.md
Normal file
@@ -0,0 +1,51 @@
|
||||
# bend
|
||||
|
||||
Bend a 3D object into an arc shape.
|
||||
|
||||
## Parameters
|
||||
|
||||
- `size` : The size of a cube which can contain the target object.
|
||||
- `angle` : The central angle of the arc shape. The radius of the arc is calculated automatically.
|
||||
- `fn` : Number of fragments. The target object will be cut into `fn` fragments and recombined into an arc shape.
|
||||
|
||||
## Examples
|
||||
|
||||
The containing cube of the target object should be laid down on the x-y plane. For examples.
|
||||
|
||||
x = 9.25;
|
||||
y = 9.55;
|
||||
z = 1;
|
||||
|
||||
%cube(size = [x, y, z]);
|
||||
linear_extrude(z) text("A");
|
||||
|
||||

|
||||
|
||||
Once you have the size of the containing cube, you can use it as the `size` argument of the `bend` module.
|
||||
|
||||
x = 9.25;
|
||||
y = 9.55;
|
||||
z = 1;
|
||||
|
||||
*cube(size = [x, y, z]);
|
||||
|
||||
bend(size = [x, y, z], angle = 270)
|
||||
linear_extrude(z) text("A");
|
||||
|
||||

|
||||
|
||||
The arc shape is smoother if the `frags` is larger.
|
||||
|
||||
x = 9.25;
|
||||
y = 9.55;
|
||||
z = 1;
|
||||
|
||||
bend(size = [x, y, z], angle = 270, frags = 360)
|
||||
linear_extrude(z)
|
||||
text("A");
|
||||
|
||||

|
||||
|
||||
This module is especially useful when you want to create things such as [zentangle bracelet](https://www.thingiverse.com/thing:1569263).
|
||||
|
||||
[](https://www.thingiverse.com/thing:1569263)
|
53
src/bend.scad
Normal file
53
src/bend.scad
Normal file
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* bend.scad
|
||||
*
|
||||
* Bend a 3D object into an arc shape.
|
||||
*
|
||||
* @copyright Justin Lin, 2017
|
||||
* @license https://opensource.org/licenses/lgpl-3.0.html
|
||||
*
|
||||
* @see https://openhome.cc/eGossip/OpenSCAD/lib-bend.html
|
||||
*
|
||||
**/
|
||||
|
||||
|
||||
module bend(size, angle, frags = 24) {
|
||||
x = size[0];
|
||||
y = size[1];
|
||||
z = size[2];
|
||||
frag_width = x / frags;
|
||||
frag_angle = angle / frags;
|
||||
half_frag_width = 0.5 * frag_width;
|
||||
half_frag_angle = 0.5 * frag_angle;
|
||||
r = half_frag_width / sin(half_frag_angle);
|
||||
h = r * cos(half_frag_angle);
|
||||
|
||||
module triangle_frag() {
|
||||
translate([0, -z, 0])
|
||||
linear_extrude(y)
|
||||
polygon(
|
||||
[
|
||||
[0, 0],
|
||||
[half_frag_width, h],
|
||||
[frag_width, 0],
|
||||
[0, 0]
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
module get_frag(i) {
|
||||
translate([-frag_width * i - half_frag_width, -h + z, 0])
|
||||
intersection() {
|
||||
translate([frag_width * i, 0, 0])
|
||||
triangle_frag();
|
||||
rotate([90, 0, 0])
|
||||
children();
|
||||
}
|
||||
}
|
||||
|
||||
for(i = [0 : frags - 1]) {
|
||||
rotate(i * frag_angle + half_frag_angle)
|
||||
get_frag(i)
|
||||
children();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user