Updates the body-system and applies the change to the patch-list used for plotting >>> body_system_1 = BodySystem([Body(0,0,0,0), Body(10,0,0,0)]) >>> patches_1 = [plt.Circle((body.position_x, body.position_y), body.size, ... fc=body.color)for body in body_system_1.bodies] #do
(
body_system: BodySystem, delta_time: float, patches: list[plt.Circle]
)
| 183 | |
| 184 | |
| 185 | def update_step( |
| 186 | body_system: BodySystem, delta_time: float, patches: list[plt.Circle] |
| 187 | ) -> None: |
| 188 | """ |
| 189 | Updates the body-system and applies the change to the patch-list used for plotting |
| 190 | |
| 191 | >>> body_system_1 = BodySystem([Body(0,0,0,0), Body(10,0,0,0)]) |
| 192 | >>> patches_1 = [plt.Circle((body.position_x, body.position_y), body.size, |
| 193 | ... fc=body.color)for body in body_system_1.bodies] #doctest: +ELLIPSIS |
| 194 | >>> update_step(body_system_1, 1, patches_1) |
| 195 | >>> patches_1[0].center |
| 196 | (0.01, 0.0) |
| 197 | |
| 198 | >>> body_system_2 = BodySystem([Body(-10,0,0,0), Body(10,0,0,0, mass=4)], 1, 10) |
| 199 | >>> patches_2 = [plt.Circle((body.position_x, body.position_y), body.size, |
| 200 | ... fc=body.color)for body in body_system_2.bodies] #doctest: +ELLIPSIS |
| 201 | >>> update_step(body_system_2, 1, patches_2) |
| 202 | >>> patches_2[0].center |
| 203 | (-9.0, 0.0) |
| 204 | """ |
| 205 | # Update the positions of the bodies |
| 206 | body_system.update_system(delta_time) |
| 207 | |
| 208 | # Update the positions of the patches |
| 209 | for patch, body in zip(patches, body_system.bodies): |
| 210 | patch.center = (body.position_x, body.position_y) |
| 211 | |
| 212 | |
| 213 | def plot( |