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. to you if you can help
[Q] Getting the point of contact between 2 OBB rectangles
Moderator: Coders of Rage
-
- Chaos Rift Regular
- Posts: 173
- Joined: Thu Feb 11, 2010 9:46 pm
Re: [Q] Getting the point of contact between 2 OBB rectangle
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.
- Light-Dark
- Dreamcast Developer
- Posts: 307
- Joined: Sun Mar 13, 2011 7:57 pm
- Current Project: 2D RPG & NES Platformer
- Favorite Gaming Platforms: NES,SNES,N64,Genesis,Dreamcast,PC,Xbox360
- Programming Language of Choice: C/++
- Location: Canada
Re: [Q] Getting the point of contact between 2 OBB rectangle
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
-
- Chaos Rift Regular
- Posts: 173
- Joined: Thu Feb 11, 2010 9:46 pm
Re: [Q] Getting the point of contact between 2 OBB rectangle
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.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?
- Falco Girgis
- Elysian Shadows Team
- Posts: 10294
- Joined: Thu May 20, 2004 2:04 pm
- Current Project: Elysian Shadows
- Favorite Gaming Platforms: Dreamcast, SNES, NES
- Programming Language of Choice: C/++
- Location: Studio Vorbis, AL
- Contact:
Re: [Q] Getting the point of contact between 2 OBB rectangle
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.
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.