GGB allows self-intersecting polygons, but disagrees with itself about what regions are defined and how to measure them.
Let me get a picture of the problem, and introduce a consistent set of definitions.
Then I can provide at least one working solution.
_____
Tool -- Intersect ray and polygon: [url]http://www.geogebratube.org/material/show/id/96426[/url]