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

  • Home
  • SEARCH
  • 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 8628813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:38:48+00:00 2026-06-12T08:38:48+00:00

I’ve just implemented collision detection using SAT and this article as reference to my

  • 0

I’ve just implemented collision detection using SAT and this article as reference to my implementation. The detection is working as expected but I need to know where both rectangles are colliding.

I need the center of the intersection
More examples

I need to find the center of the intersection, the black point on the image above (but I don’t have the intersection area neither). I’ve found some articles about this but they all involve avoiding the overlap or some kind of velocity, I don’t need this.

The information I’ve about the rectangles are the four points that represents them, the upper right, upper left, lower right and lower left coordinates. I’m trying to find an algorithm that can give me the intersection of these points.

I just need to put a image on top of it. Like two cars crashed so I put an image on top of the collision center. Any ideas?

  • 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-06-12T08:38:49+00:00Added an answer on June 12, 2026 at 8:38 am

    There is another way of doing this: finding the center of mass of the collision area by sampling points.

    Create the following function:

    bool IsPointInsideRectangle(Rectangle r, Point p);
    

    Define a search rectangle as:

    TopLeft = (MIN(x), MAX(y))
    TopRight = (MAX(x), MAX(y))
    LowerLeft = (MIN(x), MIN(y))
    LowerRight = (MAX(x), MIN(y))
    

    Where x and y are the coordinates of both rectangles.

    You will now define a step for dividing the search area like a mesh. I suggest you use AVG(W,H)/2 where W and H are the width and height of the search area.

    Then, you iterate on the mesh points finding for each one if it is inside the collition area:

    IsPointInsideRectangle(rectangle1, point) AND IsPointInsideRectangle(rectangle2, point) 
    

    Define:

    Xi : the ith partition of the mesh in X axis.
    CXi: the count of mesh points that are inside the collision area for Xi.
    

    Then:

    enter image description here

    And you can do the same thing with Y off course. Here is an ilustrative example of this approach:

    enter image description here

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I have thousands of HTML files to process using Groovy/Java and I need to
I need to clean up various Word 'smart' characters in user input, including but
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but

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.