mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-01-01 09:49:45 +00:00
Updated continuous rounding patches.
This commit is contained in:
parent
aadd189c97
commit
3180704da4
1 changed files with 36 additions and 32 deletions
|
@ -2,21 +2,21 @@ include <BOSL2/std.scad>
|
||||||
include <BOSL2/paths.scad>
|
include <BOSL2/paths.scad>
|
||||||
include <BOSL2/beziers.scad>
|
include <BOSL2/beziers.scad>
|
||||||
|
|
||||||
rounding_factor = 0.667;
|
|
||||||
|
|
||||||
function CR_corner(size, spin=0, orient=UP, trans=[0,0,0]) =
|
function CR_corner(size, spin=0, orient=UP, trans=[0,0,0]) =
|
||||||
let (
|
let (
|
||||||
r = rounding_factor,
|
// This patch might not yet correct for continuous rounding,
|
||||||
k = r/2,
|
// but it's a first approximation proof of concept.
|
||||||
// I know this patch is not yet correct for continuous
|
a = 0.68,
|
||||||
// rounding, but it's a first approximation proof of concept.
|
b = 0.60,
|
||||||
// Currently this is a degree 4 triangular patch.
|
c = 0.24,
|
||||||
patch = [
|
patch = [
|
||||||
[[0,1,1], [0,r,1], [0,0,1], [r,0,1], [1,0,1]],
|
[[0,1,1], [0,a,1], [0,c,1], [c,0,1], [a,0,1], [1,0,1]],
|
||||||
[[0,1,r], [0,k,k], [k,0,k], [1,0,r]],
|
[[0,1,a], [0,b,b], [0,0,b], [b,0,b], [1,0,a]],
|
||||||
[[0,1,0], [k,k,0], [1,0,0]],
|
[[0,1,c], [0,b,0], [b,0,0], [1,0,c]],
|
||||||
[[r,1,0], [1,r,0]],
|
[[c,1,0], [b,b,0], [1,c,0]],
|
||||||
[[1,1,0]]
|
[[a,1,0], [1,a,0]],
|
||||||
|
[[1,1,0]],
|
||||||
]
|
]
|
||||||
) [for (row=patch)
|
) [for (row=patch)
|
||||||
translate_points(v=trans,
|
translate_points(v=trans,
|
||||||
|
@ -29,20 +29,23 @@ function CR_corner(size, spin=0, orient=UP, trans=[0,0,0]) =
|
||||||
|
|
||||||
function CR_edge(size, spin=0, orient=UP, trans=[0,0,0]) =
|
function CR_edge(size, spin=0, orient=UP, trans=[0,0,0]) =
|
||||||
let (
|
let (
|
||||||
r = rounding_factor,
|
// This patch might not yet correct for continuous rounding,
|
||||||
a = -1/2,
|
// but it's a first approximation proof of concept.
|
||||||
b = -1/4,
|
a = 0.68,
|
||||||
c = 1/4,
|
c = 0.24,
|
||||||
d = 1/2,
|
m = -1/2,
|
||||||
// I know this patch is not yet correct for continuous
|
n = -3/10,
|
||||||
// rounding, but it's a first approximation proof of concept.
|
o = -1/10,
|
||||||
// Currently this is a degree 4 rectangular patch.
|
p = 1/10,
|
||||||
|
q = 3/10,
|
||||||
|
r = 1/2,
|
||||||
patch = [
|
patch = [
|
||||||
[[1,0,a], [1,0,b], [1,0,0], [1,0,c], [1,0,d]],
|
[[1,0,m], [1,0,n], [1,0,o], [1,0,p], [1,0,q], [1,0,r]],
|
||||||
[[r,0,a], [r,0,b], [r,0,0], [r,0,c], [r,0,d]],
|
[[a,0,m], [a,0,n], [a,0,o], [a,0,p], [a,0,q], [a,0,r]],
|
||||||
[[0,0,a], [0,0,b], [0,0,0], [0,0,c], [0,0,d]],
|
[[c,0,m], [c,0,n], [c,0,o], [c,0,p], [c,0,q], [c,0,r]],
|
||||||
[[0,r,a], [0,r,b], [0,r,0], [0,r,c], [0,r,d]],
|
[[0,c,m], [0,c,n], [0,c,o], [0,c,p], [0,c,q], [0,c,r]],
|
||||||
[[0,1,a], [0,1,b], [0,1,0], [0,1,c], [0,1,d]]
|
[[0,a,m], [0,a,n], [0,a,o], [0,a,p], [0,a,q], [0,a,r]],
|
||||||
|
[[0,1,m], [0,1,n], [0,1,o], [0,1,p], [0,1,q], [0,1,r]],
|
||||||
]
|
]
|
||||||
) [for (row=patch)
|
) [for (row=patch)
|
||||||
translate_points(v=trans,
|
translate_points(v=trans,
|
||||||
|
@ -53,7 +56,7 @@ function CR_edge(size, spin=0, orient=UP, trans=[0,0,0]) =
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
module CR_cube(size=[100,100,100], r=10, splinesteps=8, cheat=false)
|
module CR_cube(size=[100,100,100], r=10, splinesteps=8, cheat=false, debug=false)
|
||||||
{
|
{
|
||||||
s = size-2*[r,r,r];
|
s = size-2*[r,r,r];
|
||||||
h = size/2;
|
h = size/2;
|
||||||
|
@ -66,7 +69,7 @@ module CR_cube(size=[100,100,100], r=10, splinesteps=8, cheat=false)
|
||||||
CR_corner([r,r,r], spin=0, orient=DOWN, trans=[ size.x/2, -size.y/2, size.z/2]),
|
CR_corner([r,r,r], spin=0, orient=DOWN, trans=[ size.x/2, -size.y/2, size.z/2]),
|
||||||
CR_corner([r,r,r], spin=90, orient=DOWN, trans=[-size.x/2, -size.y/2, size.z/2]),
|
CR_corner([r,r,r], spin=90, orient=DOWN, trans=[-size.x/2, -size.y/2, size.z/2]),
|
||||||
CR_corner([r,r,r], spin=180, orient=DOWN, trans=[-size.x/2, size.y/2, size.z/2]),
|
CR_corner([r,r,r], spin=180, orient=DOWN, trans=[-size.x/2, size.y/2, size.z/2]),
|
||||||
CR_corner([r,r,r], spin=270, orient=DOWN, trans=[ size.x/2, size.y/2, size.z/2])
|
CR_corner([r,r,r], spin=270, orient=DOWN, trans=[ size.x/2, size.y/2, size.z/2]),
|
||||||
];
|
];
|
||||||
edges = [
|
edges = [
|
||||||
CR_edge([r, r, s.x], spin=0, orient=RIGHT, trans=[ 0, -h.y, h.z]),
|
CR_edge([r, r, s.x], spin=0, orient=RIGHT, trans=[ 0, -h.y, h.z]),
|
||||||
|
@ -96,19 +99,20 @@ module CR_cube(size=[100,100,100], r=10, splinesteps=8, cheat=false)
|
||||||
bezier_patch_flat([s.x, s.y], N=1, orient=UP, trans=[ 0, 0, h.z]),
|
bezier_patch_flat([s.x, s.y], N=1, orient=UP, trans=[ 0, 0, h.z]),
|
||||||
bezier_patch_flat([s.x, s.y], N=1, orient=DOWN, trans=[ 0, 0, -h.z])
|
bezier_patch_flat([s.x, s.y], N=1, orient=DOWN, trans=[ 0, 0, -h.z])
|
||||||
];
|
];
|
||||||
// Generating all the patches above took about 0.05 secs.
|
|
||||||
|
|
||||||
if (cheat) {
|
if (cheat) {
|
||||||
// Hulling just the corners takes less than a second.
|
hull() bezier_polyhedron(patches=corners, splinesteps=splinesteps);
|
||||||
hull() bezier_polyhedron(tris=corners, splinesteps=splinesteps);
|
|
||||||
} else {
|
} else {
|
||||||
// Generating the polyhedron fully from bezier patches takes 3 seconds on my laptop.
|
if (debug) {
|
||||||
bezier_polyhedron(patches=concat(edges, faces), tris=corners, splinesteps=splinesteps);
|
trace_bezier_patches(patches=concat(edges, faces), tris=corners, showcps=true, splinesteps=splinesteps);
|
||||||
|
} else {
|
||||||
|
bezier_polyhedron(patches=concat(edges, faces), tris=corners, splinesteps=splinesteps);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CR_cube(size=[100,100,100], r=20, splinesteps=15, cheat=false);
|
CR_cube(size=[100,100,100], r=20, splinesteps=16, cheat=false, debug=false);
|
||||||
cube(1);
|
cube(1);
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue