1

I have polygon and a line.

g.drawLine(this.getLine().getP1().getX(), this.getLine().getP1().getY(),
                this.getLine().getP2().getX(), this.getLine().getP2().getY());

g.drawPolygon(this.polygon);

and I have to find the cross-points between the polygon and the line(if any), and what part of the line is in the polygon. Any ideas how to do that .

Evgeni Dimitrov
  • 21,976
  • 33
  • 120
  • 145

1 Answers1

2

In Java, the problem can be reduced to finding the intersection of two lines. Each pair of lines consists of the original line and a line obtained from the PathIterator of the Polygon. There's a related example here.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045