PokerChipRace physics explanations


#66

Thank you, I’ll have a look at http://files.magusgeek.com/csb/csb_en.html.


#67

It is a great place to start. Although beware, I remember that I had to correct a few tiny math bugs when I used it. Make sure to do lots of testing.


#68

If you can read C++, you can also take a look at my fantastic bits code: https://github.com/dreignier/fantastic-bits/blob/master/fantastic-bits.cpp


#69

Hi everybody,

This multi challenge is very interesting, and for those who want to code a first simulation, the physic engine is not very hard to implement. Here are informations I used.

  • For a chip C0 : position (x0, y0), speed (vx0, vy0), radius (r0), mass = m0 = surface / PI = r0 * r0
  • For a chip C1 : position (x1, y1), speed (vx1, vy1), radius (r1), mass = m1 = surface / PI ) r1 * r1
  • distance C0 <> C1 : d = sqrt((x0 - x1)^2 + (y0 - y1)^2))
  • distance border to border C0 <> C1 : dBorder = d - r0 - r1
  • speed c0 : sp0 = sqrt(vx0^2 + vy0^2)
  • when a chip c0 expels a droplet c1, we have to calculate :
  • C1 mass is 1/15 of C0 mass : r1 = r0 * sqrt(1 / 15) (or constant SQR_15 = 3.8729833462)
  • C0 mass decreased to 14/15 of its mass, so the new reduced radius is r0 = r0 * sqrt(14/15) (or constant SQR_14_15 = 0.9660917830)
  • C1 starting position : C1 center is at (r0 - r1) distance from c0 center position in the opposite direction compared to the targeted position (action target). Beware r0 here is the reduced r0, and r1 is the new droplet calculated radius (mass conservation)
  • C1 speed : 200 to the opposite direction to the target position
  • C0 speed : actual (C0 speed) + 1/14 * (speed 200 to target position)

(to continue when I have some time)