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

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

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

Postby Solution on Mon Jul 07, 2014 5:50 am

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
Solution
Chaos Rift Newbie
Chaos Rift Newbie
 
Posts: 1
Joined: Mon Jul 07, 2014 4:57 am

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

Postby X Abstract X on Mon Jul 07, 2014 8:20 pm

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.
Attachments
Contact.pdf
(53.61 KiB) Downloaded 189 times
X Abstract X
Chaos Rift Regular
Chaos Rift Regular
 
Posts: 178
Joined: Thu Feb 11, 2010 11:46 pm
Location: Ottawa, Canada

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

Postby Light-Dark on Tue Jul 08, 2014 5:34 pm

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?
<tpw_rules> LightDark: java is a consequence of inverse moore's law: every 18 months, the average program will be twice as slow. therefore, computers always run at the same percevied speed. java's invention was a monumental step

Image
User avatar
Light-Dark
Dreamcast Developer
Dreamcast Developer
 
Posts: 315
Joined: Sun Mar 13, 2011 8:57 pm
Location: Canada

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

Postby X Abstract X on Tue Jul 08, 2014 10:18 pm

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.
X Abstract X
Chaos Rift Regular
Chaos Rift Regular
 
Posts: 178
Joined: Thu Feb 11, 2010 11:46 pm
Location: Ottawa, Canada

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

Postby Falco Girgis on Fri Jul 11, 2014 4:20 pm

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.
"So what happens if the Elysian Shadows Kickstarter fails?"
Image
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
 
Posts: 10693
Joined: Thu May 20, 2004 3:04 pm
Location: Studio Vorbis, AL


Return to Programming Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron