Programming Balls #1 Circle Vs Circle Collisions C++

javidx9 · 150K views · 2018 · 32:29

Open on YouTube

Game programming & enginesAlgorithms & data structuresC, C++, Rust, Go & systems languagestutorial

Why Stack Overflow recommends it

Stack Overflow users link it when answering questions about elastic collisions and sphere or circle collision resolution, since it walks through the math and working code.

Recommended by 2 people across 2 different months, 2018 to 2021.

What it is

javidx9 (OneLoneCoder) starts a series on collision detection and resolution by implementing circle-versus-circle collisions in C++ in a console game engine. He walks through overlap detection, static resolution, and a plausible elastic response, with full source on GitHub.

What people said

Recommends Lapo · 2018-04 · Stack Overflow · on “Moving circles elastic collision”

The solution I found is to consider normal and tangential components of my 2 circles velocities, and not their X and Y components. This way I can apply law of conservation of momentum related to tangent and normal, and at the same time it considers the geometry of circles too. The last part of this tutorial is very helpful, even if I used a different algorithm, with some different logics: [this video]

Recommends Daniel · 2021-07 · Stack Overflow · on “Sphere to Sphere Collision Detection”

Do you search a formula / the math behind it? On the fly, I could find this, but it's in German. When we talk about collision detection, we probably don't need the case "Sphere #1 lies within sphere #2" ;-) [LINK] and this is in English [this video] However, if your question is how to program a sphere at all, then I could provide Code in VB.NET....

Cites Stdugnd4ikbd · 2020-07 · Stack Overflow · on “3D sphere vs sphere collision resolve problem”

I have been watching OneLoneCoder video about circle collision resolve [this video] and use the code from git [LINK] . But the code is for 2D case, i.e. circles, and I need a solution for spheres. So I tried to add Z-component to equations but getting failures. So I am testing the next way: I create two spheres, one above other. Lower is situated a heavy sphere, upper a tiny. The higher sphere is falling. In reality tiny should bounce up, but it just stuck, and they are falling as a single body for a while, but then the higher sphere is bouncing up. Also the sphere per each jump gets higher(see gif): [LINK] Here is the code: /* vertex - VERTEX **vertex=new VERTEX*[100]; vc - vertex count (how man