|
|
|
@ -339,8 +339,6 @@ fn main() { |
|
|
|
canvas.init_events();
|
|
|
|
|
|
|
|
let (tx, rx) = mpsc::channel();
|
|
|
|
let tx1 = mpsc::Sender::clone(&tx);
|
|
|
|
canvas.start_events(tx);
|
|
|
|
|
|
|
|
let i = Vector(Fractional( 0,1), Fractional(-35,1), Fractional(0,1));
|
|
|
|
let j = Vector(Fractional( 30,1), Fractional( 17,1), Fractional(0,1));
|
|
|
|
@ -351,20 +349,13 @@ fn main() { |
|
|
|
(n / d + if (n % d).abs() < (n / 2).abs() { 0 } else { 1 }) as i32
|
|
|
|
}
|
|
|
|
|
|
|
|
thread::spawn(move || {
|
|
|
|
loop {
|
|
|
|
tx1.send(0).unwrap();
|
|
|
|
thread::sleep(time::Duration::from_millis(10));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
canvas.start_events(tx);
|
|
|
|
|
|
|
|
thread::spawn(move || {
|
|
|
|
let mut deg :i32 = 0;
|
|
|
|
loop {
|
|
|
|
let rot :TMatrix<Fractional> = rotate_z(deg) * rotate_x(-deg);
|
|
|
|
|
|
|
|
for x in rx {
|
|
|
|
match x {
|
|
|
|
1 => break,
|
|
|
|
_ => {
|
|
|
|
let rot :TMatrix<Fractional> = rotate_z(deg);
|
|
|
|
let Vector(ix, iy, _) = rot.apply(&i);
|
|
|
|
let Vector(jx, jy, _) = rot.apply(&j);
|
|
|
|
let Vector(kx, ky, _) = rot.apply(&k);
|
|
|
|
@ -373,12 +364,20 @@ fn main() { |
|
|
|
Coordinates(vec!( Coordinate(to_i32(ix), to_i32(iy))
|
|
|
|
, Coordinate(to_i32(jx), to_i32(jy))
|
|
|
|
, Coordinate(to_i32(kx), to_i32(ky)) )));
|
|
|
|
|
|
|
|
canvas.clear();
|
|
|
|
canvas.draw(&pg, Coordinate(75,75));
|
|
|
|
canvas.show();
|
|
|
|
deg = (deg + 3) % 359;
|
|
|
|
},
|
|
|
|
|
|
|
|
deg = (deg + 1) % 360;
|
|
|
|
|
|
|
|
thread::sleep(time::Duration::from_millis(5));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
for x in rx {
|
|
|
|
match x {
|
|
|
|
1 => break,
|
|
|
|
_ => {},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|