{"id":13661308,"url":"https://github.com/Habrador/Ten-Minute-Physics-Unity","last_synced_at":"2025-04-25T02:32:20.460Z","repository":{"id":44469867,"uuid":"494337984","full_name":"Habrador/Ten-Minute-Physics-Unity","owner":"Habrador","description":"Implementations in Unity of the Ten Minute Physics YouTube channel. Instead of using Unity's built-in physics engine, you will learn how to make your own. This is useful if you want to simulate ropes, cloth, tires, etc. You will also learn how to make fluid simulations and soft body physics.","archived":false,"fork":false,"pushed_at":"2025-03-20T16:08:35.000Z","size":4126,"stargazers_count":284,"open_issues_count":2,"forks_count":31,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-04-13T04:05:04.526Z","etag":null,"topics":["cloth-simulation","computer-science","csharp","double-pendulum","eulerian-fluid-simulation","fluid-simulation","n-body","pendulum","physics","physics-simulation","rigidbody","simulation","soft-body","soft-body-simulation","softbody-simulation","spatial-partitioning","triple-pendulum","unity","unity3d","xpbd"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Habrador.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-05-20T05:52:24.000Z","updated_at":"2025-04-11T09:56:18.000Z","dependencies_parsed_at":"2023-09-29T11:44:25.939Z","dependency_job_id":"48a239de-97dd-4165-9115-df2b49cc5159","html_url":"https://github.com/Habrador/Ten-Minute-Physics-Unity","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Habrador%2FTen-Minute-Physics-Unity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Habrador%2FTen-Minute-Physics-Unity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Habrador%2FTen-Minute-Physics-Unity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Habrador%2FTen-Minute-Physics-Unity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Habrador","download_url":"https://codeload.github.com/Habrador/Ten-Minute-Physics-Unity/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250742013,"owners_count":21479716,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloth-simulation","computer-science","csharp","double-pendulum","eulerian-fluid-simulation","fluid-simulation","n-body","pendulum","physics","physics-simulation","rigidbody","simulation","soft-body","soft-body-simulation","softbody-simulation","spatial-partitioning","triple-pendulum","unity","unity3d","xpbd"],"created_at":"2024-08-02T05:01:32.316Z","updated_at":"2025-04-25T02:32:20.451Z","avatar_url":"https://github.com/Habrador.png","language":"C#","funding_links":[],"categories":["Physics","C\\#","C# #"],"sub_categories":[],"readme":"# Ten Minute Physics in Unity\n\nImplementations in Unity of the YouTube channel [Ten Minute Physics](https://matthias-research.github.io/pages/tenMinutePhysics/). My contribution is that I have translated the code from mainly JavaScript to C#, and I have commented the code to make it easier to understand what's going on. I have also fixed a few minor bugs and improved the performance.  \n\n\n## 1-2. Cannon ball\n\nSimulate a bouncy cannon ball.\n\n\u003cimg src=\"/_media/01-bouncy-ball.png\" width=\"400\"\u003e\n\n## 3. Billiard\n\nSimulate billiard balls with different size and mass. Watch this YouTube video for examples: \n\n[![Link to youtube video 1000 billiard balls](https://img.youtube.com/vi/ErsK2osLkQU/0.jpg)](https://www.youtube.com/watch?v=ErsK2osLkQU)\n\n\n## 4. Pinball\n\nSimulate a pinball game.\n\n\u003cimg src=\"/_media/04-pinball.png\" width=\"400\"\u003e\n\n\n## 5. Beads on wire\n\nSimulate beads attached to a circular wire.\n\n\u003cimg src=\"/_media/05-beads-on-wire.png\" width=\"400\"\u003e\n\n\n## 6. Pendulums\n\nSimulate the chaotic behavior of pendulums with as many arms as you want and where each arm can have different mass. With many arms you get a rope or hair! Watch these YouTube videos for examples: \n\n[![Link to youtube video butterfly effect](https://img.youtube.com/vi/GqGHz6gtakY/0.jpg)](https://www.youtube.com/watch?v=GqGHz6gtakY)\n\n[![Link to youtube video double pendulum](https://img.youtube.com/vi/jMDiP7mhEx0/0.jpg)](https://www.youtube.com/watch?v=jMDiP7mhEx0)\n\n\n## 7. 3d Vector Math for Simulation\n\nNothing to simulate\n\n\n## 8. Interaction\n\nCatch and throw a ball with your mouse.\n\n\u003cimg src=\"/_media/08-user-interaction.png\" width=\"400\"\u003e\n\n\n## 9. Getting ready to simulate the world with XPBD\n\nNothing to simulate\n\n\n## 10. Soft body physics\n\nSimple unbreakable soft body bunny physics. You can flatten it and throw it around with your mouse. \n\n\u003cimg src=\"/_media/10-soft-body.gif\" width=\"400\"\u003e\n\n\n## 11. Find overlaps among objects\n\nFind overlaps among thousands of objects blazing fast. Implements a version of the [Spatial Partitioning design pattern](https://github.com/Habrador/Unity-Programming-Patterns) called \"Spatial Hashing\" which is really useful if you have an unbounded grid. \n\n\u003cimg src=\"/_media/11-spatial-hashing.png\" width=\"400\"\u003e\n\n\n## 12. Optimized soft body physics (TODO)\n\nIs not optimizing the code from #11, but is showing how you can use a more detailed mesh and make that faster. You use two meshes: one with fewer triangles that is tetrahedralized, and one with more triangles, and then they interract during the simulation.  \n\n\n## 13. Tetrahedralizer (TODO)\n\nImplemetation of an algorithm that splits a mesh into tetrahedrons. Will be available here when finished: [Open source Computational Geometry library](https://github.com/Habrador/Computational-geometry)\n\n\n## 14. Cloth simulation\n\nBasic cloth simulation.\n\n\u003cimg src=\"/_media/14-cloth-simulation.gif\" width=\"400\"\u003e\n\n\n## 15. Cloth self-collisions\n\nTODO\n\n\n## 16. Simulation on the GPU\n\nTODO\n\n\n## 17. Eulerian Fluid Simulator with 200 lines of code\n\nSpoiler: It's just the simulation part that's 200 lines of code. You need a few more lines of code to set it up, display it on screen, etc. Watch this YouTube video for examples: \n\n[![Link to youtube video fluid simulation](https://img.youtube.com/vi/6Jw1CsTOkDg/0.jpg)](https://www.youtube.com/watch?v=6Jw1CsTOkDg)\n\n\n## 18. FLIP Water Simulator\n\nTODO\n\n\n## 19. Differential equations and calculus from scratch\n\nNothing to simulate\n\n\t\n## 20. Height-field water simulation\n\nSimulate a swimming pool with balls. \n\n\u003cimg src=\"/_media/20-heightfield.gif\" width=\"400\"\u003e\n\n\n## 21. Fire simulator\n\nTODO\n\n\n## 22. Basic rigid body simulator\n\nSimulating rigid bodies using XPBD. \n\n\u003cimg src=\"/_media/22-basic-rb-simulator.png\" width=\"400\"\u003e\n\n\n## 23. Sweep and Prune collision detection\n\nA fast way to check collisions between many objects by checking each object's Axis-Aligned Bounding Box (AABB). Is related to \"11. Find overlaps among objects\" but can handle objects with different sizes.  \n\n\u003cimg src=\"/_media/23-sweep-and-prune.png\" width=\"400\"\u003e\n\n\n## 24. Bounding Volume Hierarchies\n\nTODO\n\n\n\n# Bonus\n\nBonus implementations related to the code above.\n\n\n## 3-Body Problem\n\nSimulation of planetary orbits based on this famous unsolved problem (https://en.wikipedia.org/wiki/Three-body_problem). Watch this YouTube video for examples: \n\n[![Link to youtube video 3-body problem](https://img.youtube.com/vi/o5HWPeP-JS4/0.jpg)](https://www.youtube.com/watch?v=o5HWPeP-JS4)\n\n\n## Calculate pi\n\nCalculate decimals in pi by bouncing boxes with different mass and calculate collisions. If the small box is 1 kg and the big box is 10000 kg, then the small box will collide with the big box and the wall to the left 314 times. Inspired by 3Blue1Bown's YouTube video: [The most unexpected answer to a counting puzzle](https://www.youtube.com/watch?v=HEfHFsfGXjs).\n\n\u003cimg src=\"/_media/bonus-calculate-pi.png\" width=\"400\"\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHabrador%2FTen-Minute-Physics-Unity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FHabrador%2FTen-Minute-Physics-Unity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHabrador%2FTen-Minute-Physics-Unity/lists"}