Please ignore secret bonuses. Secret tests do NOT award bonus. Max hw grade is 30+2 bonus efficiency

Do you need help?

Order of the rectangles

P
Paolo130601 (210 points)
0 1 3
in HW6 required by (210 points)
recategorized by
My question is: in any case, is it always possible establish a precise order of the rectangles? I mean, taking as instance the pic below, if I have two rectangles that are overlapped by a third one in common, which is the correct order to get in output? (Red, cyan, green), (red,green,cyan), they are both acceptable or this never happens in the tests? Thanks in advance :)

https://ibb.co/9GgZdXn
227 views

3 Answers

S
Silktrader (2550 points)
2 6 16
by (2.6k points)

Among the homework's assumptions there's (line #16):

the sequence of the drawing operations is unique (there is only one overlap between rectangles that orders them)

You should be able to determine the rectangles drawing order based on intersections. From my understanding of the specifications the configuration you brought up is invalid.

P
Pasqualino96 (1490 points)
4 23 27
by (1.5k points)

Let's take the image "circle.png" available in the HW6 as an example: as you can see, the green square is not overlapped by any other ones. This means that it is the last one in the order beacuse, if you think of squares as if they were cards in a deck and you start laying them on a table one by one, you'll see why the green square is the last one. Meanwhile, the pink square is the first because it has been overlapped by the green (which we said it was the last one) and the grey which is the second "card" in the order because it is upon the pink one but under the blue one (which is under ther green one who's the last "card").

I hope i made it clear for you how intersection works on this  HW. If there's still something not clear, don't be afraid to send me a message and don't forget to select this answer as the best one xD!

------------------------------ ITA -------------------------------------------

Prendiamo come esempio l'immagine "circle.png" disponibile in HW6: come puoi vedere, il quadrato verde non è sovrapposto ad altri. Questo significa che è l'ultimo nell'ordine perché, se pensi ai quadrati come se fossero carte in un mazzo e inizi a posarli uno ad uno su un tavolo, vedrai perché il quadrato verde è l'ultimo . Nel frattempo, il quadrato rosa è il primo perché è stato sovrapposto al verde (che abbiamo detto era l'ultimo) e al grigio che è la seconda "carta" nell'ordine perché è sopra quello rosa ma sotto il blu uno (che è sotto quello verde che è l'ultima "carta").

Spero di averti chiarito come funziona l'intersezione su questo HW. Se c'è ancora qualcosa che non è chiaro, non aver paura di inviarmi un messaggio e non dimenticare di selezionare questa risposta come la migliore xD!

b
benjamin (2490 points)
1 7 21
by (2.5k points)
The image you linked is not a valid one since there is no unique way to order them. We can tell that the green one was the last but then we have two valid 'routes' we could take, hence there  are two possible ways the arrange the rectangles.