Open Vasilius-001 opened 3 years ago
I have implemented math only for I-J format of G2/G3. I guess it could be simple to implement, but I am not so good in math :-(
public G2G3Helper(LaserGRBL.GrblCommand.StatePositionBuilder spb, LaserGRBL.GrblCommand cmd)
{
bool jb = cmd.JustBuilt;
if (!jb) cmd.BuildHelper();
double aX = (double)spb.X.Previous; //startX
double aY = (double)spb.Y.Previous; //startY
double bX = (double)spb.X.Number; //endX
double bY = (double)spb.Y.Number; //endY
double oX = cmd.I != null ? (double)cmd.I.Number : 0.0; //offsetX
double oY = cmd.J != null ? (double)cmd.J.Number : 0.0; //offsetY
CenterX = aX + oX; //centerX
CenterY = aY + oY; //centerY
Ray = Math.Sqrt(oX * oX + oY * oY); //raggio
RectX = CenterX - Ray;
RectY = CenterY - Ray;
RectW = 2 * Ray;
RectH = 2 * Ray;
StartAngle = CalculateAngle(CenterX, CenterY, aX, aY); //angolo iniziale
EndAngle = CalculateAngle(CenterX, CenterY, bX, bY); //angolo finale
AngularWidth = AngularDistance(StartAngle, EndAngle, spb.G2);
if (!jb) cmd.DeleteHelper();
}
Hello, I found this something to convert the G02/G03 problem with radius to center coordinates. If you assume that you put a circle with radius R at the start and end point of the arc and where the two circles touch is the center of the arc, you can convert these coordinates to I and J. The page is unfortunately in German, has a JavaScript to calculate the center. Maybe you can have a look at it and include it in your Conde. Unfortunately I don't have a compiler on my computer to help you with this. I just found out that Microsoft Edge can also translate web pages. I personally use Deepl as a translator, it's online.
http://walter.bislins.ch/blog/index.asp?page=Schnittpunkte+zweier+Kreise+berechnen+%28JavaScript%29
There is a laser engraver with GRBL 1.1h firmware. I need to draw circles and arcs, for this I create in a manual file. I open the file in LaserGRBL 3.7.1. Circles are displayed in the preview, but arcs are not displayed at all. In this case, the image with a laser engraver is correct.