What do I need to know to make a simple physics engine?

Started by
16 comments, last by Cornstalks 12 years, 1 month ago
To be honest, your question is really vague. There isn't really one answer. You know you need to know vector and matrix math and geometric principles. Everything else pretty much expands on those things. The theorems for collision detection and resolution, the algorithms for broad-phase and narrow-phase collision detection, etc. just build on these basic concepts and ideas, and then use clever understandings of the math and the problem to accomplish the desired goal. There really isn't one answer about knowing how to detect collisions between various types. It's an open field of active research, and there are many correct answers.

Some of the theorems and ideas popularly used to accomplish the things you're desiring are the Separating Axis Theorem, GJK collision detection, Voronoi regions, Minkowski addition, broad-phase collision detection (with things like BSPs, spatial hashing, etc.), etc. These things are just a small sample of things used in various physics engines, and I wouldn't be surprised if you are already aware of this. If you want to know how to detect and handle a collision, I suggest you look up another physics engine, see the algorithm they use, and then research that algorithm. Being able to look at a problem and decompose it into a mathematical formula is also important. Simply googling the type of objects that can collide is also important, and you'll find various answers for various shapes. And I don't think there's one answer that'll solve every problem. Usually, you have to use multiple answers to solve all the problems, as well as decomposing your problems into other problems which can be solved by your chosen method (like with collision detection and concave shapes using SAT or GJK). And then there's the cases you have to deal with where you really can't accurately solve the problem and just have to hack it with an estimation.

If you have a more specific question about one of these aspects, then it's a much easier question to answer. But there isn't really an answer to asking what you need to know in order to write a physics engine, because there's a million ways to do it, each way having it's own million things to know.

But really, I'd suggest using the Separating Axis Theorem. This site is gold for a starting point. Whether you use SAT, GJK, etc. is up to you. With each of these algorithms, there are things you need to know. But first you need to decide on an algorithm before I think anyone can really say what you'll need to know, specifically.
[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]
Advertisement
To be honest, your question is really vague. There isn't really one answer. You know you need to know vector and matrix math and geometric principles. Everything else pretty much expands on those things. The theorems for collision detection and resolution, the algorithms for broad-phase and narrow-phase collision detection, etc. just build on these basic concepts and ideas, and then use clever understandings of the math and the problem to accomplish the desired goal. There really isn't one answer about knowing how to detect collisions between various types. It's an open field of active research, and there are many correct answers. Some of the theorems and ideas popularly used to accomplish the things you're desiring are the Separating Axis Theorem, GJK collision detection, Voronoi regions, Minkowski addition, broad-phase collision detection (with things like BSPs, spatial hashing, etc.), etc. These things are just a small sample of things used in various physics engines, and I wouldn't be surprised if you are already aware of this. If you want to know how to detect and handle a collision, I suggest you look up another physics engine, see the algorithm they use, and then research that algorithm. Being able to look at a problem and decompose it into a mathematical formula is also important. Simply googling the type of objects that can collide is also important, and you'll find various answers for various shapes. And I don't think there's one answer that'll solve every problem. Usually, you have to use multiple answers to solve all the problems, as well as decomposing your problems into other problems which can be solved by your chosen method (like with collision detection and concave shapes using SAT or GJK). And then there's the cases you have to deal with where you really can't accurately solve the problem and just have to hack it with an estimation. If you have a more specific question about one of these aspects, then it's a much easier question to answer. But there isn't really an answer to asking what you need to know in order to write a physics engine, because there's a million ways to do it, each way having it's own million things to know. But really, I'd suggest using the Separating Axis Theorem. This site is gold for a starting point. Whether you use SAT, GJK, etc. is up to you. With each of these algorithms, there are things you need to know. But first you need to decide on an algorithm before I think anyone can really say what you'll need to know, specifically.


Sorry about being vague, I'm just unsure of how to ask the question properly. I've looked at the tutorials on metanetsoftware.com, but I'm just not sure how to use the information on there. From what I've seen, they don't really provide much more information beyond diagrams and descriptions. I feel like I already know everything I need, but I just need a "refresher" so to speak.

I guess to get a better answer, what is likely to be the best book to find information about vector math used in games?

To be honest, your question is really vague. There isn't really one answer. You know you need to know vector and matrix math and geometric principles. Everything else pretty much expands on those things. The theorems for collision detection and resolution, the algorithms for broad-phase and narrow-phase collision detection, etc. just build on these basic concepts and ideas, and then use clever understandings of the math and the problem to accomplish the desired goal. There really isn't one answer about knowing how to detect collisions between various types. It's an open field of active research, and there are many correct answers.

Some of the theorems and ideas popularly used to accomplish the things you're desiring are the Separating Axis Theorem, GJK collision detection, Voronoi regions, Minkowski addition, broad-phase collision detection (with things like BSPs, spatial hashing, etc.), etc. These things are just a small sample of things used in various physics engines, and I wouldn't be surprised if you are already aware of this. If you want to know how to detect and handle a collision, I suggest you look up another physics engine, see the algorithm they use, and then research that algorithm. Being able to look at a problem and decompose it into a mathematical formula is also important. Simply googling the type of objects that can collide is also important, and you'll find various answers for various shapes. And I don't think there's one answer that'll solve every problem. Usually, you have to use multiple answers to solve all the problems, as well as decomposing your problems into other problems which can be solved by your chosen method (like with collision detection and concave shapes using SAT or GJK). And then there's the cases you have to deal with where you really can't accurately solve the problem and just have to hack it with an estimation.

If you have a more specific question about one of these aspects, then it's a much easier question to answer. But there isn't really an answer to asking what you need to know in order to write a physics engine, because there's a million ways to do it, each way having it's own million things to know.

But really, I'd suggest using the Separating Axis Theorem. This site is gold for a starting point. Whether you use SAT, GJK, etc. is up to you. With each of these algorithms, there are things you need to know. But first you need to decide on an algorithm before I think anyone can really say what you'll need to know, specifically.


That may not have been what the OP needed but that was an excellent intro to collision detection. Thank you for your post.

To the OP: The basis of all basic math used in describing 3D environments is Linear Algebra. Going through a course in it or reading any good textbook would get you what you need. If you have that background (or a solid physics background) a discreet mathematics textbook would be a possible next step then maybe numerical analysis (although neither is related to collision detection directly...). Most of your introductory game programming/physics modeling books also have all the relevant info.
I'm not asking what I need to know to make a physics engine


That may certainly prove to be confusing considering that is the very exact title of your thread.

I, much like the others, can't quite make out what you're asking for. If you want to code the algorithms yourself instead of looking them up, then go read up on basic physics concepts, crank up your math skills, grab a pen and paper and off you go. You should have enough knowledge about the physical relationships between various physical quantities and enough tricks in your math bag that you should be able to not only handle collision detection but collision response. If you do not, then you can find both physics and math tutorials in my signature. That is about as bare as it gets to reinventing the algorithms, without having to reinvent classical physics altogether.

Yo dawg, don't even trip.


[quote name='Nyxenon' timestamp='1330292001' post='4916805']I'm not asking what I need to know to make a physics engine


That may certainly prove to be confusing considering that is the very exact title of your thread.

I, much like the others, can't quite make out what you're asking for. If you want to code the algorithms yourself instead of looking them up, then go read up on basic physics concepts, crank up your math skills, grab a pen and paper and off you go. You should have enough knowledge about the physical relationships between various physical quantities and enough tricks in your math bag that you should be able to not only handle collision detection but collision response. If you do not, then you can find both physics and math tutorials in my signature. That is about as bare as it gets to reinventing the algorithms, without having to reinvent classical physics altogether.
[/quote]

I apologize for being very confusing. I'm not asking how to make a physics engine, I'm just asking what kinds of concepts I should look into to be able to check collisions. After going off on my own research, I've decided that I know much of what I need to know.
Cross production to get the normal of a face (already knew this)
Dot product (also knew this previously)
Projection (knew of it, but never used it)
Normalization (knew it and used it)

The kind of information I was really hoping to hear about were things like Separating Axis Theorem. Which I've looked into and managed to write my own algorithm to check collision between two convex polygons. Voronoi regions were another thing that I found that I might want to look into.

I wasn't looking for info for how to do complex collision responses (like rotation), I just needed to push the bodies apart.

What I mean by wanting to know the basics, and how to use them is something like how you can use dot production to project vertices onto an axis to check for gaps with SAT. (I figured this out myself after reading up about it).

Everything I've found on the net was really vague about how to do things, and they left parts out, and the equations were hard to understand at times.

I haven't learned anything from this post that I didn't already know about, but that is my own fault for being unable to express what kind of info I'm looking for. I apologize for wasting everyone's time. I'm just going to try to figure out what I need to know myself.

Thanks for at least trying.
I also have a question,

does box2d use runge kutta 4 integration?

I also have a question,

does box2d use runge kutta 4 integration?


I've never heard of using Runge Kutta for straight integration but my experience is from Numerical Analysis so I could just be an idiot.

does box2d use runge kutta 4 integration?

Found by googling "box2d runge kutta". First result.
[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

This topic is closed to new replies.

Advertisement