public static bool Vne(CuttingArguments cut, int x0, int y0, int x1, int y1) { if (Intersection(cut, x0, y0, x1, y1)) { return(false); } if (!(cut.MinX < x0 && x0 < cut.MaxX)) { return(true); } if (!(cut.MinX < x1 && x1 < cut.MaxX)) { return(true); } if (!(cut.MinY < y0 && y0 < cut.MaxY)) { return(true); } if (!(cut.MinY < y1 && y1 < cut.MaxY)) { return(true); } return(false); }
private static bool Intersection(CuttingArguments cut, int x0, int y0, int x1, int y1) { int ax1, ay1, ax2, ay2, bx1, by1, bx2, by2; ax1 = cut.MinX; ay1 = cut.MinY; ax2 = cut.MaxX; ay2 = cut.MinY; bx1 = x0; by1 = y0; bx2 = x1; by2 = y1; int v1 = (bx2 - bx1) * (ay1 - by1) - (by2 - by1) * (ax1 - bx1); int v2 = (bx2 - bx1) * (ay2 - by1) - (by2 - by1) * (ax2 - bx1); int v3 = (ax2 - ax1) * (by1 - ay1) - (ay2 - ay1) * (bx1 - ax1); int v4 = (ax2 - ax1) * (by2 - ay1) - (ay2 - ay1) * (bx2 - ax1); if ((v1 * v2 <= 0) && (v3 * v4 <= 0)) { return(true); } ax1 = cut.MaxX; ay1 = cut.MinY; ax2 = cut.MaxX; ay2 = cut.MaxY; bx1 = x0; by1 = y0; bx2 = x1; by2 = y1; v1 = (bx2 - bx1) * (ay1 - by1) - (by2 - by1) * (ax1 - bx1); v2 = (bx2 - bx1) * (ay2 - by1) - (by2 - by1) * (ax2 - bx1); v3 = (ax2 - ax1) * (by1 - ay1) - (ay2 - ay1) * (bx1 - ax1); v4 = (ax2 - ax1) * (by2 - ay1) - (ay2 - ay1) * (bx2 - ax1); if ((v1 * v2 <= 0) && (v3 * v4 <= 0)) { return(true); } ax1 = cut.MaxX; ay1 = cut.MaxY; ax2 = cut.MinX; ay2 = cut.MaxY; bx1 = x0; by1 = y0; bx2 = x1; by2 = y1; v1 = (bx2 - bx1) * (ay1 - by1) - (by2 - by1) * (ax1 - bx1); v2 = (bx2 - bx1) * (ay2 - by1) - (by2 - by1) * (ax2 - bx1); v3 = (ax2 - ax1) * (by1 - ay1) - (ay2 - ay1) * (bx1 - ax1); v4 = (ax2 - ax1) * (by2 - ay1) - (ay2 - ay1) * (bx2 - ax1); if ((v1 * v2 <= 0) && (v3 * v4 <= 0)) { return(true); } ax1 = cut.MinX; ay1 = cut.MaxY; ax2 = cut.MinX; ay2 = cut.MinY; bx1 = x0; by1 = y0; bx2 = x1; by2 = y1; v1 = (bx2 - bx1) * (ay1 - by1) - (by2 - by1) * (ax1 - bx1); v2 = (bx2 - bx1) * (ay2 - by1) - (by2 - by1) * (ax2 - bx1); v3 = (ax2 - ax1) * (by1 - ay1) - (ay2 - ay1) * (bx1 - ax1); v4 = (ax2 - ax1) * (by2 - ay1) - (ay2 - ay1) * (bx2 - ax1); if ((v1 * v2 <= 0) && (v3 * v4 <= 0)) { return(true); } return(false); }
internal static bool Vne(CuttingArguments cutArgs, int x2, int y2) { if (x2 < cutArgs.MinX) { return(true); } if (y2 < cutArgs.MinY) { return(true); } if (x2 > cutArgs.MaxX) { return(true); } if (y2 > cutArgs.MaxY) { return(true); } return(false); }
public void Draw(IPixelSet pixelSet, IDrawingArea drawingArea) { var cut = new CuttingArguments { MinX = Math.Min(x0, x1), MinY = Math.Min(y0, y1), MaxX = Math.Max(x0, x1), MaxY = Math.Max(y0, y1), }; IPaintTool line1 = Line2Tool.Build(); line1.OnMouseClick(cut.MinX, cut.MinY); line1.OnMouseClicked(cut.MinX, cut.MaxY); line1.Draw(pixelSet, drawingArea); IPaintTool line2 = Line2Tool.Build(); line2.OnMouseClick(cut.MinX, cut.MaxY); line2.OnMouseClicked(cut.MaxX, cut.MaxY); line2.Draw(pixelSet, drawingArea); IPaintTool line3 = Line2Tool.Build(); line3.OnMouseClick(cut.MaxX, cut.MaxY); line3.OnMouseClicked(cut.MaxX, cut.MinY); line3.Draw(pixelSet, drawingArea); IPaintTool line4 = Line2Tool.Build(); line4.OnMouseClick(cut.MaxX, cut.MinY); line4.OnMouseClicked(cut.MinX, cut.MinY); line4.Draw(pixelSet, drawingArea); foreach (IPaintTool paintTool in drawingArea) { paintTool.Cutting(cut); } }
public void Cutting(CuttingArguments cut) { }
public void Cutting(CuttingArguments cut) { cuttingMode = true; this.cutArgs = cut; }
public void Cutting(CuttingArguments cut) { throw new NotImplementedException(); }
public void Cutting(CuttingArguments cut) { this.cutPoint = cut; }