MCPcopy Create free account
hub / github.com/Notgnoshi/generative / simulate_coordinate

Function simulate_coordinate

tools/streamline.rs:320–356  ·  view source on GitHub ↗
(
    original: Coord,
    field: &VectorField,
    timestep: f64,
    num_timesteps: usize,
    record_streamlines: bool,
)

Source from the content-addressed store, hash-verified

318}
319
320fn 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
358fn simulate_rigid_geometry(
359 mut geometry: Geometry,

Callers 2

simulate_rigid_geometryFunction · 0.85
simulate_geom_verticesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected