Is There a Ready Routine for Intersection Calculation in Polygons? lazarus / 39-Graphics ---------------------------------------------------------------------- loaded · 2021-01-03 18:02 Hi Everyone. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  procedure TForm1.FormPaint(Sender: TObject);var  poly:array[0..3] of TPoint;  cline:array[0..1] of TPoint;begin  poly[0]:=Point(100,100);  poly[1]:=Point(ClientWidth-100,100);  poly[2]:=Point(ClientWidth-100,ClientHeight-100);  poly[3]:=Point(100,ClientHeight-100);  canvas.brush.color:=clred;  canvas.brush.Style:=bsCross;  canvas.Polygon(poly);  cline[0]:=Point(round(ClientWidth/2)+10,10);  cline[1]:=Point(round(ClientWidth/2)-10,ClientHeight-10);  canvas.pen.Width:=3;  canvas.Polyline(cline);end; With the code above There is an example polygon that I have drawn (it consists of 4 points in the drawing, but it can actually consist of 3-50 points). And I want to cut this polygon according to a certain line. So actually I want to get their intersections as fields. In the future, I will work to calculate the combination or differences of intertwined areas. Before dealing with geometry formulas, I wanted to consult you. What is the best method for this job? ---------------------------------------------------------------------- wp · 2021-01-03 21:33 This is pretty complicated stuff for the general case... There is a Delphi library "Clipper" by Angus Johnson from which you maybe get an idea what to do. It is for Graphics32, but I think the algorithm should be general enough so that you can extend it to your purpose: https://sourceforge.net/projects/polyclipping/. I am attaching the demo project as well as Angus' clipper unit, converted to Lazarus. Please note that the demo required Graphics32 to be installed -- you can get it via Online-Package-Manager as pl_Graphics32. P.S. Maybe similar stuff is in BGRABitmap, I don't know. ---------------------------------------------------------------------- circular · 2021-01-03 21:35 Not yet in BGRABitmap. But that would be cool ---------------------------------------------------------------------- Seenkao · 2021-01-03 22:40 Разбейте полигон на треугольники. Eng: Divide the polygon into triangles. ---------------------------------------------------------------------- loaded · 2021-01-04 11:24 wp, circular, seenkao, thank you individually. wp, I'm trying to run the demo you posted. I hope it works. circular, I hope you add these features to a BGRAbitmap, and we pray for you. seenkao, my path will definitely cross with the triangulation process one day. This is an issue that I am aware of but always avoid. If I can't find an easier way, I'll gradually learn to triangulate. ---------------------------------------------------------------------- marcov · 2021-01-04 11:29 Angus library has a bit weird license. ---------------------------------------------------------------------- BeanzMaster · 2021-01-22 07:05 Hi load look at the function TBZ2DPolygonTool.IntersectWithLine(aLine : TBZ2DLineTool; out IntersectPoints : TBZArrayOfFloatPoints) : Boolean; (line 423) here https://github.com/jdelauney/BZScene/blob/mas ter/Source/Utils/BZGeoTools.pas perhaps it can help you a bit. Cheers