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_step = bend.spanned_angle() / segment_count as f64;
let mut points = Vec::new();
for i in 0..=segment_count {
let x = circle.pos.x()
+ circle.r * (angle_from + i as f64 * angle_step).cos();
let y = circle.pos.y()
+ circle.r * (angle_from + i as f64 * angle_step).sin();
points.push(structure::Point { x, y });
}
points
(0..=segment_count)
.into_iter()
.map(|i| angle_from + i as f64 * angle_step)
.map(|phi| {
let x = circle.pos.x() + circle.r * phi.cos();
let y = circle.pos.y() + circle.r * phi.sin();
structure::Point { x, y }
})
.collect()
}
// Intentionally skipped for now.