mirror of https://codeberg.org/topola/topola.git
refactor(specctra/design): construct points on circle via Iterator map+collect
This commit is contained in:
parent
577dc7c26d
commit
dfff4ff4c2
|
|
@ -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.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue