dimforge / rapier

2D and 3D physics engines focused on performance.
https://rapier.rs
Apache License 2.0
3.97k stars 248 forks source link

What should I study to contribute? #231

Closed til-school closed 1 year ago

til-school commented 3 years ago

Hi @sebcrozet, can I please get some advice on what subjects should I study to understand your amazing projects so I can contribute? I'm in school and I've been programming for almost a year now in Rust and I do great in my Math and Physics classes. I love physics simulations and programming in Rust. Every time I run Rapier's examples3d folder it's total jaw dropping pure awesomeness.

My study list

If I study the above will I have the right knowledge to understand your projects? Is there anything missing from my list above? I know it will take a long time for me to learn all the above so I've given myself until the end of next year.

Super looking forward to your response.

Tilly

sebcrozet commented 3 years ago

Hey @til-school! Glad to see that you picked up an interested in physics simulation. I don’t know what is the best way for you to learn things, but I would suggest to select a concrete thing you would want to contribute, and then learn on-the-go as you try to implement this thing, and repeat. What topic interests you the most right now? Linear algebra, collision detection, dynamics?

Keep in mind that parry and rapier contain a fair amount of code that won’t be described in any books or papers. So don’t expect to find everything out there. At some point, you will need to practice a lot to get the necessary hindsight to be able to "improvise" and design your own solutions. That’s why I believe starting by giving you a concrete contribution objective should help get your hands dirty soon enough, instead of getting drowned into a sea of theory.

Linear algebra - For learning nalgebra. We are not taught linear-algebra in school but I've started this on my own. I'm going through khan-academy's linear-algebra course. I've also started learning nalgebra's matrix.rs implementation.

Sounds good. Collision-detection and physics only use a subset of what nalgebra is able to do. So if linear algebra isn’t your main objective, keep in mind that the most import things for you to understand are unit-quaternions (and rotations in general), isometries (aka. rigid-body transformations), 2D and 3D vectors and matrices. Learning about how, e.g., matrix multiplication is implemented in nalgebra itself isn’t very useful (as long as you know how the textbook matrix multiplication work). The same applies to matrix decomposition: don’t bother learning the implementation details (which is a very complicated topic by itself), and focus more on how to use them, how to interpret their results. Being aware of what BLAS operations are (but not necessarily how they are implemented) is useful as well.

Computational geometry - For learning parry's convex_hull3.rs and voronoi_simplex3.rs implementation. I'm learning these algorithms slowly. So far I know how to implement convex hull in 2D.

Computational geometry is used by collision-detection, so by focusing on collision-detection you will find resources about these things. The voronoi_simplex3.rs isn’t very useful by itself: it exists only to serve the implementation of the GJK algorithm (which is descsribed in the Real-Collision Detection book).

Collision detection - For learning parry's query folder I've started going through the book Real-Time Collision Detection. Right now I'm on that chapter about Bounding Volumes. I'm also going through parry's bounding_volume folder.

This book is a great place to start!

Differential geometry - For learning parry's contact_manifolds. Reading online it seems manifolds are taught in differential geometry and/or discrete differential geometry. I might be wrong. Is differential geometry needed?

Knowing a bit of differential geometry is useful but not necessary. The word manifold in what is called "contact manifold" in parry isn’t really related to manifolds in differential geometry. The ContactManifold really just is a set of points lying on the same plane, which can be seen as some kind of surfaces.

Differential geometry will be useful if you start implementing, e.g., collision-detection on smooth surfaces. But parry doesn’t have any of this, yet.

Physics & Geometry - For learning rapier's code. I love this. We are learning about energy and thermodynamics.

Well, Rapier’s code is a mixture of many things. So you probably need to understand the overall structure of a physics engine before focusing on individual parts. Any book about game physics engine development should give you the overall picture (because all game physics engine are organized roughly the same way with the broad-phase, narrow-phase, island computation, constraints initialization/resolution, integration).

Calculus - I find this the hardest. Is Calculus used a lot?

I would say that calculus is mostly needed in dynamics. This is what you use to obtain the equations you implement using linear-algebra. You will need some calculus to understand the derivation of the equation of motions.

til-school commented 3 years ago

This is priceless advice! Thank you so much!!!!!

What topic interests you the most right now? Linear algebra, collision detection, dynamics?

Linear algebra and collision detection a lot of fun. I can read about it for hours. My calculus lessons puts me to sleep, but I will try to learn it eventually because like you said it's needed in dynamics.

Keep in mind that parry and rapier contain a fair amount of code that won’t be described in any books or papers. So don’t expect to find everything out there. At some point, you will need to practice a lot to get the necessary hindsight to be able to "improvise" and design your own solutions.

Got it! It would be great to know how you got started into physics simulations and your journey into mastering it. I might be asking for too much here but that would be a very inspiring read.

Sounds good. Collision-detection and physics only use a subset of what nalgebra is able to do. So if linear algebra isn’t your main objective, keep in mind that the most import things for you to understand are unit-quaternions (and rotations in general), isometries (aka. rigid-body transformations), 2D and 3D vectors and matrices. Learning about how, e.g., matrix multiplication is implemented in nalgebra itself isn’t very useful (as long as you know how the textbook matrix multiplication work). The same applies to matrix decomposition: don’t bother learning the implementation details (which is a very complicated topic by itself), and focus more on how to use them, how to interpret their results. Being aware of what BLAS operations are (but not necessarily how they are implemented) is useful as well.

Cool. I will learn how to use them without dwelling too much into implementation detail.

Knowing a bit of differential geometry is useful but not necessary. The word manifold in what is called "contact manifold" in parry isn’t really related to manifolds in differential geometry. The ContactManifold really just is a set of points lying on the same plane, which can be seen as some kind of surfaces.

That's a relief! My study bucket list was growing so it's nice to cross one off for now.

Well, Rapier’s code is a mixture of many things. So you probably need to understand the overall structure of a physics engine before focusing on individual parts. Any book about game physics engine development should give you the overall picture (because all game physics engine are organized roughly the same way with the broad-phase, narrow-phase, island computation, constraints initialization/resolution, integration).

Done! I will get this book - Game Physics Engine Development.

That’s why I believe starting by giving you a concrete contribution objective should help get your hands dirty soon enough, instead of getting drowned into a sea of theory.

That would be amazing! Think I should wait a little longer to ask for a contribution objective till I build up confidence coding open-source. I'm also getting a Rust tutor soon.