Format
This commit is contained in:
parent
61abb88938
commit
a63749c28b
20
src/main.rs
20
src/main.rs
@ -220,9 +220,13 @@ fn main() {
|
||||
let step = 40.0;
|
||||
let as_f32 = |x| x as f32 * step;
|
||||
let range = if target >= 0.0 {
|
||||
(0..=((target-0.0001) / step) as usize).map(as_f32).chain(Some(target))
|
||||
(0..=((target - 0.0001) / step) as usize)
|
||||
.map(as_f32)
|
||||
.chain(Some(target))
|
||||
} else {
|
||||
(0..=((next_angle-0.0001) / step) as usize).map(as_f32).chain(None)
|
||||
(0..=((next_angle - 0.0001) / step) as usize)
|
||||
.map(as_f32)
|
||||
.chain(None)
|
||||
};
|
||||
|
||||
for angle in range {
|
||||
@ -231,13 +235,11 @@ fn main() {
|
||||
let mut tri = rotate(*next_tri, radians);
|
||||
|
||||
// "binary search"-like optimization here
|
||||
for &delta in &[80.0, 30.0, 10.0, 5.0, 1.0, 0.6, 0.32, 0.18, 0.1, 0.06, 0.03, 0.01, 0.003] {
|
||||
for &delta in &[
|
||||
80.0, 30.0, 10.0, 5.0, 1.0, 0.6, 0.32, 0.18, 0.1, 0.06, 0.03, 0.01, 0.003,
|
||||
] {
|
||||
let initial_state = last_tri.intersects(&tri);
|
||||
let dx = if initial_state {
|
||||
delta
|
||||
} else {
|
||||
-delta
|
||||
};
|
||||
let dx = if initial_state { delta } else { -delta };
|
||||
while last_tri.intersects(&tri) == initial_state {
|
||||
tri.0.x += dx;
|
||||
tri.1.x += dx;
|
||||
@ -264,7 +266,7 @@ fn main() {
|
||||
} else if w.width < best.width {
|
||||
w.width -= (2.0 * PI - free_angle - next_angle) * 0.01;
|
||||
//if (angle > 50 && angle < 55) || (angle > 88 && angle < 92) {
|
||||
//println!("{:?} -> {:?}", angle, w.width);
|
||||
//println!("{:?} -> {:?}", angle, w.width);
|
||||
//}
|
||||
new.push(w);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user