Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6386879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:04:55+00:00 2026-05-25T03:04:55+00:00

I have a large window in which there are n small windows. Task to

  • 0

I have a large window in which there are n small windows. Task to place small windows so that between them there was no intersection, or say that it’s impossible to do.

All windows are rectangular and have the coordinates of all vertices.

I understand how easy it is to determine whether cross one of the rectangles with the others. It’s enough to look at include whether the coordinates of the vertices in any other rectangle.

But here’s how to find a free area where you could move this rectangle?

In my case, small windows appear in the big one. And the problem looks like.
enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T03:04:56+00:00Added an answer on May 25, 2026 at 3:04 am

    This looks somewhat like a Rectangle Packing problem.
    There are examples and implementations out there that can help.

    The thing that differs is that you’re dealing with an UI, not textures or some other problem. You can go for the above mentioned solutions, but I imagine you will need some sort of transition animation so the user sees/understands where all his/her window will end up.

    It depends how this feature works I presume. Is the user allowed to intersect windows in the first place ?

    I imagine all rectangles will need to fit into a larget one (the display)

    I’ve been playing with different sized rectangles of paper on my desk and here is something that comes to mind:

    1st determine if all you’ve got enough space: split the left over space into rectangles and add the rectangle areas then check if the space areas are larger or equal to the intersection areas. If so continue.

    1. Loop through all rectangles and find intersections.
    2. For each intersection, store the rectangles involved.
    3. Loop through all the rectangles that have intersections and store the available space in
      the remaining directions (e.g. left,top-left,top,etc.)
    4. For each rectangle with intersections, add the horizontal left over space to check if it its larger than the width of the intersection rectangle, then do the same with vertical left over space. This step should allow to determine if you can move only the rectangles with intersections to get enough space to clear intersections.
    5. If the above aplies use the remaining space to determine how much you need to move each rectangle. Choose the direction of separation (vertical or horizontal) based on which left over spacing is larger (e.g. total top+bottom vs total left+right). Then move each box in the direction of separation(e.g if horizontal move the rectangle with the smallest horizontal space by that amount, then the other rectangle towards it’s remaining space) and re-evaluate the intersection for this case. If there are no intersections, hooray…otherwise, do the same with vertical space.
    6. If this pint 4 does not apply that means you can’t move the rectangles slightly using the space around them, you need to use more space. Include the nearest box and it’s space
      then check again if the extra space is sufficient.

    Here’s what I mean by splitting the remaining space into boxes to find the area:
    boxes and intersections

    I would suggest first checking the rectangle packing solutions I’ve linked to, as they use the available space optimally and it actually works, not something I came with by playing with paper 🙂
    I haven’t coded/tested my solution yet.

    HTH

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a large database table that I need to display on a Windows
I have a windows service that receives a large amount of data that needs
I have a large makefile which builds several libraries, installs them, and then keeps
I have a CWnd window which I create dynamically, and it seems that the
I have a CWnd window which I create dynamically, and it seems that the
We have a large number of Window Mobile Devices (Symbol MC35 & MC70). I
I have a directory on a Windows machine with a large number of files
I have large batches of XHTML files that are manually updated. During the review
I'm developing a website in PHP and I have large JS files that I
I have written a small test program in which I try to use the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.