title: Cut polygon algorithm
body: <p>i'm trying to solve a problem where a polygon object that cross the min/max Y points have to be splited to parts thus new rectangle/polygon object will be created</p>
  
  <p><img src="https://i.stack.imgur.com/7KUkY.png" alt="enter image description here"></p>
  
  <p>Here the red marked range is my x1,y1 and x2,y2 points and everything that is inside of it must be removed, green marked fields are the new objects that have to be created after removing red marked field, the problem is that i cannot track where to "close" the newly created rectangle. I need someone to offer some algorithm of doing this or link me to the existing algorithms.</p>