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_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.
|
||||
|
|
|
|||
Loading…
Reference in New Issue