refactor(specctra/design): construct points on circle via Iterator map+collect

This commit is contained in:
Alain Emilia Anna Zscheile 2024-12-10 23:53:43 +01:00
parent 577dc7c26d
commit dfff4ff4c2
1 changed files with 9 additions and 9 deletions

View File

@ -99,15 +99,15 @@ impl SpecctraDesign {
let angle_from = bend.start_angle(); let angle_from = bend.start_angle();
let angle_step = bend.spanned_angle() / segment_count as f64; let angle_step = bend.spanned_angle() / segment_count as f64;
let mut points = Vec::new(); (0..=segment_count)
for i in 0..=segment_count { .into_iter()
let x = circle.pos.x() .map(|i| angle_from + i as f64 * angle_step)
+ circle.r * (angle_from + i as f64 * angle_step).cos(); .map(|phi| {
let y = circle.pos.y() let x = circle.pos.x() + circle.r * phi.cos();
+ circle.r * (angle_from + i as f64 * angle_step).sin(); let y = circle.pos.y() + circle.r * phi.sin();
points.push(structure::Point { x, y }); structure::Point { x, y }
} })
points .collect()
} }
// Intentionally skipped for now. // Intentionally skipped for now.