Format
This commit is contained in:
parent
61abb88938
commit
a63749c28b
18
src/main.rs
18
src/main.rs
@ -220,9 +220,13 @@ fn main() {
|
|||||||
let step = 40.0;
|
let step = 40.0;
|
||||||
let as_f32 = |x| x as f32 * step;
|
let as_f32 = |x| x as f32 * step;
|
||||||
let range = if target >= 0.0 {
|
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 {
|
} 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 {
|
for angle in range {
|
||||||
@ -231,13 +235,11 @@ fn main() {
|
|||||||
let mut tri = rotate(*next_tri, radians);
|
let mut tri = rotate(*next_tri, radians);
|
||||||
|
|
||||||
// "binary search"-like optimization here
|
// "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 initial_state = last_tri.intersects(&tri);
|
||||||
let dx = if initial_state {
|
let dx = if initial_state { delta } else { -delta };
|
||||||
delta
|
|
||||||
} else {
|
|
||||||
-delta
|
|
||||||
};
|
|
||||||
while last_tri.intersects(&tri) == initial_state {
|
while last_tri.intersects(&tri) == initial_state {
|
||||||
tri.0.x += dx;
|
tri.0.x += dx;
|
||||||
tri.1.x += dx;
|
tri.1.x += dx;
|
||||||
|
Loading…
Reference in New Issue
Block a user