Example 1: figure-8 solution to the 3-body-problem This example can be seen as a test of the implementation: given the right initial conditions, the bodies should move in a figure-8. (initial conditions taken from http://www.artcompsci.org/vol_1/v1_web/node56.html) >>> body
()
| 251 | |
| 252 | |
| 253 | def example_1() -> BodySystem: |
| 254 | """ |
| 255 | Example 1: figure-8 solution to the 3-body-problem |
| 256 | This example can be seen as a test of the implementation: given the right |
| 257 | initial conditions, the bodies should move in a figure-8. |
| 258 | (initial conditions taken from http://www.artcompsci.org/vol_1/v1_web/node56.html) |
| 259 | >>> body_system = example_1() |
| 260 | >>> len(body_system) |
| 261 | 3 |
| 262 | """ |
| 263 | |
| 264 | position_x = 0.9700436 |
| 265 | position_y = -0.24308753 |
| 266 | velocity_x = 0.466203685 |
| 267 | velocity_y = 0.43236573 |
| 268 | |
| 269 | bodies1 = [ |
| 270 | Body(position_x, position_y, velocity_x, velocity_y, size=0.2, color="red"), |
| 271 | Body(-position_x, -position_y, velocity_x, velocity_y, size=0.2, color="green"), |
| 272 | Body(0, 0, -2 * velocity_x, -2 * velocity_y, size=0.2, color="blue"), |
| 273 | ] |
| 274 | return BodySystem(bodies1, time_factor=3) |
| 275 | |
| 276 | |
| 277 | def example_2() -> BodySystem: |
no test coverage detected