I have defined a Polygon. I want to intersect and trim a list of other Lines with the Edges of this polygon (white rectangle here), so that endpoints of lines are limited to the inner part of the polygon.
currently, I'm intersecting each cyan line with the edges of the polygon which gives me the intersection points. But the problems is I don't know how to trim them. I know that I need to change the X1, Y1, X2 and Y2 of each intersecting line (cyan line) to the intersection point. But I don't know how do do it.
Let me explain it this way. A cyan line intersects one of the edges of the polygon, now I need to move the endpoint of the cyan line to the intersection point to simulate a trim right? Which endpoint I need to move? I'm a bit lost here.
public class Polygon
{
public List<Line>() Edges;
}
public class Line
{
public double X1;
public double X2;
public double Y1;
public double Y2;
}
var listOfIntersectingLines = new List<Line>() {L1, L2, ... };
var ListOfLinesLimitedToPolygon = ?

