Closed gezhaowan closed 3 years ago
Could you send me a minimal testfile with a bunch of different-sized thermals?
On Wed, 18 Nov 2020 at 12:30, gezhaowan notifications@github.com wrote:
I tried to implement the SetThermal function and tried many methods, but the output result is always incorrect. I confirm that there is no problem with my drawing logic; The closest output is like this. [image: image] https://user-images.githubusercontent.com/33305089/99524804-f0d10300-29d3-11eb-8875-d49b5de9891a.png
Do you have any suggestions? @StijnKuipers https://github.com/StijnKuipers
` internal void SetThermal(double Xoff, double Yoff, double OuterDiameter, double InnerDiameter, double GapWidth, double Rotation) { Shape.Vertices.Clear(); GerberApertureType sector1 = new GerberApertureType(); GerberApertureType sector2 = new GerberApertureType(); GerberApertureType sector3 = new GerberApertureType(); GerberApertureType sector4 = new GerberApertureType(); int sides = (int)Math.Floor(10 Math.Max(4.0, OuterDiameter / 2)); { double radius = OuterDiameter / 2; double padd = 0;// -rotation Math.PI 2.0 / 360; for (int i = 0; i < sides; i++) { double P = i / (double)sides Math.PI 2.0 + padd; double x = (double)(Xoff + Math.Sin(P) radius); double y = (double)(Yoff + Math.Cos(P) * radius); if ((y < Yoff - GapWidth / 2) && (x < Xoff - GapWidth / 2)) { sector1.Shape.Add(x, y); } if ((y < Yoff - GapWidth / 2)&& (x >= Xoff + GapWidth / 2)) { sector2.Shape.Add(x, y); } if ((y >= Yoff + GapWidth / 2) && (x < Xoff - GapWidth / 2)) { sector3.Shape.Add(x, y); } if ((y >= Yoff + GapWidth / 2) && (x >= Xoff + GapWidth / 2)) sector4.Shape.Add(x, y); } }
{ double radius = InnerDiameter / 2; //int sides = (int)Math.Floor(10 * Math.Max(2.0, radius)); double padd = 0;// -rotation * Math.PI * 2.0 / 360; Shape.Vertices.Clear(); for (int i = sides-1; i >= 0; i--) { double P = i / (double)sides * Math.PI * 2.0 + padd; double x = (double)(Xoff + Math.Sin(P) * radius); double y = (double)(Yoff + Math.Cos(P) * radius); if ((y < Yoff - GapWidth / 2) && (x < Xoff - GapWidth / 2)) { sector1.Shape.Add(x, y); } if ((y < Yoff - GapWidth / 2) && (x >= Xoff + GapWidth / 2)) { sector2.Shape.Add(x, y); } if ((y >= Yoff + GapWidth / 2) && (x < Xoff - GapWidth / 2)) { sector3.Shape.Add(x, y); } if ((y >= Yoff + GapWidth / 2) && (x >= Xoff + GapWidth / 2)) sector4.Shape.Add(x, y); } } sector1.Shape.Close(); sector2.Shape.Close(); sector3.Shape.Close(); sector4.Shape.Close(); Parts.Add(sector1); Parts.Add(sector2); Parts.Add(sector3); Parts.Add(sector4);
} `
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ThisIsNotRocketScience/GerberTools/issues/122, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABSI6LQT646J7IM5P6IXBTSQOV57ANCNFSM4TZ3BOOQ .
PCB Benchmark.zip This is the test file I used. There is only one thermal pad inside.
I have solved it. The main reason is that PolyLine is initialized with 4 points. After clearing it, it is fine.
Cool! Thanks! :-D
On Thu, 19 Nov 2020 at 03:19, gezhaowan notifications@github.com wrote:
[image: image] https://user-images.githubusercontent.com/33305089/99612424-814d2900-2a50-11eb-8201-a94a9eaa9012.png I have solved it. The main reason is that PolyLine is initialized with 4 points. After clearing it, it is fine.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ThisIsNotRocketScience/GerberTools/issues/122#issuecomment-730081955, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABSI6IWU6FZSBEVRQQV2CDSQR6EFANCNFSM4TZ3BOOQ .
I tried to implement the SetThermal function and tried many methods, but the output result is always incorrect. I confirm that there is no problem with my drawing logic; The closest output is like this.
Do you have any suggestions? @StijnKuipers
` internal void SetThermal(double Xoff, double Yoff, double OuterDiameter, double InnerDiameter, double GapWidth, double Rotation) { Shape.Vertices.Clear(); GerberApertureType sector1 = new GerberApertureType(); GerberApertureType sector2 = new GerberApertureType(); GerberApertureType sector3 = new GerberApertureType(); GerberApertureType sector4 = new GerberApertureType(); int sides = (int)Math.Floor(10 Math.Max(4.0, OuterDiameter / 2)); { double radius = OuterDiameter / 2; double padd = 0;// -rotation Math.PI 2.0 / 360; for (int i = 0; i < sides; i++) { double P = i / (double)sides Math.PI 2.0 + padd; double x = (double)(Xoff + Math.Sin(P) radius); double y = (double)(Yoff + Math.Cos(P) * radius); if ((y < Yoff - GapWidth / 2) && (x < Xoff - GapWidth / 2)) { sector1.Shape.Add(x, y); } if ((y < Yoff - GapWidth / 2)&& (x >= Xoff + GapWidth / 2)) { sector2.Shape.Add(x, y); } if ((y >= Yoff + GapWidth / 2) && (x < Xoff - GapWidth / 2)) { sector3.Shape.Add(x, y); } if ((y >= Yoff + GapWidth / 2) && (x >= Xoff + GapWidth / 2)) sector4.Shape.Add(x, y); } }
} `