Bachelor Project (thesis) @USI. Extension of https://github.com/carzaniga/flying-balls. A simple 2D simulation/game of flying balls and polygons
Go to file
2023-08-02 19:09:32 +02:00
.gitignore Added entry to gitignore 2023-05-18 11:19:58 +02:00
after.mp4 Added before vs after to readme 2023-08-02 17:55:43 +02:00
balls.cc GUI controls for restitution coefficient and gravity field 2022-12-28 18:50:12 +01:00
balls.h GUI controls for restitution coefficient and gravity field 2022-12-28 18:50:12 +01:00
before.mp4 Added before vs after to readme 2023-08-02 17:55:43 +02:00
c_index.cc 2D vector objects for positions, velocities, etc. 2022-06-01 11:09:35 +02:00
c_index.h basic modularization of ball and ball_face classes 2022-05-30 18:05:53 +02:00
collisions.cc Reformated collisions.cc 2023-05-19 16:29:05 +02:00
collisions.h Now when polygons collide, they get moved by the overlap to ensure that 2023-05-19 15:24:11 +02:00
color.cc Added random color generation to the polygons, also made so that the 2023-06-13 13:50:07 +02:00
color.h Added random color generation to the polygons, also made so that the 2023-06-13 13:50:07 +02:00
game.cc first, basic transition to C++ 2022-05-30 15:59:45 +02:00
game.h trying to make the video in the readme work :) 2023-08-02 18:05:30 +02:00
gravity.cc Added the gravity vector method for polygons (kinda blindly copied and 2023-05-17 13:27:11 +02:00
gravity.h Added gravity vector for polygons in gravity.h 2023-05-17 13:30:05 +02:00
main.cc Added random color generation to the polygons, also made so that the 2023-06-13 13:50:07 +02:00
Makefile Added random color generation to the polygons, also made so that the 2023-06-13 13:50:07 +02:00
matrix.h Generator now makes the polygons origin at their center of mass, easier for rotation 2023-03-20 15:33:35 +01:00
polygon_generator.cc Removed the passing of the mass through parameters. Now the mass is 2023-05-19 16:31:38 +02:00
polygon_generator.h Removed the passing of the mass through parameters. Now the mass is 2023-05-19 16:31:38 +02:00
polygons.cc trying to make the video in the readme work :) 2023-08-02 18:05:30 +02:00
polygons.h Added random color generation to the polygons, also made so that the 2023-06-13 13:50:07 +02:00
README.md finally got videos to work!! 2023-08-02 19:03:40 +02:00
spaceship.cc Reformated main.cc and spaceship.cc 2023-03-14 21:45:20 +01:00
spaceship.h basic modularization of ball and ball_face classes 2022-05-30 18:05:53 +02:00
stats.cc first, basic transition to C++ 2022-05-30 15:59:45 +02:00
stats.h modularization: main, game, balls, c_index, spaceship, gravity 2021-12-11 21:32:48 +01:00
vec2d.h Added random color generation to the polygons, also made so that the 2023-06-13 13:50:07 +02:00

From Flying Balls to Colliding Polygons

Abstract

(text taken from the abstract of my report that you can find here

Physics engines are a fun and interesting way to learn about the laws of physics, as well as computer science. They provide a real-time simulation of common physical phenomena, and therefore illustrate theoretical concepts such as the equations that dictate the motion of objects.

The goal of this project was to extend an existing physics engine built for demonstration purposes. This engine was initially designed and developed to simulate circular objects ("balls") in 2D.

With this project, we intended to extend this engine to also simulate arbitrary polygons, again in a physically accurate way. The main technical challenges of the project is therefore the correct simulation of the dynamics of rigid, polygonal objects. In particular, we developed a model of polygonal rigid objects:

  • we implemented a simulation of their inertial motion, possibly in the presence of a constant force field such as gravity;
  • we detect collisions between objects;
  • we compute and then simulate the dynamic effects of collisions.

The simulations are animated and displayed in real-time. It is also therefore crucial that the simulation code be efficient to obtain smooth animations.

Before vs After

Context

A little of context for the follow videos:

  • in the first video, the special ball with an arrow inside is a "spaceship", that can be controlled by the user;
  • the yellow bar that appears after midway through both videos represent the restitution coefficient of the collision resolution (the lower it is, the greater the dampening on impact between objects);
  • the white line with a ball at the end that appears after the restitution coefficient bar represents the gravity vector that gets applied to the speed of each object at each frame, the ball is the direction the vector is pointing it.

Before

https://github.com/karma-riuk/flying-balls/assets/30158492/ddc0d608-9667-4a21-8132-e056e443e0e2

After

https://github.com/karma-riuk/flying-balls/assets/30158492/bd4013b8-bc01-4d52-aa2f-44dbc25de717

Contact

If you have any question concerning this work, feel free to contact me at arno.fauconnet@gmail.com