Problem I. 223. (November 2009)
I. 223. Prepare a simulation to display the motion of coloured bubbles in the plane. Each bubble is represented by a disk of one-colour, bouncing on an 800×600 image and transforming into one another. Position and velocity of a bubble are given by real coordinate pairs, its radius is a real number, while its colour is a triplet of byte-sized integers in RGB encoding. Each bubble has also a certain mass, equal to the square of its radius, that is, proportional to its area. Bubbles move on the screen in every simulation step according to their velocity. If they leave the simulation area, they reappear on the opposite side with the same velocity, thus moving toward the interior part of the image. When two bubbles hit each other, they merge into one new bubble with
i) mass equal to the sum of the original masses, that is r12+r22;
ii) centre equal to the weighted mean of the centres of the original bubbles:
iii) coordinates of velocity given by the law of conservation of momentum
iv) R, G and B components of its colour again equal to the weighted mean of the original components (the weights being the masses).
If this newly created bubble touches a third one, yet another fusion takes place, governed by the same rules.
The first command line argument to your program is the name of a text file to be read. Each line of this file contains initial data for every bubble, separated by a space in the following format: position_x position_y velocity_x velocity_y radius red green blue.
In the example, ``be01.txt'' is the sample input, ``Részlet a szimulációs térből kezdetben'' is ``part of the simulation area in the beginning'', while ``és 10 szimulációs lépés után'' is ``after 10 simulation steps''.
The source code and project files of your solution -- without the i223.exe or any other auxiliary files generated by the compiler -- should be submitted in a compressed folder i223.zip.
Deadline expired on 10 December 2009.
Sorry, the solution is available only in Hungarian. Google translation
A programokat az alábbi tesztállományokkal vizsgáltuk: teszt.zip.
Mintamegoldásként Szabó Attila pécsi, 9. osztályos tanuló Free Pascalban készült (i223.pas) és Balla Attila budapesti, 12. osztályos diák Delphiben készült (i223.zip) munkáját adjuk közre.