poly_cylinder() now has a twist parameter.
This commit is contained in:
parent
fa658d9eaa
commit
73d814d2fe
17
readme.md
17
readme.md
|
@ -6116,6 +6116,16 @@ it gets the linear dimensions right. See <https://hydraraptor.blogspot.com/2011/
|
||||||
|
|
||||||
The module provides `poly_circle()`, `poly_cylinder()` and `poly_ring()` that is useful for making printed washers and pillars.
|
The module provides `poly_circle()`, `poly_cylinder()` and `poly_ring()` that is useful for making printed washers and pillars.
|
||||||
|
|
||||||
|
`poly_cylinder()` has a `twist` parameter which can be set to make the polygon rotate each layer.
|
||||||
|
This can be used to mitigate the number of sides being small and make small holes stronger and more round, but is quite slow due to the
|
||||||
|
large increase in the number of facets.
|
||||||
|
When set to 1 the polygons alternate each layer, when set higher the rotation takes `twist + 1` layers to repeat.
|
||||||
|
A small additional rotation is added to make the polygon rotate one more side over the length of the hole to make it appear round when
|
||||||
|
veiwed end on.
|
||||||
|
|
||||||
|
When `twist` is set the resulting cylinder is extended by `eps` at each end so that the exact length of the hole can be used without
|
||||||
|
leaving a scar on either surface.
|
||||||
|
|
||||||
|
|
||||||
[utils/core/polyholes.scad](utils/core/polyholes.scad) Implementation.
|
[utils/core/polyholes.scad](utils/core/polyholes.scad) Implementation.
|
||||||
|
|
||||||
|
@ -6133,7 +6143,7 @@ The module provides `poly_circle()`, `poly_cylinder()` and `poly_ring()` that is
|
||||||
|:--- |:--- |
|
|:--- |:--- |
|
||||||
| ```drill(r, h = 100, center = true)``` | Make a cylinder for drilling holes suitable for CNC routing, set h = 0 for circle |
|
| ```drill(r, h = 100, center = true)``` | Make a cylinder for drilling holes suitable for CNC routing, set h = 0 for circle |
|
||||||
| ```poly_circle(r, sides = 0)``` | Make a circle adjusted to print the correct size |
|
| ```poly_circle(r, sides = 0)``` | Make a circle adjusted to print the correct size |
|
||||||
| ```poly_cylinder(r, h, center = false, sides = 0, chamfer = false)``` | Make a cylinder adjusted to print the correct size |
|
| ```poly_cylinder(r, h, center = false, sides = 0, chamfer = false, twist = 0)``` | Make a cylinder adjusted to print the correct size |
|
||||||
| ```poly_drill(r, h = 100, center = true)``` | Make a cylinder for drilling holes suitable for CNC routing if cnc_bit_r is non zero, otherwise a poly_cylinder. |
|
| ```poly_drill(r, h = 100, center = true)``` | Make a cylinder for drilling holes suitable for CNC routing if cnc_bit_r is non zero, otherwise a poly_cylinder. |
|
||||||
| ```poly_ring(or, ir, sides = 0)``` | Make a 2D ring adjusted to have the correct internal radius |
|
| ```poly_ring(or, ir, sides = 0)``` | Make a 2D ring adjusted to have the correct internal radius |
|
||||||
| ```poly_tube(or, ir, h, center = false)``` | Make a tube adjusted to have the correct internal radius |
|
| ```poly_tube(or, ir, h, center = false)``` | Make a tube adjusted to have the correct internal radius |
|
||||||
|
@ -6167,6 +6177,11 @@ The module provides `poly_circle()`, `poly_cylinder()` and `poly_ring()` that is
|
||||||
| 1 | ```rod(9.5, 43)``` | Smooth rod 9.5mm x 43mm |
|
| 1 | ```rod(9.5, 43)``` | Smooth rod 9.5mm x 43mm |
|
||||||
| 1 | ```rod(9, 41)``` | Smooth rod 9mm x 41mm |
|
| 1 | ```rod(9, 41)``` | Smooth rod 9mm x 41mm |
|
||||||
|
|
||||||
|
### Printed
|
||||||
|
| Qty | Filename |
|
||||||
|
| ---:|:--- |
|
||||||
|
| 1 | polyhole.stl |
|
||||||
|
|
||||||
|
|
||||||
<a href="#top">Top</a>
|
<a href="#top">Top</a>
|
||||||
|
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 114 KiB After Width: | Height: | Size: 136 KiB |
|
@ -21,30 +21,60 @@ include <../utils/core/core.scad>
|
||||||
use <../vitamins/rod.scad>
|
use <../vitamins/rod.scad>
|
||||||
include <../vitamins/sheets.scad>
|
include <../vitamins/sheets.scad>
|
||||||
|
|
||||||
module polyholes() {
|
module positions()
|
||||||
module positions()
|
for(i = [1 : 10]) {
|
||||||
for(i = [1 : 10]) {
|
translate([(i * i + i) / 2 + 3 * i , 8])
|
||||||
translate([(i * i + i) / 2 + 3 * i , 8])
|
let($r = i / 2)
|
||||||
let($r = i / 2)
|
children();
|
||||||
|
|
||||||
|
let(d = i + 0.5)
|
||||||
|
translate([(d * d + d) / 2 + 3 * d, 19])
|
||||||
|
let($r = d / 2)
|
||||||
children();
|
children();
|
||||||
|
}
|
||||||
|
|
||||||
let(d = i + 0.5)
|
module polyhole_stl() {
|
||||||
translate([(d * d + d) / 2 + 3 * d, 19])
|
stl("polyhole");
|
||||||
let($r = d / 2)
|
|
||||||
children();
|
|
||||||
}
|
|
||||||
|
|
||||||
stl_colour(pp1_colour) linear_extrude(3, center = true)
|
linear_extrude(3, center = true)
|
||||||
difference() {
|
difference() {
|
||||||
square([100, 27]);
|
square([100, 27]);
|
||||||
|
|
||||||
positions()
|
positions()
|
||||||
poly_circle(r = $r);
|
poly_circle(r = $r);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
positions()
|
module alt_polyhole_stl() {
|
||||||
|
holes = [2.5, 2, 1.5];
|
||||||
|
n = len(holes);
|
||||||
|
size = [n * 10, 10, 10];
|
||||||
|
difference() {
|
||||||
|
translate([-size.x / n / 2, $preview ? 0 : -size.y / 2])
|
||||||
|
cube($preview ? [size.x, size.y / 2, size.z] : size);
|
||||||
|
|
||||||
|
for(i = [0 : n - 1])
|
||||||
|
translate([i * 10, 0])
|
||||||
|
if(i % 2)
|
||||||
|
translate_z(size.z)
|
||||||
|
poly_cylinder(r = holes[i] / 2, h = 2 * size.z, center = true, twist = i + 1);
|
||||||
|
else
|
||||||
|
poly_cylinder(r = holes[i] / 2, h = size.z, center = false, twist = i + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module polyholes() {
|
||||||
|
stl_colour(pp1_colour)
|
||||||
|
polyhole_stl();
|
||||||
|
|
||||||
|
positions()
|
||||||
rod(d = 2 * $r, l = 8 * $r + 5);
|
rod(d = 2 * $r, l = 8 * $r + 5);
|
||||||
//
|
//
|
||||||
|
// Alternating polyholes
|
||||||
|
//
|
||||||
|
translate([30, -40])
|
||||||
|
alt_polyhole_stl();
|
||||||
|
//
|
||||||
// Poly rings
|
// Poly rings
|
||||||
//
|
//
|
||||||
ir = 3 / 2;
|
ir = 3 / 2;
|
||||||
|
@ -74,4 +104,11 @@ module polyholes() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
polyholes();
|
if($preview)
|
||||||
|
polyholes();
|
||||||
|
else {
|
||||||
|
polyhole_stl();
|
||||||
|
|
||||||
|
translate([50, -20])
|
||||||
|
alt_polyhole_stl();
|
||||||
|
}
|
||||||
|
|
|
@ -22,6 +22,16 @@
|
||||||
//! it gets the linear dimensions right. See <https://hydraraptor.blogspot.com/2011/02/polyholes.html>
|
//! it gets the linear dimensions right. See <https://hydraraptor.blogspot.com/2011/02/polyholes.html>
|
||||||
//!
|
//!
|
||||||
//! The module provides `poly_circle()`, `poly_cylinder()` and `poly_ring()` that is useful for making printed washers and pillars.
|
//! The module provides `poly_circle()`, `poly_cylinder()` and `poly_ring()` that is useful for making printed washers and pillars.
|
||||||
|
//!
|
||||||
|
//! `poly_cylinder()` has a `twist` parameter which can be set to make the polygon rotate each layer.
|
||||||
|
//! This can be used to mitigate the number of sides being small and make small holes stronger and more round, but is quite slow due to the
|
||||||
|
//! large increase in the number of facets.
|
||||||
|
//! When set to 1 the polygons alternate each layer, when set higher the rotation takes `twist + 1` layers to repeat.
|
||||||
|
//! A small additional rotation is added to make the polygon rotate one more side over the length of the hole to make it appear round when
|
||||||
|
//! veiwed end on.
|
||||||
|
//!
|
||||||
|
//! When `twist` is set the resulting cylinder is extended by `eps` at each end so that the exact length of the hole can be used without
|
||||||
|
//! leaving a scar on either surface.
|
||||||
//
|
//
|
||||||
function sides(r) = max(round(4 * r), 3); //! Optimium number of sides for specified radius
|
function sides(r) = max(round(4 * r), 3); //! Optimium number of sides for specified radius
|
||||||
function corrected_radius(r, n = 0) = r / cos(180 / (n ? n : sides(r))); //! Adjusted radius to make flats lie on the circle
|
function corrected_radius(r, n = 0) = r / cos(180 / (n ? n : sides(r))); //! Adjusted radius to make flats lie on the circle
|
||||||
|
@ -32,9 +42,26 @@ module poly_circle(r, sides = 0) { //! Make a circle adjusted to print the corre
|
||||||
circle(r = corrected_radius(r,n), $fn = n);
|
circle(r = corrected_radius(r,n), $fn = n);
|
||||||
}
|
}
|
||||||
|
|
||||||
module poly_cylinder(r, h, center = false, sides = 0, chamfer = false) {//! Make a cylinder adjusted to print the correct size
|
module poly_cylinder(r, h, center = false, sides = 0, chamfer = false, twist = 0) {//! Make a cylinder adjusted to print the correct size
|
||||||
extrude_if(h, center)
|
if(twist) {
|
||||||
poly_circle(r, sides);
|
slices = ceil(h / layer_height);
|
||||||
|
twist = min(twist, slices - 1);
|
||||||
|
sides = sides ? sides : sides(r);
|
||||||
|
rot = 360 / sides / (twist + 1) * (1 + 1 / slices);
|
||||||
|
if(center)
|
||||||
|
for(side = [0, 1])
|
||||||
|
mirror([0, 0, side])
|
||||||
|
poly_cylinder(r = r, h = h / 2, sides = sides, twist = twist);
|
||||||
|
else
|
||||||
|
render(convexity = 5)
|
||||||
|
for(i = [0 : slices - 1])
|
||||||
|
translate_z(i * layer_height - eps)
|
||||||
|
rotate(rot * i)
|
||||||
|
poly_cylinder(r = r, h = layer_height + 2 * eps, sides = sides);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
extrude_if(h, center)
|
||||||
|
poly_circle(r, sides);
|
||||||
|
|
||||||
if(h && chamfer)
|
if(h && chamfer)
|
||||||
poly_cylinder(r + layer_height, center ? layer_height * 2 : layer_height, center, sides = sides ? sides : sides(r));
|
poly_cylinder(r + layer_height, center ? layer_height * 2 : layer_height, center, sides = sides ? sides : sides(r));
|
||||||
|
|
Loading…
Reference in New Issue