Area of a square cut by a line, identifying the smaller side

area

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.

enter image description here

Edit: BTW I do know the x,y positions of all path intersections and I know the grid points.

Best Answer

@Valerie:

Does this figure help?

enter image description here

Just take the average of the $y$ (vertical) values at the left value of $x$ and right value of $x$--the green points. If this average is above the squares midpoint, then the larger area is below.