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(); } }
public G2G3Helper(LaserGRBL.GrblCommand.StatePositionBuilder spb, LaserGRBL.GrblCommand cmd) { bool jb = cmd.JustBuilt; if (!jb) { cmd.BuildHelper(); } CW = spb.G2; 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 = 0.0; double oY = 0.0; if (cmd.R != null) //G2G3 use R cmd { oX = ((aX + bX) / 2.0) - aX; oY = ((aY + bY) / 2.0) - aY; } else { oX = cmd.I != null ? (double)cmd.I.Number : 0.0; //offsetX 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 (Circle(aX, aY, bX, bY)) { BBox = new Rect(RectX, RectY, RectW, RectH); } else { BBox = CW ? BBBox(EndAngle, StartAngle, Ray, CenterX, CenterY) : BBBox(StartAngle, EndAngle, Ray, CenterX, CenterY); } if (!jb) { cmd.DeleteHelper(); } }