MCPcopy Create free account
hub / github.com/ecto/muni / compute_path_length

Function compute_path_length

depot/dispatch/src/coverage.rs:231–240  ·  view source on GitHub ↗

Compute total path length from waypoints.

(waypoints: &[Waypoint])

Source from the content-addressed store, hash-verified

229
230/// Compute total path length from waypoints.
231fn compute_path_length(waypoints: &[Waypoint]) -> f64 {
232 waypoints
233 .windows(2)
234 .map(|w| {
235 let dx = w[1].x - w[0].x;
236 let dy = w[1].y - w[0].y;
237 (dx * dx + dy * dy).sqrt()
238 })
239 .sum()
240}
241
242#[cfg(test)]
243mod tests {

Callers 1

generateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected