I have a parallelogram, for which I have the "half width" vectors (that is, this was a unit square that has had an arbitrary affine transformation applied to it). I have another square, which we can arbitrarily say is the axis aligned unit square.
I want to determine the area of overlap of the parallelogram with the square. Or more precisely, I want to determine the percentage overlap of the parallelogram by the square.
I can think of some relatively straight-forward ways to approximate the area using monte-carlo techniques, but I'm wondering if there's a more analytic solution.
I can imagine, for instance, using something like Sutherland-Hodgman to construct the convex hull of the overlap, and then finding the area of that convex hull. But that seems like overkill.
Plus, this would be for a pixel shader (hopefully SM2, though I might bump it up to SM3 if absolutely necessary), so I'm a bit concerned about branching. Sutherland-Hodgman and then area calculation seem pretty hard to construct without branching, because of all the different cases (though I haven't really tried yet, so it's probably doable).
Anyway, I'm just wondering if anyone has any other ideas for how to approach the problem.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement