How do I detect whether two 2D polygons intersect with each other | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How do I detect whether two 2D polygons intersect with each other

Basically each polygon represents an array of "Vector2D" (Vector2D has two properties: x: float, y: float) Also need to take into account that the arrays could have different lengths (meaning that one polygon could have more sides than the other) I am not asking how to calculate intersection area or something like that, I would like to have a function which returns true or false whether the two polygons intersect. So what is the best algorithm for a task like that? Also, answers are very much appreciated!

16th Dec 2020, 12:18 AM
Frumkin
Frumkin - avatar
1 Answer
+ 1
Then you are asking how to calculate intersection... please look up the math yourself, give it a shot, and ask questions with code showing that you at least tried.
16th Dec 2020, 12:36 AM
Slick
Slick - avatar