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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:15:14+00:00 2026-05-22T23:15:14+00:00

I’m using the implementation of the algorithm described here: http://www.codezealot.org/archives/55 Using this implementation, when

  • 0

I’m using the implementation of the algorithm described here: http://www.codezealot.org/archives/55

Using this implementation, when I want to find the minimal displacement vector for two colliding rectangles, the algorithm will sometimes (in one of two cases to be exact) give me the wrong “direction” in which one rectangle needs to pushed in order to get away from the rectangle that it’s colliding with. It will instead produce the exact opposite direction from the one which it is supposed to go in.

This is because (of course) the two opposing edges of a rectangle are of course mathematically similar and hence produce the same results.

This is the implementation of the algorithm in Java:

http://pastebin.com/fgAwBsGv

You can assume that Vector2f, Projection2D etc. function correctly and produce correct values. By the way,

I’m using left hand normals because the polygon is assembled counterclock-wise. Principally, this should be enough, since the left-hand normal will always point away from the polygon. The problem is that since the two overlaps of opposing edges of a rectangle will be exactly the same, the algorithm will simply use the first one and its corresponding axis.

thanks for your help!

  • 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-22T23:15:15+00:00Added an answer on May 22, 2026 at 11:15 pm

    Hey, I forgot that I created this question a while ago, so I’m going to answer it now in case somebody else has the same problem:

    The solution is to simply turn around the displacement vector (multiply it by -1) if it’s pointing towards the shape from which the object needs to be pushed away.

    To find out if the displacement vector is pointing towards the shape, you first have to get the general direction from object a to object b by subtracting their centers from each other. After that, you check the dot product between the displacement vector and the direction(a,b) vector that you just created. If it’s > 0, the displacement vector and direction(a,b) are pointing in the same direction, hence you need to flip the displacement vector.

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

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want use html5's new tag to play a wav file (currently only supported
I want to count how many characters a certain string has in PHP, but
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
In order to apply a triggered animation to all ToolTip s in my app,
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

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.