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 990139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:54:10+00:00 2026-05-16T05:54:10+00:00

I have complex polygons which I know the minimum x, minimum y, maximum x

  • 0

I have complex polygons which I know the minimum x, minimum y, maximum x and maximum y. I also have another rectangle which I know the top left and bottom right vertices. Knowing this information, how can I know if these 2 bounding boxes are colliding? Thanks

  • 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-16T05:54:10+00:00Added an answer on May 16, 2026 at 5:54 am

    Try something like this:

    typedef struct rect {
        int top;     // maximum y-coord
        int bottom;  // minimum y-coord
        int left;    // minimum x-coord
        int right;   // maximum x-coord
    } rectangle;
    
    // Returns 1 if the point (x, y) lies within the rectangle, 0 otherwise
    int is_point_in_rectangle(rectangle r, int x, int y) {
        if ((r.left   <= x && r.right >= x) &&
            (r.bottom <= y && r.top   >= y))
            return 1;
        return 0;
    }
    
    // Returns 1 if the rectangles overlap, 0 otherwise
    int do_rectangles_intersect(rectangle a, rectangle b) {
        if ( is_point_in_rectangle(a, b.left , b.top   ) ||
             is_point_in_rectangle(a, b.right, b.top   ) ||
             is_point_in_rectangle(a, b.left , b.bottom) ||
             is_point_in_rectangle(a, b.right, b.bottom))
            return 1;
        if ( is_point_in_rectangle(b, a.left , a.top   ) ||
             is_point_in_rectangle(b, a.right, a.top   ) ||
             is_point_in_rectangle(b, a.left , a.bottom) ||
             is_point_in_rectangle(b, a.right, a.bottom))
            return 1;
        return 0;
    }
    

    You can do the same for any polygon, just iterate through all of its points and call is_point_in_rectangle with them. Since you only have a bounding box for the complex polygon, there is a chance that this method gives you a false positive (that is, the rectangle is inside the complex polygon’s bounding box but outside of the polygon itself). However, this restriction applies to any method where a complex shape is simplified to a bounding box.

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

Sidebar

Related Questions

I am using WCF and REST, and I have complex types, which are working
I have some complex regular expressions which I need to comment for readability and
I have a complex type defined which doesn't currently contain any minOccurs restrictions. When
I have complex logic which is not possible (too slow) to run through PHP
I have a complex action which can take a long time to run. If
We have complex template classes that have some methods which will not work with
I have complex GUI application written in Python and wxPython. I want it to
I have some complex message to show inside of a flash message so instead
We have a complex app that serves AJAX JSON streams (using ADO to grab
I have several complex data structures like Map< A, Set< B > > Set<

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.