(
original: Coord,
field: &VectorField,
timestep: f64,
num_timesteps: usize,
record_streamlines: bool,
)
| 318 | } |
| 319 | |
| 320 | fn simulate_coordinate( |
| 321 | original: Coord, |
| 322 | field: &VectorField, |
| 323 | timestep: f64, |
| 324 | num_timesteps: usize, |
| 325 | record_streamlines: bool, |
| 326 | ) -> (AffineTransform, LineString) { |
| 327 | let mut streamline = Vec::with_capacity(if record_streamlines { num_timesteps } else { 0 }); |
| 328 | let mut current = original; |
| 329 | if record_streamlines { |
| 330 | streamline.push(current); |
| 331 | } |
| 332 | for _ in 0..num_timesteps { |
| 333 | if current.x > field.max_x |
| 334 | || current.x < field.min_x |
| 335 | || current.y > field.max_y |
| 336 | || current.y < field.min_y |
| 337 | { |
| 338 | break; |
| 339 | } |
| 340 | |
| 341 | let current_vector = (field.function)(current.x, current.y); |
| 342 | |
| 343 | current.x += timestep * current_vector.0; |
| 344 | current.y += timestep * current_vector.1; |
| 345 | |
| 346 | if record_streamlines { |
| 347 | streamline.push(current); |
| 348 | } |
| 349 | } |
| 350 | |
| 351 | // TODO: Keep track of the initial and final coordinate orientations |
| 352 | let offset = current - original; |
| 353 | let transform = AffineTransform::translate(offset.x, offset.y); |
| 354 | |
| 355 | (transform, LineString::new(streamline)) |
| 356 | } |
| 357 | |
| 358 | fn simulate_rigid_geometry( |
| 359 | mut geometry: Geometry, |
no outgoing calls
no test coverage detected