mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2024-12-29 16:29:40 +00:00
Removed knurlings.scad as it's now handled by textures in skin.scad.
This commit is contained in:
parent
e5454a048e
commit
e4bac06df7
3 changed files with 9 additions and 205 deletions
|
@ -10,7 +10,6 @@
|
|||
|
||||
|
||||
include <threading.scad>
|
||||
include <knurling.scad>
|
||||
include <structs.scad>
|
||||
include <rounding.scad>
|
||||
|
||||
|
@ -182,13 +181,9 @@ module pco1810_cap(wall=2, texture="none", anchor=BOTTOM, spin=0, orient=UP)
|
|||
difference() {
|
||||
union() {
|
||||
if (texture == "knurled") {
|
||||
knurled_cylinder(d=w, helix=45, l=tamper_ring_h+wall, anchor=BOTTOM);
|
||||
cyl(d=w-1.5, l=tamper_ring_h+wall, anchor=BOTTOM);
|
||||
textured_cylinder(d=w, h=h, texture="diamonds", tex_size=[3,3], style="concave", anchor=BOT);
|
||||
} else if (texture == "ribbed") {
|
||||
zrot_copies(n=30, r=(w-1)/2) {
|
||||
cube([1, 1, tamper_ring_h+wall], anchor=BOTTOM);
|
||||
}
|
||||
cyl(d=w-1, l=tamper_ring_h+wall, anchor=BOTTOM);
|
||||
textured_cylinder(d=w, h=h, texture="ribs", tex_size=[3,3], style="min_edge", anchor=BOT);
|
||||
} else {
|
||||
cyl(d=w, l=tamper_ring_h+wall, anchor=BOTTOM);
|
||||
}
|
||||
|
@ -367,13 +362,9 @@ module pco1881_cap(wall=2, texture="none", anchor=BOTTOM, spin=0, orient=UP)
|
|||
difference() {
|
||||
union() {
|
||||
if (texture == "knurled") {
|
||||
knurled_cylinder(d=w, helix=45, l=11.2+wall, anchor=BOTTOM);
|
||||
cyl(d=w-1.5, l=11.2+wall, anchor=BOTTOM);
|
||||
textured_cylinder(d=w, h=11.2+wall, texture="diamonds", tex_size=[3,3], style="concave", anchor=BOT);
|
||||
} else if (texture == "ribbed") {
|
||||
zrot_copies(n=30, r=(w-1)/2) {
|
||||
cube([1, 1, 11.2+wall], anchor=BOTTOM);
|
||||
}
|
||||
cyl(d=w-1, l=11.2+wall, anchor=BOTTOM);
|
||||
textured_cylinder(d=w, h=11.2+wall, texture="ribs", tex_size=[3,3], style="min_edge", anchor=BOT);
|
||||
} else {
|
||||
cyl(d=w, l=11.2+wall, anchor=BOTTOM);
|
||||
}
|
||||
|
@ -576,13 +567,9 @@ module generic_bottle_cap(
|
|||
// thickness so the wall+texture are the specified wall thickness. That
|
||||
// seems wrong so this does specified thickness+texture
|
||||
if (texture == "knurled") {
|
||||
knurled_cylinder(d = w + 1.5 * diamMagMult, helix = 45, l = h, anchor = BOTTOM);
|
||||
cyl(d = w, l = h, anchor = BOTTOM);
|
||||
textured_cylinder(d=w + 1.5*diamMagMult, l=h, texture="diamonds", tex_size=[3,3], style="concave", anchor=BOT);
|
||||
} else if (texture == "ribbed") {
|
||||
zrot_copies(n = 30, r = (w + .2 * diamMagMult) / 2) {
|
||||
cube([1 * diamMagMult, 1 * diamMagMult, h], anchor = BOTTOM);
|
||||
}
|
||||
cyl(d = w, l = h, anchor = BOTTOM);
|
||||
textured_cylinder(d=w + 1.5*diamMagMult, l=h, texture="ribs", tex_size=[3,3], style="min_edge", anchor=BOT);
|
||||
} else {
|
||||
cyl(d = w, l = h, anchor = BOTTOM);
|
||||
}
|
||||
|
|
183
knurling.scad
183
knurling.scad
|
@ -1,183 +0,0 @@
|
|||
//////////////////////////////////////////////////////////////////////
|
||||
// LibFile: knurling.scad
|
||||
// Shapes and masks for knurling cylinders.
|
||||
// Includes:
|
||||
// include <BOSL2/std.scad>
|
||||
// include <BOSL2/knurling.scad>
|
||||
// FileGroup: Parts
|
||||
// FileSummary: Masks and shapes to create knurling.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
// Section: Knurling
|
||||
|
||||
|
||||
// Module: knurled_cylinder()
|
||||
// Usage:
|
||||
// knurled_cylinder(l|h|height, r|d=, [count=], [profile=], [helix=]);
|
||||
// knurled_cylinder(l|h|height, r1=|d1=, r2=|d2=, [count=], [profile=], [helix=]);
|
||||
// Description:
|
||||
// Creates a knurled cylinder. The knurling is made from small bumps (pyramids) arranged on the surface.
|
||||
// The
|
||||
// Arguments:
|
||||
// l / h / height = The length/height of the cylinder
|
||||
// r = The radius of the cylinder to knurl.
|
||||
// r1 = The radius of the bottom of the conical cylinder to knurl.
|
||||
// r2 = The radius of the top of the conical cylinder to knurl.
|
||||
// d = The diameter of the cylinder to knurl.
|
||||
// d1 = The diameter of the bottom of the conical cylinder to knurl.
|
||||
// d2 = The diameter of the top of the conical cylinder to knurl.
|
||||
// count = The number of bumps filling one revolution of the cylinder. Default: 30
|
||||
// profile = The lower angle between the pyramid-shaped bumps. Smaller angles make the bumps sharper and can lead to bad models if count is small. Default 120
|
||||
// helix = The helical angle of the bumps, in degrees. Close to zero produces vertical ribbing. Close to 90 degrees produces very thin bumps and is not recommended. Default: 30
|
||||
// chamfer = The size of the chamfers on the ends of the cylinder. Default: none.
|
||||
// chamfer1 = The size of the chamfer on the bottom end of the cylinder. Default: none.
|
||||
// chamfer2 = The size of the chamfer on the top end of the cylinder. Default: none.
|
||||
// chamfang = The angle in degrees of the chamfers on the ends of the cylinder.
|
||||
// chamfang1 = The angle in degrees of the chamfer on the bottom end of the cylinder.
|
||||
// chamfang2 = The angle in degrees of the chamfer on the top end of the cylinder.
|
||||
// from_end = If true, chamfer is measured from the end of the cylinder, instead of inset from the edge. Default: `false`.
|
||||
// rounding = The radius of the rounding on the ends of the cylinder. Default: none.
|
||||
// rounding1 = The radius of the rounding on the bottom end of the cylinder.
|
||||
// rounding2 = The radius of the rounding on the top end of the cylinder.
|
||||
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
|
||||
// spin = Rotate this many degrees around the Z axis. See [spin](attachments.scad#subsection-spin). Default: `0`
|
||||
// orient = Vector to rotate top towards. See [orient](attachments.scad#subsection-orient). Default: `UP`
|
||||
// Examples(Med):
|
||||
// knurled_cylinder(l=30, r=20, count=30, profile=120, helix=45);
|
||||
// knurled_cylinder(l=30, r=20, count=30, profile=120, helix=30);
|
||||
// knurled_cylinder(l=30, r=20, count=30, profile=90, helix=30);
|
||||
// knurled_cylinder(l=30, r=20, count=20, profile=120, helix=30);
|
||||
// knurled_cylinder(l=30, r=20, count=20, profile=120, helix=0.01);
|
||||
// knurled_cylinder(l=30, r=20, count=20, profile=140, helix=60);
|
||||
// knurled_cylinder(l=30, r1=20, r2=12, count=40, profile=90, helix=55);
|
||||
module knurled_cylinder(
|
||||
l,
|
||||
r=undef, r1=undef, r2=undef,
|
||||
d=undef, d1=undef, d2=undef,
|
||||
count=30, profile=120, helix=30,
|
||||
chamfer=undef, chamfer1=undef, chamfer2=undef,
|
||||
chamfang=undef, chamfang1=undef, chamfang2=undef,
|
||||
from_end=false,
|
||||
rounding=undef, rounding1=undef, rounding2=undef,
|
||||
anchor=CENTER, spin=0, orient=UP,
|
||||
height, h
|
||||
) {
|
||||
assert(is_finite(helix) && helix>0 && helix<90, "Must give helix angle between 0 and 90");
|
||||
assert(is_finite(profile) && profile>0 && profile<180, "Must give profile between 0 and 180");
|
||||
l = one_defined([l,h,height],"l,h,height");
|
||||
r1 = get_radius(r1=r1, r=r, d1=d1, d=d, dflt=10);
|
||||
r2 = get_radius(r1=r2, r=r, d1=d2, d=d, dflt=10);
|
||||
inset = r1 * sin(180/count) / tan(profile/2);
|
||||
twist = 360*l*tan(helix)/(r1*2*PI);
|
||||
c1 = circle(r=r1,$fn=count);
|
||||
c2 = rot(-180/count,p=circle(r=r1-inset,$fn=count));
|
||||
path = [for (i=idx(c1)) each [c1[i],c2[i]]];
|
||||
knob_w = 2*PI*r1/count;
|
||||
knob_h = knob_w / tan(helix);
|
||||
layers = ceil(l/knob_h);
|
||||
plen = len(path);
|
||||
vertices = concat(
|
||||
[
|
||||
for (layer = [0:1:layers], pt=path)
|
||||
let(scale_factor = lerp(1,r2/r1,layer/layers))
|
||||
scale([scale_factor,scale_factor,1],
|
||||
(layer%2)? [pt.x, pt.y, layer*knob_h-layers*knob_h/2] :
|
||||
rot(180/count, p=[pt.x, pt.y, layer*knob_h-layers*knob_h/2])
|
||||
)
|
||||
], [
|
||||
[0,0,-layers*knob_h/2],
|
||||
[0,0, layers*knob_h/2]
|
||||
]
|
||||
);
|
||||
faces = concat(
|
||||
[
|
||||
for (layer = [0:1:layers-1], i=idx(path)) let(
|
||||
loff = (layer%2)? 2 : 0,
|
||||
i1 = layer*plen+((i+1)%plen),
|
||||
i2 = layer*plen+((i+2)%plen),
|
||||
i3 = (layer+1)*plen+posmod(i+1+loff,plen),
|
||||
i4 = (layer+1)*plen+posmod(i+2+loff,plen),
|
||||
i5 = (layer+1)*plen+posmod(i-0+loff,plen),
|
||||
i6 = (layer+1)*plen+posmod(i-1+loff,plen)
|
||||
) each [
|
||||
[i1, i2, ((i%2)? i5 : i3)],
|
||||
[i3, i5, ((i%2)? i2 : i1)]
|
||||
]
|
||||
], [
|
||||
for (i=[0:1:count-1]) let(
|
||||
i1 = posmod(i*2+1,plen),
|
||||
i2 = posmod(i*2+2,plen),
|
||||
i3 = posmod(i*2+3,plen),
|
||||
loff = layers*plen
|
||||
) each [
|
||||
[i1,i3,i2],
|
||||
[i1+loff,i2+loff,i3+loff],
|
||||
[i3,i1,len(vertices)-2],
|
||||
[i1+loff,i3+loff,len(vertices)-1]
|
||||
]
|
||||
]
|
||||
);
|
||||
attachable(anchor,spin,orient, r1=r1, r2=r2, l=l) {
|
||||
intersection() {
|
||||
polyhedron(points=vertices, faces=faces, convexity=2*layers);
|
||||
cyl(
|
||||
r1=r1, r2=r2, l=l,
|
||||
chamfer=chamfer, chamfer1=chamfer1, chamfer2=chamfer2,
|
||||
chamfang=chamfang, chamfang1=chamfang1, chamfang2=chamfang2,
|
||||
from_end=from_end,
|
||||
rounding=rounding, rounding1=rounding1, rounding2=rounding2,
|
||||
$fn=count*2
|
||||
);
|
||||
}
|
||||
children();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Module: knurled_cylinder_mask()
|
||||
// Usage:
|
||||
// knurled_cylinder_mask(l|h|height, r|d=, [overage], [count], [profile], [helix]) [ATTACHMENTS];
|
||||
// knurled_cylinder_mask(l|h|height, r=1|d1=, r2=|d2=, [overage=], [count=], [profile=], [helix=],...) [ATTACHMENTS];
|
||||
// Description:
|
||||
// Creates a mask to difference from a cylinder to give it a knurled surface.
|
||||
// Arguments:
|
||||
// l = The length of the axis of the mask.
|
||||
// r = The radius of the cylinder to knurl.
|
||||
// overage = Extra backing to the mask. Default: 5
|
||||
// ---
|
||||
// r1 = The radius of the bottom of the conical cylinder to knurl.
|
||||
// r2 = The radius of the top of the conical cylinder to knurl.
|
||||
// d = The diameter of the cylinder to knurl.
|
||||
// d1 = The diameter of the bottom of the conical cylinder to knurl.
|
||||
// d2 = The diameter of the top of the conical cylinder to knurl.
|
||||
// count = The number of bumps filling one revolution of the cylinder. Default: 30
|
||||
// profile = The lower angle between the pyramid-shaped bumps. Smaller angles make the bumps sharper and can lead to bad models if count is small. Default 120
|
||||
// helix = The helical angle of the bumps, in degrees. Close to zero produces vertical ribbing. Close to 90 degrees produces very thin bumps and is not recommended. Default: 30
|
||||
// anchor = Translate so anchor point is at origin (0,0,0). See [anchor](attachments.scad#subsection-anchor). Default: `CENTER`
|
||||
// spin = Rotate this many degrees around the Z axis. See [spin](attachments.scad#subsection-spin). Default: `0`
|
||||
// orient = Vector to rotate top towards. See [orient](attachments.scad#subsection-orient). Default: `UP`
|
||||
// Examples:
|
||||
// knurled_cylinder_mask(l=30, r=20, overage=5, profile=120, helix=30);
|
||||
// knurled_cylinder_mask(l=30, r=20, overage=10, profile=120, helix=30);
|
||||
module knurled_cylinder_mask(
|
||||
l, r, overage=5,
|
||||
r1=undef, r2=undef,
|
||||
d=undef, d1=undef, d2=undef,
|
||||
count=30, profile=120, helix=30,
|
||||
anchor=CENTER, spin=0, orient=UP, height,h
|
||||
) {
|
||||
l = one_defined([l,h,height],"l,h,height");
|
||||
r1 = get_radius(r1=r1, r=r, d1=d1, d=d, dflt=10);
|
||||
r2 = get_radius(r1=r2, r=r, d1=d2, d=d, dflt=10);
|
||||
attachable(anchor,spin,orient, r1=r1, r2=r2, l=l) {
|
||||
difference() {
|
||||
cylinder(r1=r1+overage, r2=r2+overage, h=l, center=true);
|
||||
knurled_cylinder(r1=r1, r2=r2, l=l+0.01, profile=profile, helix=helix,count=count);
|
||||
}
|
||||
children();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|
|
@ -2063,7 +2063,7 @@ function _get_texture(tex,n,m) =
|
|||
// Usage: As Module
|
||||
// textured_linear_sweep(path, texture, tex_size, h, ...) [ATTACHMENTS];
|
||||
// textured_linear_sweep(path, texture, counts=, h=, ...) [ATTACHMENTS];
|
||||
// Topics: Sweep, Extrusion, Textures
|
||||
// Topics: Sweep, Extrusion, Textures, Knurling
|
||||
// Description:
|
||||
// Given a single polygon path, creates a linear extrusion of that polygon vertically, with a given texture tiled evenly over the side surfaces.
|
||||
// Arguments:
|
||||
|
@ -2225,7 +2225,7 @@ module textured_linear_sweep(
|
|||
// Usage: As Module
|
||||
// textured_revolution(path, texture, tex_size, [tscale=], ...) [ATTACHMENTS];
|
||||
// textured_revolution(path, texture, counts=, [tscale=], ...) [ATTACHMENTS];
|
||||
// Topics: Sweep, Extrusion, Textures
|
||||
// Topics: Sweep, Extrusion, Textures, Knurling
|
||||
// Description:
|
||||
// Given a single 2D path, fully in the X+ half-plane, revolves that path around the Z axis (after rotating its Y+ to Z+).
|
||||
// This creates a solid from that surface of revolution, capped top and bottom, with the sides covered in a given tiled texture.
|
||||
|
@ -2348,7 +2348,7 @@ module textured_revolution(
|
|||
// Usage: As Module
|
||||
// textured_cylinder(h, r|d=, texture, tex_size|counts=, [tscale=], [inset=], [rot=], ...) [ATTACHMENTS];
|
||||
// textured_cylinder(h, r1=|d1=, r2=|d2=, texture=, tex_size=|counts=, [tscale=], [inset=], [rot=], ...) [ATTACHMENTS];
|
||||
// Topics: Sweep, Extrusion, Textures
|
||||
// Topics: Sweep, Extrusion, Textures, Knurling
|
||||
// Description:
|
||||
// Creates a cylinder or cone with optional chamfers or roundings, covered in a textured surface.
|
||||
// Arguments:
|
||||
|
|
Loading…
Reference in a new issue