Page 1 of 1

[Q] Getting the point of contact between 2 OBB rectangles

Posted: Mon Jul 07, 2014 4:50 am
by Solution
Okay so, first off: Hi! I'm Jeroen, a 17 year old beginner programmer bla bla bla, you didn't really click this to hear my lifes story.


I'm working on and endproject for school, and me and a close friend are trying to create a physics engine, and give a demonstration of how it works.

I've run into the problem of getting the point of contact, and I tried watching some old video's on the ES youtube channel, but it more or less raped my brain and I still don't quite get it.

We currently have the following variables: A center point, the corner locations, the radius, and the axis axis. I really hope someone could help, and if we need any other variables I would love some explaination on how I'd be getting those.


Thanks in advance!
Jeroen/Solution




p.s. :worship: :bow: to you if you can help

Re: [Q] Getting the point of contact between 2 OBB rectangle

Posted: Mon Jul 07, 2014 7:20 pm
by X Abstract X
I actually wrote somewhat of a tutorial on the subject of building a 2D rigid body physics engine (it's not finalized). I've attached the section I wrote on finding contact points for polygon-polygon collisions, it should be of help. If you have any questions, I'll try to answer them.

Re: [Q] Getting the point of contact between 2 OBB rectangle

Posted: Tue Jul 08, 2014 4:34 pm
by Light-Dark
X Abstract X wrote:I actually wrote somewhat of a tutorial on the subject of building a 2D rigid body physics engine (it's not finalized). I've attached the section I wrote on finding contact points for polygon-polygon collisions, it should be of help. If you have any questions, I'll try to answer them.

If it's not too much trouble do you mind posting the entire tutorial?

Re: [Q] Getting the point of contact between 2 OBB rectangle

Posted: Tue Jul 08, 2014 9:18 pm
by X Abstract X
Light-Dark wrote:
X Abstract X wrote:I actually wrote somewhat of a tutorial on the subject of building a 2D rigid body physics engine (it's not finalized). I've attached the section I wrote on finding contact points for polygon-polygon collisions, it should be of help. If you have any questions, I'll try to answer them.

If it's not too much trouble do you mind posting the entire tutorial?
Unfortunately I never got around to filling in some of the gaps, so it's not really something you can pick up and read as a sole resource. As a matter of fact, it was written for school and sort of assumes the reader knows a bit about how a rigid body engine works. It accompanies the source code I wrote and explains some of the major concepts. If there's a particular topic you were interested in, I would be happy to post the relevant section (if it exists) though.

Re: [Q] Getting the point of contact between 2 OBB rectangle

Posted: Fri Jul 11, 2014 3:20 pm
by Falco Girgis
Yo, niggas. Unfortunately I'm swamped as shit trying to get ready for the Kickstarter, but I can give you some useful advice.

1) The point-of-contact algorithm uses the contact normal and penetration depths as inputs. Both of these are found through the separating axis theorem when doing OBB vs OBB collision. Consider PoC calculation an extension of the core SAT algorithm.
2) You then consider how many vertices are involved in the contact. For one, obviously that one vertex is the PoC. For multiple, you have an edge vs edge contact. Average the two edges for the PoC.

It's kind of a pain in the ass to do, so don't be discouraged that you're having problems. There is very little literature on the subject, and the literature that there is out there is written in the form of mathematical proofs rather than ready-to-implement code.