Jump to content

  • Log In with Google      Sign In   
  • Create Account

Colision 2D - getting push vector


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 furrymaster   Members   -  Reputation: 100

Like
0Likes
Like

Posted 18 February 2012 - 03:20 AM

Hi, at the moment i'm creating simple physic in my engine and i have problem with 1 thing: when i have colision rect<< >>rect(s) how can I calculate vector which say "if you dont want to colide move for [x,y]". That what I have is: moving rectangle, coliding with it rectangles, move vector of my rectangle and intersect rectangle of each rect-rect colision.
Main problematic colisions are:
Posted Image
As you can see i cannot sum all push vectors because my moving rectangle will be pushed too far away.
So that i'm getting 2 vectors from them which: has "best pushing" for x and for y value but counter to rect move vector.
But it doesnt works well too( I can find an example where it doesnt work ). Do you have any idea what should it do? Maybe i'm going bad way to get "push vector"? Any articles about getting this vector would be nice too.
If I helped you rate me

Sponsor:

#2 wildbunny   Members   -  Reputation: 550

Like
1Likes
Like

Posted 18 February 2012 - 05:08 AM

Hi there,

Your push directions are incorrect - the for rect vs rect the push directions are always either in the x or y axis only.

This article I wrote should give you some ideas, although not the complete answer: http://www.wildbunny.co.uk/blog/2011/04/20/collision-detection-for-dummies/

If you shrink one box A down to a point, and then increase the dimensions of the other box B by those of box A, the push vector can be found as the shortest distance from the point (box A) to the edges of box B.

Hope that helps!

Cheers, Paul.

#3 furrymaster   Members   -  Reputation: 100

Like
0Likes
Like

Posted 18 February 2012 - 11:53 AM

thank you for useful advice.
Luckly I found solutinon by myself few hours ago but i think this material probably will help me soon:)
If I helped you rate me

#4 h4tt3n   Members   -  Reputation: 1285

Like
0Likes
Like

Posted 18 February 2012 - 03:09 PM

The algoritm you are looking for is the Separating Axis Theorem (SAT) and its use of the Minimum Translation Vector (MTV).

A few links:

http://www.geometrictools.com/Documentation/MethodOfSeparatingAxes.pdf
http://www.geometrictools.com/Documentation/MethodOfSeparatingAxes.pdf
http://www.metanetsoftware.com/technique/tutorialA.html
http://content.gpwiki.org/index.php/VB:Tutorials:Building_A_Physics_Engine:Basic_Intersection_Detection
http://www.sevenson.com.au/actionscript/sat/
http://www.codeproject.com/Articles/15573/2D-Polygon-Collision-Detection

Cheers,
Mike




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS