Link to home
Start Free TrialLog in
Avatar of gegege
gegege

asked on

Fill an Area with 4 differnet size rectangles (in a random order) [1000 points]

I have 3 squares and 1 rectangle with these sizes:

200 x 200
300 x 300
400 x 400

and 1 rectangle

200 x 400

What I need to do is given a larger rectangle which will always change, fill it with random amounts of the above four shapes in random orders. I would need to be able to change the shapes from time to time as well (they will always be square or rectangles though).

Does anyone have any idea how I can do this?  I am not looking for code, just some pointers.



Avatar of jamanat
jamanat

-------  ----  ----  ----
|  A   | | B | | C | | D |
|------| |---| |---| |---|

Now above are the figures you gave A(rectangle) B,C,D(squares) right? suppose you have a larger rectangle F.
   Here are some of the questions:
  1. F will always change it's size and position?
  2. A,B,C,D has to perfectly fit in F? or partially will do?
  3. Do you need to fill F completely? or some open space will do?
  4. overlap of A,B,C,D is ok? or there shouldn't be any overlap?

  Final question, do you need logic for filling F? or you need logic for creating F also?

  I may be able to think if you answer these questions.. thanks.

Jamanat
Avatar of gegege

ASKER

hi jamanat,

1 - F will be different, I will let the user decide the actual size, but I am going to say it will always be a rectange.

2 - They don't have to fit perfectly, they can go outside of F, but by the smallest amount possible

3 - I need to fill it completly

4 - there can't be any overlap - but if it is not possible that the shapes fit together (as one is 300 (as opposed to 200 or 400) and so they won't be even) then it is possible to cut the shapes but I would like to avoid this as much as possible.

I just need the logic for filling f.

thanks, I am really not sure how to do this so any help you can give would be great.
Avatar of gegege

ASKER

any ideas?
ASKER CERTIFIED SOLUTION
Avatar of ygal02
ygal02

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gegege

ASKER

yeah, i got a mate to explain it at the weekend and this is basically what he said so I think this is what I will do.

cheers