Develop the physics of free fall of an object in c++

I need to write a program that will simulate the situation:


A certain object that has its own physical properties. properties (mass, material, size, color, etc.) will fall from a given height N. The program should be based on the physical laws (in the simplest version, without sophistication) and the physical properties of the object return values:

  1. t is the time it takes for this object to fall to the ground.
  2. V - speed of the beginning, speed. final, average speed.
  3. acceleration of gravity

You also need to: simulate the elastic force (that is, how much it will bounce after landing).

All this needs to be done graphically, using c++.
What are the best tools to use?
SFML, OpenGL, or something more suitable for this purpose?
And is there any literature on the subject.
Thanks.

Author: BERTOLDO, 2020-03-07

1 answers

From my knowledge stack, this is the easiest thing to do in Unity3d, if sharpe is allowed. The initial speed will be 0 while in the update it needs to set the acceleration This will give the average speed, the speed at any time, and the acceleration data To show the elasticity, you need to register the reverse acceleration when touching the object, this can be done in the ball class, where you can also substitute different elasticity constants and use them to display different materials using the buttons. B +sax this can also be done by the application, but here you will have to tinker more, although the mechanics are still the same - create a class of the ball and the surface, set the vector of the ball's movement and the method that will generate it in space, you can take just the lower border of the screen for the floor, in general, this can be done without third-party libraries. As a result, we have in any of the options

  • Ball class with all the lotions ( acceleration, required public field-speed, elasticity)
  • Space class (it specifies the lower boundary, its interaction with the ball, as well as the method that will be responsible for the height ratio and the display of the ruler on the screen, counting the time in flight (from 0 to an obstacle or stop), and finally the method that will generate this ball at the desired height)
  • Well, the user interface (Choice of material (elastic constants), height, optional ball color, and start buttons. Next, the fields that show the speed, time and acceleration for this session, and the little things you want. ) That's all-good luck

P.S.-about the moment of the ball falling You need to set it a constant acceleration (according to the formula depending on the mass and material) along the vector down in the update, which will be triggered say every 0.1 or 0.01 seconds, and when touching, multiply speed by -1(x), where x it will be responsible for how much speed it will have left after the fall, so it will jump up, lose speed and fall down until the speed is enough to climb.

 -1
Author: Antares, 2020-03-07 14:16:04