|
|
|
#1 |
|
Senior Member
Join Date: Jan 2003
Location: Austin, TX
Posts: 293
|
area of intersection between rotated rectangles
hi guys
How would I go about finding the area of the intersection between two rectangles that may be rotated relative to each other? The information I have to work with is their coordinates (one centered, one top left aligned, but it wouldn't be hard to find the other center point if that's necessary), the width and height of each rectangle, and the angles they are rotated at. |
|
|
|
|
|
#2 |
|
Senior Member
Join Date: Jul 2007
Location: Columbus, OH.
Posts: 461
|
One solution could be to (i) use the sutherland hodgman algorithm to clip one rectangle within the other, and then (ii) use greens theorem/the surveyors formula to compute the area. The second step is easy, but the first step requires a little bit of care to program correctly.
There might be a simpler solution, so be sure to ask around at some other places.
__________________
Completed games:Mind Maze (48 hour job), Puzzle Kaboom, Pinball Racers, Spice Hunters Ongoing Projects: Doom-a-like, Quake-a-like, updated Feb. 4 '09 About me: Homepage. |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Oct 2002
Posts: 444
|
or use drawing api + blending modes + bitmap.draw + getColorBoundsRect per every scan line to estimate the area.
|
|
|
|
|
|
#4 |
|
Senior Member
Join Date: Dec 2004
Posts: 453
|
find the two intersection points and the two points for the corners, and then divide it into two triangles. That will make it a lot simpler.
|
|
|
|
![]() |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|