#Help with an algorithm

6 messages · Page 1 of 1 (latest)

toxic drift
#

I'm having trouble with an algorithm
let's say I have 3 rectangles, the sides of each rectangle are parallel to the x and y axis.
These rectangles can overlap, the goal is to find the area of all rectangles minus the intersection.

I have a few test cases and the area it's supposed to result in

Here's what I tried
I tried calculating the area of each of the 3 rectangles
Then I calculated the intersection between rectangles 1 and 3, 1 and 2 and 2 and 3, and substracted that.
I can't get that result.

Can someone help me out with a hint or what I'm doing wrong with my thought process

elfin furnaceBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

toxic drift
#

I'm not supposed to solve this by going through all the points in the region of the rectangles, as that would be inefficient

next linden
toxic drift
#

thank you

#

!solved