Understanding 2D Gravity Simulation in C++ Code
Explore the concept of simulating gravity in a 2D environment using C++ code. Discover how large objects attract small objects and the mathematical equations involved in calculating gravitational effects. Dive into the important segments of C code and kernel functions to grasp the intricacies of gravity simulation.
Download Presentation
Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
E N D
Presentation Transcript
Gravity simulation Denis Bav ar
Gravity in 2D 2 large objects which attract other objects N small objects with mass low enough that their influence on other objects can be ignored. Equation in original c++ code: p.vx += 0.03 * p1.m / (d*d) * (p1.x - p.x)/d; 0.03 = a constant that replaces G (gravitational constant) in the program p1.m = mass of the other object d = distance between two objects (p1.x p.x)/d = turns 2D acceleration into horizontal acceleration