mirror of
https://github.com/Irev-Dev/Round-Anything.git
synced 2025-01-16 10:40:24 +01:00
Mostly renaming for readability
This commit is contained in:
parent
e2cdd6c1bc
commit
f4a75dd38a
@ -32,10 +32,11 @@ Both this modules do the same thing as minkowskiRound() but focus on either insi
|
||||
// }
|
||||
//}
|
||||
|
||||
//minkowskiRound(0.5,2,1,[50,50,50])union(){//--example in the thiniverse thumbnail/main image
|
||||
// $fn=20;
|
||||
// minkowskiRound(0.7,1.5,1,[50,50,50])union(){//--example in the thiniverse thumbnail/main image
|
||||
// cube([6,6,22]);
|
||||
// rotate([30,45,10])cylinder(h=22,d=10);
|
||||
//}//--I rendered this out with a $fn=25 and it took more than 12 hours on my computer
|
||||
// rotate([30,45,10])cylinder(h=22,d=10);
|
||||
// }//--I rendered this out with a $fn=25 and it took more than 12 hours on my computer
|
||||
|
||||
|
||||
module round2d(OR=3,IR=1){
|
||||
@ -48,16 +49,16 @@ module round2d(OR=3,IR=1){
|
||||
}
|
||||
}
|
||||
|
||||
module minkowskiRound(OR=1,IR=1,enable=1,cubeSize=[500,500,500]){
|
||||
module minkowskiRound(OR=1,IR=1,enable=1,boundingEnvelope=[500,500,500]){
|
||||
if(enable==0){//do nothing if not enabled
|
||||
children();
|
||||
} else {
|
||||
minkowski(){//expand the now positive shape back out
|
||||
difference(){//make the negative shape positive again
|
||||
cube(cubeSize-[0.1,0.1,0.1],center=true);
|
||||
cube(boundingEnvelope-[0.1,0.1,0.1],center=true);
|
||||
minkowski(){//expand the negative shape inwards
|
||||
difference(){//create a negative of the children
|
||||
cube(cubeSize,center=true);
|
||||
cube(boundingEnvelope,center=true);
|
||||
minkowski(){//expand the children
|
||||
children();
|
||||
sphere(IR);
|
||||
@ -71,16 +72,16 @@ module minkowskiRound(OR=1,IR=1,enable=1,cubeSize=[500,500,500]){
|
||||
}
|
||||
}
|
||||
|
||||
module minkowskiOutsideRound(r=1,enable=1,cubeSize=[500,500,500]){
|
||||
module minkowskiOutsideRound(r=1,enable=1,boundingEnvelope=[500,500,500]){
|
||||
if(enable==0){//do nothing if not enabled
|
||||
children();
|
||||
} else {
|
||||
minkowski(){//expand the now positive shape
|
||||
difference(){//make the negative positive
|
||||
cube(cubeSize-[0.1,0.1,0.1],center=true);
|
||||
cube(boundingEnvelope-[0.1,0.1,0.1],center=true);
|
||||
minkowski(){//expand the negative inwards
|
||||
difference(){//create a negative of the children
|
||||
cube(cubeSize,center=true);
|
||||
cube(boundingEnvelope,center=true);
|
||||
children();
|
||||
}
|
||||
sphere(r);
|
||||
@ -91,15 +92,15 @@ module minkowskiOutsideRound(r=1,enable=1,cubeSize=[500,500,500]){
|
||||
}
|
||||
}
|
||||
|
||||
module minkowskiInsideRound(r=1,enable=1,cubeSize=[500,500,500]){
|
||||
module minkowskiInsideRound(r=1,enable=1,boundingEnvelope=[500,500,500]){
|
||||
if(enable==0){//do nothing if not enabled
|
||||
children();
|
||||
} else {
|
||||
difference(){//make the negative positive again
|
||||
cube(cubeSize-[0.1,0.1,0.1],center=true);
|
||||
cube(boundingEnvelope-[0.1,0.1,0.1],center=true);
|
||||
minkowski(){//expand the negative shape inwards
|
||||
difference(){//make the expanded children a negative shape
|
||||
cube(cubeSize,center=true);
|
||||
cube(boundingEnvelope,center=true);
|
||||
minkowski(){//expand the children
|
||||
children();
|
||||
sphere(r);
|
||||
|
@ -180,11 +180,14 @@ function findPoint(ang1,refpoint1,ang2,refpoint2,r=0)=
|
||||
)
|
||||
[outputX,outputY,r];
|
||||
|
||||
function beamChain(rp,offset1=0,offset2,mode=0,minR=0,startAngle,endAngle)=
|
||||
/*This function takes a series of radii points and plots points to run along side at a constanit distance, think of it as offset but for line instead of a polygon
|
||||
rp=radii points, offset1&offset2=offset 1&2,minR=min radius, startAngle&2=angle 1&2
|
||||
function beamChain(radiiPoints,offset1=0,offset2,mode=0,minR=0,startAngle,endAngle)=
|
||||
/*This function takes a series of radii points and plots points to run along side at a consistant distance, think of it as offset but for line instead of a polygon
|
||||
radiiPoints=radii points,
|
||||
offset1 & offset2= The two offsets that give the beam it's thickness. When using with mode=2 only offset1 is needed as there is no return path for the polygon
|
||||
minR=min radius, if all of your radii are set properly within the radii points this value can be ignored
|
||||
startAngle & endAngle= Angle at each end of the beam, different mode determine if this angle is relative to the ending legs of the beam or absolute.
|
||||
mode=1 - include endpoints startAngle&2 are relative to the angle of the last two points and equal 90deg if not defined
|
||||
mode=2 - endpoints not included
|
||||
mode=2 - Only the forward path is defined, useful for combining the beam with other radii points, see examples for a use-case.
|
||||
mode=3 - include endpoints startAngle&2 are absolute from the x axis and are 0 if not defined
|
||||
negative radiuses only allowed for the first and last radii points
|
||||
|
||||
@ -192,55 +195,55 @@ function beamChain(rp,offset1=0,offset2,mode=0,minR=0,startAngle,endAngle)=
|
||||
let(
|
||||
offset2undef=offset2==undef?1:0,
|
||||
offset2=offset2undef==1?0:offset2,
|
||||
CWorCCW1=sign(offset1)*CWorCCW(rp),
|
||||
CWorCCW2=sign(offset2)*CWorCCW(rp),
|
||||
CWorCCW1=sign(offset1)*CWorCCW(radiiPoints),
|
||||
CWorCCW2=sign(offset2)*CWorCCW(radiiPoints),
|
||||
offset1=abs(offset1),
|
||||
offset2b=abs(offset2),
|
||||
Lrp3=len(rp)-3,
|
||||
Lrp=len(rp),
|
||||
Lrp3=len(radiiPoints)-3,
|
||||
Lrp=len(radiiPoints),
|
||||
startAngle=mode==0&&startAngle==undef?
|
||||
getAngle(rp[0],rp[1])+90:
|
||||
getAngle(radiiPoints[0],radiiPoints[1])+90:
|
||||
mode==2&&startAngle==undef?
|
||||
0:
|
||||
mode==0?
|
||||
getAngle(rp[0],rp[1])+startAngle:
|
||||
getAngle(radiiPoints[0],radiiPoints[1])+startAngle:
|
||||
startAngle,
|
||||
endAngle=mode==0&&endAngle==undef?
|
||||
getAngle(rp[Lrp-1],rp[Lrp-2])+90:
|
||||
getAngle(radiiPoints[Lrp-1],radiiPoints[Lrp-2])+90:
|
||||
mode==2&&endAngle==undef?
|
||||
0:
|
||||
mode==0?
|
||||
getAngle(rp[Lrp-1],rp[Lrp-2])+endAngle:
|
||||
getAngle(radiiPoints[Lrp-1],radiiPoints[Lrp-2])+endAngle:
|
||||
endAngle,
|
||||
OffLn1=[for(i=[0:Lrp3]) offset1==0?rp[i+1]:parallelFollow([rp[i],rp[i+1],rp[i+2]],offset1,minR,mode=CWorCCW1)],
|
||||
OffLn2=[for(i=[0:Lrp3]) offset2==0?rp[i+1]:parallelFollow([rp[i],rp[i+1],rp[i+2]],offset2b,minR,mode=CWorCCW2)],
|
||||
Rp1=abs(rp[0].z),
|
||||
Rp2=abs(rp[Lrp-1].z),
|
||||
endP1a=findPoint(getAngle(rp[0],rp[1]), OffLn1[0], startAngle,rp[0], Rp1),
|
||||
endP1b=findPoint(getAngle(rp[Lrp-1],rp[Lrp-2]), OffLn1[len(OffLn1)-1], endAngle,rp[Lrp-1], Rp2),
|
||||
endP2a=findPoint(getAngle(rp[0],rp[1]), OffLn2[0], startAngle,rp[0], Rp1),
|
||||
endP2b=findPoint(getAngle(rp[Lrp-1],rp[Lrp-2]), OffLn2[len(OffLn1)-1], endAngle,rp[Lrp-1], Rp2),
|
||||
OffLn1=[for(i=[0:Lrp3]) offset1==0?radiiPoints[i+1]:parallelFollow([radiiPoints[i],radiiPoints[i+1],radiiPoints[i+2]],offset1,minR,mode=CWorCCW1)],
|
||||
OffLn2=[for(i=[0:Lrp3]) offset2==0?radiiPoints[i+1]:parallelFollow([radiiPoints[i],radiiPoints[i+1],radiiPoints[i+2]],offset2b,minR,mode=CWorCCW2)],
|
||||
Rp1=abs(radiiPoints[0].z),
|
||||
Rp2=abs(radiiPoints[Lrp-1].z),
|
||||
endP1a=findPoint(getAngle(radiiPoints[0],radiiPoints[1]), OffLn1[0], startAngle,radiiPoints[0], Rp1),
|
||||
endP1b=findPoint(getAngle(radiiPoints[Lrp-1],radiiPoints[Lrp-2]), OffLn1[len(OffLn1)-1], endAngle,radiiPoints[Lrp-1], Rp2),
|
||||
endP2a=findPoint(getAngle(radiiPoints[0],radiiPoints[1]), OffLn2[0], startAngle,radiiPoints[0], Rp1),
|
||||
endP2b=findPoint(getAngle(radiiPoints[Lrp-1],radiiPoints[Lrp-2]), OffLn2[len(OffLn1)-1], endAngle,radiiPoints[Lrp-1], Rp2),
|
||||
absEnda=getAngle(endP1a,endP2a),
|
||||
absEndb=getAngle(endP1b,endP2b),
|
||||
negRP1a=[cos(absEnda)*rp[0].z*10+endP1a.x, sin(absEnda)*rp[0].z*10+endP1a.y, 0.0],
|
||||
negRP2a=[cos(absEnda)*-rp[0].z*10+endP2a.x, sin(absEnda)*-rp[0].z*10+endP2a.y, 0.0],
|
||||
negRP1b=[cos(absEndb)*rp[Lrp-1].z*10+endP1b.x, sin(absEndb)*rp[Lrp-1].z*10+endP1b.y, 0.0],
|
||||
negRP2b=[cos(absEndb)*-rp[Lrp-1].z*10+endP2b.x, sin(absEndb)*-rp[Lrp-1].z*10+endP2b.y, 0.0],
|
||||
OffLn1b=(mode==0||mode==2)&&rp[0].z<0&&rp[Lrp-1].z<0?
|
||||
negRP1a=[cos(absEnda)*radiiPoints[0].z*10+endP1a.x, sin(absEnda)*radiiPoints[0].z*10+endP1a.y, 0.0],
|
||||
negRP2a=[cos(absEnda)*-radiiPoints[0].z*10+endP2a.x, sin(absEnda)*-radiiPoints[0].z*10+endP2a.y, 0.0],
|
||||
negRP1b=[cos(absEndb)*radiiPoints[Lrp-1].z*10+endP1b.x, sin(absEndb)*radiiPoints[Lrp-1].z*10+endP1b.y, 0.0],
|
||||
negRP2b=[cos(absEndb)*-radiiPoints[Lrp-1].z*10+endP2b.x, sin(absEndb)*-radiiPoints[Lrp-1].z*10+endP2b.y, 0.0],
|
||||
OffLn1b=(mode==0||mode==2)&&radiiPoints[0].z<0&&radiiPoints[Lrp-1].z<0?
|
||||
concat([negRP1a],[endP1a],OffLn1,[endP1b],[negRP1b])
|
||||
:(mode==0||mode==2)&&rp[0].z<0?
|
||||
:(mode==0||mode==2)&&radiiPoints[0].z<0?
|
||||
concat([negRP1a],[endP1a],OffLn1,[endP1b])
|
||||
:(mode==0||mode==2)&&rp[Lrp-1].z<0?
|
||||
:(mode==0||mode==2)&&radiiPoints[Lrp-1].z<0?
|
||||
concat([endP1a],OffLn1,[endP1b],[negRP1b])
|
||||
:mode==0||mode==2?
|
||||
concat([endP1a],OffLn1,[endP1b])
|
||||
:
|
||||
OffLn1,
|
||||
OffLn2b=(mode==0||mode==2)&&rp[0].z<0&&rp[Lrp-1].z<0?
|
||||
OffLn2b=(mode==0||mode==2)&&radiiPoints[0].z<0&&radiiPoints[Lrp-1].z<0?
|
||||
concat([negRP2a],[endP2a],OffLn2,[endP2b],[negRP2b])
|
||||
:(mode==0||mode==2)&&rp[0].z<0?
|
||||
:(mode==0||mode==2)&&radiiPoints[0].z<0?
|
||||
concat([negRP2a],[endP2a],OffLn2,[endP2b])
|
||||
:(mode==0||mode==2)&&rp[Lrp-1].z<0?
|
||||
:(mode==0||mode==2)&&radiiPoints[Lrp-1].z<0?
|
||||
concat([endP2a],OffLn2,[endP2b],[negRP2b])
|
||||
:mode==0||mode==2?
|
||||
concat([endP2a],OffLn2,[endP2b])
|
||||
@ -288,8 +291,8 @@ function CentreN2PointsArc(p1,p2,cen,mode=0,fn)=
|
||||
)
|
||||
[for(i=[0:fn]) [cos(p1Angle+(arcAngle/fn)*i*CWorCCW)*r+cen[0],sin(p1Angle+(arcAngle/fn)*i*CWorCCW)*r+cen[1]]];
|
||||
|
||||
function translateRadiiPoints(rp,tran=[0,0],rot=0)=
|
||||
[for(i=rp)
|
||||
function translateRadiiPoints(radiiPoints,tran=[0,0],rot=0)=
|
||||
[for(i=radiiPoints)
|
||||
let(
|
||||
a=getAngle([0,0],[i.x,i.y]),//get the angle of the this point
|
||||
h=pointDist([0,0],[i.x,i.y]) //get the hypotenuse/radius
|
||||
@ -307,14 +310,14 @@ module round2d(OR=3,IR=1){
|
||||
}
|
||||
}
|
||||
|
||||
module shell2d(offset1,OR=0,IR=0,offset2=0){
|
||||
module shell2d(offset1,offset2=0,minOR=0,minIR=0){
|
||||
difference(){
|
||||
round2d(OR,IR){
|
||||
round2d(minOR,minIR){
|
||||
offset(max(offset1,offset2)){
|
||||
children(0);//original 1st child forms the outside of the shell
|
||||
}
|
||||
}
|
||||
round2d(IR,OR){
|
||||
round2d(minIR,minOR){
|
||||
difference(){//round the inside cutout
|
||||
offset(min(offset1,offset2)){
|
||||
children(0);//shrink the 1st child to form the inside of the shell
|
||||
@ -340,11 +343,11 @@ module internalSq(size,r,center=0){
|
||||
}
|
||||
}
|
||||
|
||||
module extrudeWithRadius(ln,r1=0,r2=0,fn=30){
|
||||
module extrudeWithRadius(length,r1=0,r2=0,fn=30){
|
||||
n1=sign(r1);n2=sign(r2);
|
||||
r1=abs(r1);r2=abs(r2);
|
||||
translate([0,0,r1]){
|
||||
linear_extrude(ln-r1-r2){
|
||||
linear_extrude(length-r1-r2){
|
||||
children();
|
||||
}
|
||||
}
|
||||
@ -356,7 +359,7 @@ module extrudeWithRadius(ln,r1=0,r2=0,fn=30){
|
||||
}
|
||||
}
|
||||
}
|
||||
translate([0,0,ln-r2+i*r2]){
|
||||
translate([0,0,length-r2+i*r2]){
|
||||
linear_extrude(r2/fn){
|
||||
offset(n2*sqrt(sq(r2)-sq(i*r2))-n2*r2){
|
||||
children();
|
||||
@ -366,16 +369,16 @@ module extrudeWithRadius(ln,r1=0,r2=0,fn=30){
|
||||
}
|
||||
}
|
||||
|
||||
function mirrorPoints(b,rot=0,atten=[0,0])= //mirrors a list of points about Y, ignoring the first and last points and returning them in reverse order for use with polygon or polyRound
|
||||
function mirrorPoints(radiiPoints,rot=0,endAttenuation=[0,0])= //mirrors a list of points about Y, ignoring the first and last points and returning them in reverse order for use with polygon or polyRound
|
||||
let(
|
||||
a=translateRadiiPoints(b,[0,0],-rot),
|
||||
temp3=[for(i=[0+atten[0]:len(a)-1-atten[1]])
|
||||
a=translateRadiiPoints(radiiPoints,[0,0],-rot),
|
||||
temp3=[for(i=[0+endAttenuation[0]:len(a)-1-endAttenuation[1]])
|
||||
[a[i][0],-a[i][1],a[i][2]]
|
||||
],
|
||||
temp=translateRadiiPoints(temp3,[0,0],rot),
|
||||
temp2=revList(temp3)
|
||||
)
|
||||
concat(b,temp2);
|
||||
concat(radiiPoints,temp2);
|
||||
|
||||
function processRadiiPoints(rp)=
|
||||
[for(i=[0:len(rp)-1])
|
||||
|
@ -66,16 +66,16 @@ module experimentalParametricPolyRoundExample() {
|
||||
module conflicResolutionExample(){
|
||||
//example of radii conflict handling and debuging feature
|
||||
function makeRadiiPoints(r1, r2)=[[0,0,0],[0,20,r1],[20,20,r1],[20,0,0]];
|
||||
|
||||
|
||||
// the squre shape being 20 wide, two radii of 10 both fit into the shape (just)
|
||||
translate([-25,0,0])polygon(polyRound(makeRadiiPoints(10,10),50));
|
||||
|
||||
|
||||
//radii are too large and are reduced to fit and will be reduce to 10 and 10
|
||||
translate([0,0,0])polygon(polyRound(makeRadiiPoints(30,30),50));
|
||||
|
||||
|
||||
//radii are too large again and are reduced to fit, but keep their ratios r1 will go from 10 to 4 and r2 will go from 40 to 16
|
||||
translate([25,0,0])polygon(polyRound(makeRadiiPoints(10,40),50));
|
||||
|
||||
|
||||
//mode 2 = no radii limiting
|
||||
translate([50,0,0])polygon(polyRound(makeRadiiPoints(15,20),50,mode=2));
|
||||
}
|
||||
@ -94,6 +94,7 @@ module translateRadiiPointsExample() {
|
||||
[boltR, minT, 0],
|
||||
[boltR, 0, startAndEndRadius],
|
||||
];
|
||||
|
||||
negativeNutCapture=translateRadiiPoints(nutCapture(),tran=[5,0]);
|
||||
rotatedNegativeNutCapture=translateRadiiPoints(nutCapture(1),tran=[20,5],rot=90);
|
||||
aSquare=concat(
|
||||
@ -105,23 +106,23 @@ module translateRadiiPointsExample() {
|
||||
[[0,10,0]]
|
||||
);
|
||||
polygon(polyRound(aSquare,20));
|
||||
translate([10,12,0])polygon(polyRound(nutCapture(),20));
|
||||
translate([-5,0,0])polygon(polyRound(nutCapture(),20));
|
||||
}
|
||||
|
||||
module 2dShellExample(){
|
||||
radiiPoints=[[-4,0,1],[5,3,1.5],[0,7,0.1],[8,7,10],[20,20,0.8],[10,0,10]];
|
||||
shell2d(-0.5)polygon(polyRound(radiiPoints,30));
|
||||
translate([0,-10,0])shell2d(-0.5){
|
||||
scale(1)polygon(polyRound(radiiPoints,30));
|
||||
polygon(polyRound(radiiPoints,30));
|
||||
translate([8,8])gridpattern(memberW = 0.3, sqW = 1, iter = 17, r = 0.2);
|
||||
}
|
||||
shell2d(-0.5)scale(1)polygon(polyRound(radiiPoints,30));
|
||||
}
|
||||
|
||||
module beamChainExample(){
|
||||
function beamPoints(r1,r2,rStart=0,rEnd=0)=[[0,0,rStart],[2,8,0],[5,4,r1],[15,10,r2],[17,2,rEnd]];
|
||||
|
||||
// chained lines by themselves
|
||||
{
|
||||
translate(){
|
||||
radiiPoints=beamPoints(0,0);
|
||||
for(i=[0: len(radiiPoints)]){color("red")translate([radiiPoints[i].x,radiiPoints[i].y,0])cylinder(d=0.2, h=1);}
|
||||
polygon(polyRound(beamChain(radiiPoints,offset1=0.02, offset2=-0.02),20));
|
||||
@ -136,15 +137,15 @@ module beamChainExample(){
|
||||
}
|
||||
|
||||
// Give make the lines beams with some thickness
|
||||
{
|
||||
translate([0,-7*2,0]){
|
||||
radiiPoints=beamPoints(2,1);
|
||||
translate([0,-7*2,0])polygon(polyRound(beamChain(radiiPoints,offset1=0.5, offset2=-0.5),20));
|
||||
polygon(polyRound(beamChain(radiiPoints,offset1=0.5, offset2=-0.5),20));
|
||||
}
|
||||
|
||||
// Add an angle to the start of the beam
|
||||
{
|
||||
translate([0,-7*3,0]){
|
||||
radiiPoints=beamPoints(2,1);
|
||||
translate([0,-7*3,0])polygon(polyRound(beamChain(radiiPoints,offset1=0.5, offset2=-0.5, startAngle=45),20));
|
||||
polygon(polyRound(beamChain(radiiPoints,offset1=0.5, offset2=-0.5, startAngle=45),20));
|
||||
}
|
||||
|
||||
// Put a negative radius at the start for transationing to a flat surface
|
||||
@ -163,18 +164,18 @@ module beamChainExample(){
|
||||
// Attached to the end of the beam chain by dividing the beam paths in forward and return and
|
||||
// concat other polygon inbetween
|
||||
translate([0,-7*6,0]){
|
||||
ex4=beamPoints(2,1);
|
||||
forwardPath=beamChain(ex4,offset1=0.5,startAngle=-15,mode=2);
|
||||
returnPath=revList(beamChain(ex4,offset1=-0.5,startAngle=-15,mode=2));
|
||||
radiiPoints=beamPoints(2,1);
|
||||
forwardPath=beamChain(radiiPoints,offset1=0.5,startAngle=-15,mode=2);
|
||||
returnPath=revList(beamChain(radiiPoints,offset1=-0.5,startAngle=-15,mode=2));
|
||||
entirePath=concat(forwardPath,clipP,returnPath);
|
||||
polygon(polyRound(entirePath,20));
|
||||
}
|
||||
|
||||
// Add transitioning radii into the end polygong
|
||||
translate([0,-7*7-2,0]){
|
||||
ex4=beamPoints(2,1,rEnd=3);
|
||||
forwardPath=beamChain(ex4,offset1=0.5,startAngle=-15,mode=2);
|
||||
returnPath=revList(beamChain(ex4,offset1=-0.5,startAngle=-15,mode=2));
|
||||
radiiPoints=beamPoints(2,1,rEnd=3);
|
||||
forwardPath=beamChain(radiiPoints,offset1=0.5,startAngle=-15,mode=2);
|
||||
returnPath=revList(beamChain(radiiPoints,offset1=-0.5,startAngle=-15,mode=2));
|
||||
entirePath=concat(forwardPath,clipP,returnPath);
|
||||
polygon(polyRound(entirePath,20));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user