Skip to content

MohamedAhmed7/Gravity-Simulation-OpenGL

 
 

Repository files navigation

Gravity-Simulation-OpenGL

Assignment 2 for computer graphics class work

this is a simulation of gravity between particles according to their masses as newton's law of universal gravitation img

initially a big particle is created at the origin with infinity mass that will attrackt any new particle creatd by left clicking on the mouse by the user as the new particle is smaller than the big mass so the gravitation force accelerate the small particles towards the origin (Big mass)

  • change in velocity on x and y axis

- p.vx += 0.0003 * p1.m / (d*d) * (p1.x - p.x) / d

- p.vy += 0.0003 * p1.m / (d*d) * (p1.y - p.y) / d;

events:
left click --> add samll particle at the mouse position
right click ---> add big particle at the mouse position
scroll click --> remove all the particles from the screen

Sample View

sample

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 78.4%
  • C 21.6%