mirror of
https://github.com/revarbat/BOSL2.git
synced 2025-08-06 10:06:30 +02:00
quat excision from path_extrude
This commit is contained in:
@@ -359,27 +359,24 @@ module extrude_from_to(pt1, pt2, convexity, twist, scale, slices) {
|
|||||||
// path = [ [0, 0, 0], [33, 33, 33], [66, 33, 40], [100, 0, 0], [150,0,0] ];
|
// path = [ [0, 0, 0], [33, 33, 33], [66, 33, 40], [100, 0, 0], [150,0,0] ];
|
||||||
// path_extrude(path) circle(r=10, $fn=6);
|
// path_extrude(path) circle(r=10, $fn=6);
|
||||||
module path_extrude(path, convexity=10, clipsize=100) {
|
module path_extrude(path, convexity=10, clipsize=100) {
|
||||||
function polyquats(path, q=q_ident(), v=[0,0,1], i=0) = let(
|
rotmats = cumprod([
|
||||||
v2 = path[i+1] - path[i],
|
for (i = idx(path,e=-2)) let(
|
||||||
ang = vector_angle(v,v2),
|
vec1 = i==0? UP : unit(path[i]-path[i-1], UP),
|
||||||
axis = ang>0.001? unit(cross(v,v2)) : [0,0,1],
|
vec2 = unit(path[i+1]-path[i], UP)
|
||||||
newq = q_mul(quat(axis, ang), q),
|
) rot(from=vec1,to=vec2)
|
||||||
dist = norm(v2)
|
]);
|
||||||
) i < (len(path)-2)?
|
// This adds a rotation midway between each item on the list
|
||||||
concat([[dist, newq, ang]], polyquats(path, newq, v2, i+1)) :
|
interp = rot_resample(rotmats,N=2,method="count");
|
||||||
[[dist, newq, ang]];
|
|
||||||
|
|
||||||
epsilon = 0.0001; // Make segments ever so slightly too long so they overlap.
|
epsilon = 0.0001; // Make segments ever so slightly too long so they overlap.
|
||||||
ptcount = len(path);
|
ptcount = len(path);
|
||||||
pquats = polyquats(path);
|
|
||||||
for (i = [0:1:ptcount-2]) {
|
for (i = [0:1:ptcount-2]) {
|
||||||
pt1 = path[i];
|
pt1 = path[i];
|
||||||
pt2 = path[i+1];
|
pt2 = path[i+1];
|
||||||
dist = pquats[i][0];
|
dist = norm(pt2-pt1);
|
||||||
q = pquats[i][1];
|
T = rotmats[i];
|
||||||
difference() {
|
difference() {
|
||||||
translate(pt1) {
|
translate(pt1) {
|
||||||
q_rot(q) {
|
multmatrix(T) {
|
||||||
down(clipsize/2/2) {
|
down(clipsize/2/2) {
|
||||||
if ((dist+clipsize/2) > 0) {
|
if ((dist+clipsize/2) > 0) {
|
||||||
linear_extrude(height=dist+clipsize/2, convexity=convexity) {
|
linear_extrude(height=dist+clipsize/2, convexity=convexity) {
|
||||||
@@ -390,12 +387,12 @@ module path_extrude(path, convexity=10, clipsize=100) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
translate(pt1) {
|
translate(pt1) {
|
||||||
hq = (i > 0)? q_slerp(q, pquats[i-1][1], 0.5) : q;
|
hq = (i > 0)? interp[2*i-1] : T;
|
||||||
q_rot(hq) down(clipsize/2+epsilon) cube(clipsize, center=true);
|
multmatrix(hq) down(clipsize/2+epsilon) cube(clipsize, center=true);
|
||||||
}
|
}
|
||||||
translate(pt2) {
|
translate(pt2) {
|
||||||
hq = (i < ptcount-2)? q_slerp(q, pquats[i+1][1], 0.5) : q;
|
hq = (i < ptcount-2)? interp[2*i+1] : T;
|
||||||
q_rot(hq) up(clipsize/2+epsilon) cube(clipsize, center=true);
|
multmatrix(hq) up(clipsize/2+epsilon) cube(clipsize, center=true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -404,7 +401,6 @@ module path_extrude(path, convexity=10, clipsize=100) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Section: Offset Mutators
|
// Section: Offset Mutators
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
Reference in New Issue
Block a user