I have a grid with a path running through it. Within each of the grid squares, where the path intersects, I want to determine which side of the current grid has the smaller area. I was hoping there was a clever way to do this by measuring up (or down) from the grid corners, to where the path intersects, and calculating if they crossed more than 50% of the grid, but I'm not clever enough cuz whatever I try fails. So I was wondering if anyone could suggest the proper route to do it this for each square will have a different shape.
I'm assuming I'll have to break each grid into "shapes", and then calculate the area of the shapes; but I was hoping not to have to go that route. In my case I'm writing a javascript program to automate this, so having to determine the shapes programmatically will also be a challenge. Thanks!
Here's a pic of what I'm talking about.
Edit: BTW I do know the x,y positions of all path intersections and I know the grid points.

