mirror of
https://github.com/Irev-Dev/Round-Anything.git
synced 2025-08-17 21:21:19 +02:00
Merge pull request #8 from Irev-Dev/remove-warnings-and-tweak-examples
Resolve warning messages and tweak examples
This commit is contained in:
@@ -432,22 +432,23 @@ function CentreN2PointsArc(p1,p2,cen,mode=0,fn)=
|
|||||||
mode==3, plotted counter clockwise
|
mode==3, plotted counter clockwise
|
||||||
*/
|
*/
|
||||||
let(
|
let(
|
||||||
CWorCCW=CWorCCW([cen,p1,p2]),//determine the direction of rotation
|
isCWorCCW=CWorCCW([cen,p1,p2]),//determine the direction of rotation
|
||||||
//determine the arc angle depending on the mode
|
//determine the arc angle depending on the mode
|
||||||
p1p2Angle=cosineRuleAngle(p2,cen,p1),
|
p1p2Angle=cosineRuleAngle(p2,cen,p1),
|
||||||
arcAngle=
|
arcAngle=
|
||||||
mode==0?p1p2Angle:
|
mode==0?p1p2Angle:
|
||||||
mode==1?p1p2Angle-360:
|
mode==1?p1p2Angle-360:
|
||||||
mode==2&&CWorCCW==-1?p1p2Angle:
|
mode==2&&isCWorCCW==-1?p1p2Angle:
|
||||||
mode==2&&CWorCCW== 1?p1p2Angle-360:
|
mode==2&&isCWorCCW== 1?p1p2Angle-360:
|
||||||
mode==3&&CWorCCW== 1?p1p2Angle:
|
mode==3&&isCWorCCW== 1?p1p2Angle:
|
||||||
mode==3&&CWorCCW==-1?p1p2Angle-360:
|
mode==3&&isCWorCCW==-1?p1p2Angle-360:
|
||||||
cosineRuleAngle(p2,cen,p1)
|
cosineRuleAngle(p2,cen,p1),
|
||||||
,
|
|
||||||
r=pointDist(p1,cen),//determine the radius
|
r=pointDist(p1,cen),//determine the radius
|
||||||
p1Angle=getAngle(cen,p1) //angle of line 1
|
p1Angle=getAngle(cen,p1) //angle of line 1
|
||||||
)
|
)
|
||||||
[for(i=[0:fn]) [cos(p1Angle+(arcAngle/fn)*i*CWorCCW)*r+cen[0],sin(p1Angle+(arcAngle/fn)*i*CWorCCW)*r+cen[1]]];
|
[for(i=[0:fn])
|
||||||
|
let(angleIncrement=(arcAngle/fn)*i*isCWorCCW)
|
||||||
|
[cos(p1Angle+angleIncrement)*r+cen.x,sin(p1Angle+angleIncrement)*r+cen.y]];
|
||||||
|
|
||||||
function translateRadiiPoints(radiiPoints,tran=[0,0],rot=0)=
|
function translateRadiiPoints(radiiPoints,tran=[0,0],rot=0)=
|
||||||
[for(i=radiiPoints)
|
[for(i=radiiPoints)
|
||||||
@@ -663,9 +664,9 @@ function getAngle(p1,p2)=p1==p2?0:invtan(p2[0]-p1[0],p2[1]-p1[1]);
|
|||||||
function getMidpoint(p1,p2)=[(p1[0]+p2[0])/2,(p1[1]+p2[1])/2]; //returns the midpoint of two points
|
function getMidpoint(p1,p2)=[(p1[0]+p2[0])/2,(p1[1]+p2[1])/2]; //returns the midpoint of two points
|
||||||
function pointDist(p1,p2)=sqrt(abs(sq(p1[0]-p2[0])+sq(p1[1]-p2[1]))); //returns the distance between two points
|
function pointDist(p1,p2)=sqrt(abs(sq(p1[0]-p2[0])+sq(p1[1]-p2[1]))); //returns the distance between two points
|
||||||
function isColinear(p1,p2,p3)=getGradient(p1,p2)==getGradient(p2,p3)?1:0;//return 1 if 3 points are colinear
|
function isColinear(p1,p2,p3)=getGradient(p1,p2)==getGradient(p2,p3)?1:0;//return 1 if 3 points are colinear
|
||||||
module polyline(p) {
|
module polyline(p, width=0.3) {
|
||||||
for(i=[0:max(0,len(p)-1)]){
|
for(i=[0:max(0,len(p)-1)]){
|
||||||
line(p[i],p[listWrap(i+1,len(p) )]);
|
color([i*1/len(p),1-i*1/len(p),0,0.5])line(p[i],p[listWrap(i+1,len(p) )],width);
|
||||||
}
|
}
|
||||||
} // polyline plotter
|
} // polyline plotter
|
||||||
module line(p1, p2 ,width=0.3) { // single line plotter
|
module line(p1, p2 ,width=0.3) { // single line plotter
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
include <polyround.scad>
|
include <polyround.scad>
|
||||||
|
|
||||||
basicPolyRoundExample();
|
basicPolyRoundExample();
|
||||||
|
// polyLineExample();
|
||||||
// parametricPolyRoundExample();
|
// parametricPolyRoundExample();
|
||||||
// experimentalParametricPolyRoundExample();
|
// experimentalParametricPolyRoundExample();
|
||||||
// conflicResolutionExample();
|
// conflicResolutionExample();
|
||||||
@@ -9,15 +10,23 @@ basicPolyRoundExample();
|
|||||||
// beamChainExample();
|
// beamChainExample();
|
||||||
// mirrorPointsExample();
|
// mirrorPointsExample();
|
||||||
// radiusExtrudeExample();
|
// radiusExtrudeExample();
|
||||||
// radiusExtrudePolygon();
|
|
||||||
// polyRoundExtrudeExample();
|
// polyRoundExtrudeExample();
|
||||||
|
|
||||||
module basicPolyRoundExample(){
|
module basicPolyRoundExample(){
|
||||||
|
// polyLine is a dev helper. Aim is to show the points of the polygon and their order before
|
||||||
|
// you're ready to move on to polyRound and a polygon
|
||||||
radiiPoints=[[-4,0,1],[5,3,1.5],[0,7,0.1],[8,7,10],[20,20,0.8],[10,0,10]];
|
radiiPoints=[[-4,0,1],[5,3,1.5],[0,7,0.1],[8,7,10],[20,20,0.8],[10,0,10]];
|
||||||
polygon(polyRound(radiiPoints,30));
|
polygon(polyRound(radiiPoints,30));
|
||||||
%translate([0,0,0.3])polygon(getpoints(radiiPoints));//transparent copy of the polgon without rounding
|
%translate([0,0,0.3])polygon(getpoints(radiiPoints));//transparent copy of the polgon without rounding
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module polyLineExample() {
|
||||||
|
radiiPoints=[[-4,0,1],[5,3,1.5],[0,7,0.1],[8,7,10],[20,20,0.8],[10,0,10]];
|
||||||
|
polyline(polyRound(radiiPoints,3), 0.05);
|
||||||
|
translate([0,10,0])
|
||||||
|
polyline(radiiPoints, 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
module parametricPolyRoundExample() {
|
module parametricPolyRoundExample() {
|
||||||
//Example of how a parametric part might be designed with this tool
|
//Example of how a parametric part might be designed with this tool
|
||||||
width=20; height=25;
|
width=20; height=25;
|
||||||
@@ -67,7 +76,7 @@ module experimentalParametricPolyRoundExample() {
|
|||||||
|
|
||||||
module conflicResolutionExample(){
|
module conflicResolutionExample(){
|
||||||
//example of radii conflict handling and debuging feature
|
//example of radii conflict handling and debuging feature
|
||||||
function makeRadiiPoints(r1, r2)=[[0,0,0],[0,20,r1],[20,20,r1],[20,0,0]];
|
function makeRadiiPoints(r1, r2)=[[0,0,0],[0,20,r1],[20,20,r2],[20,0,0]];
|
||||||
|
|
||||||
// the squre shape being 20 wide, two radii of 10 both fit into the shape (just)
|
// 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));
|
translate([-25,0,0])polygon(polyRound(makeRadiiPoints(10,10),50));
|
||||||
@@ -79,7 +88,7 @@ module conflicResolutionExample(){
|
|||||||
translate([25,0,0])polygon(polyRound(makeRadiiPoints(10,40),50));
|
translate([25,0,0])polygon(polyRound(makeRadiiPoints(10,40),50));
|
||||||
|
|
||||||
//mode 2 = no radii limiting
|
//mode 2 = no radii limiting
|
||||||
translate([50,0,0])polygon(polyRound(makeRadiiPoints(15,20),50,mode=2));
|
translate([50,0,0])polygon(polyRound(makeRadiiPoints(12,20),50,mode=2));
|
||||||
}
|
}
|
||||||
|
|
||||||
module translateRadiiPointsExample() {
|
module translateRadiiPointsExample() {
|
||||||
@@ -124,9 +133,9 @@ 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]];
|
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
|
// chained lines by themselves
|
||||||
translate(){
|
translate([0,0,0]){
|
||||||
radiiPoints=beamPoints(0,0);
|
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);}
|
for(i=[0: len(radiiPoints)-1]){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));
|
polygon(polyRound(beamChain(radiiPoints,offset1=0.02, offset2=-0.02),20));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,7 +143,7 @@ module beamChainExample(){
|
|||||||
// Add some radii to the line transitions
|
// Add some radii to the line transitions
|
||||||
translate([0,-7,0]){
|
translate([0,-7,0]){
|
||||||
radiiPoints=beamPoints(2,1);
|
radiiPoints=beamPoints(2,1);
|
||||||
for(i=[0: len(ex3)]){color("red")translate([radiiPoints[i].x,radiiPoints[i].y,0])cylinder(d=0.2, h=1);}
|
for(i=[0: len(radiiPoints)-1]){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));
|
polygon(polyRound(beamChain(radiiPoints,offset1=0.02, offset2=-0.02),20));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,7 +193,8 @@ module beamChainExample(){
|
|||||||
|
|
||||||
// Define multiple shells from the the one set of points
|
// Define multiple shells from the the one set of points
|
||||||
translate([0,-7*9,0]){
|
translate([0,-7*9,0]){
|
||||||
for(i=[0:2]){polygon(polyRound(beamChain(ex3,offset1=-1+i*0.4, offset2=-1+i*0.4+0.25),20));}
|
radiiPoints=beamPoints(2,1,rEnd=3);
|
||||||
|
for(i=[0:2]){polygon(polyRound(beamChain(radiiPoints,offset1=-1+i*0.4, offset2=-1+i*0.4+0.25),20));}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user