|
|
|
@ -254,9 +254,50 @@ fn _line() { |
|
|
|
|
|
|
|
println!();
|
|
|
|
let pg = Polygon(
|
|
|
|
Coordinates(vec!( Coordinate( 0, -20)
|
|
|
|
, Coordinate( 20, 20)
|
|
|
|
, Coordinate(-20, 20) )));
|
|
|
|
Coordinates(vec!( Coordinate( 0, -10)
|
|
|
|
, Coordinate( 10, 10)
|
|
|
|
, Coordinate(-10, 10) )));
|
|
|
|
println!("{:>14} : {}", pg, pg.plot());
|
|
|
|
|
|
|
|
let i = Vector(Fractional( 0,1), Fractional(-30,1), Fractional(0,1));
|
|
|
|
let j = Vector(Fractional( 30,1), Fractional( 30,1), Fractional(0,1));
|
|
|
|
let k = Vector(Fractional(-30,1), Fractional( 30,1), Fractional(0,1));
|
|
|
|
|
|
|
|
let rot :TMatrix<Fractional> = rotate_z(20);
|
|
|
|
let Vector(ix, iy, _) = rot.apply(&i);
|
|
|
|
let Vector(jx, jy, _) = rot.apply(&j);
|
|
|
|
let Vector(kx, ky, _) = rot.apply(&k);
|
|
|
|
|
|
|
|
fn to_i32(x :Fractional) -> i32 {
|
|
|
|
let Fractional(n, d) = x;
|
|
|
|
(n / d + if (n % d).abs() < (n / 2).abs() { 0 } else { 1 }) as i32
|
|
|
|
}
|
|
|
|
|
|
|
|
println!();
|
|
|
|
let pg = Polygon(
|
|
|
|
Coordinates(vec!( Coordinate(to_i32(ix) + 100, to_i32(iy) + 100)
|
|
|
|
, Coordinate(to_i32(jx) + 100, to_i32(jy) + 100)
|
|
|
|
, Coordinate(to_i32(kx) + 100, to_i32(ky) + 100) )));
|
|
|
|
println!("{:>14} : {}", pg, pg.plot());
|
|
|
|
|
|
|
|
let i = Vector( 0.0, -30.0, 0.0);
|
|
|
|
let j = Vector( 30.0, 30.0, 0.0);
|
|
|
|
let k = Vector(-30.0, 30.0, 0.0);
|
|
|
|
|
|
|
|
let rot :TMatrix<f64> = rotate_z(20);
|
|
|
|
let Vector(ix, iy, _) = rot.apply(&i);
|
|
|
|
let Vector(jx, jy, _) = rot.apply(&j);
|
|
|
|
let Vector(kx, ky, _) = rot.apply(&k);
|
|
|
|
|
|
|
|
fn to_i32_2(x :f64) -> i32 {
|
|
|
|
x.round() as i32
|
|
|
|
}
|
|
|
|
|
|
|
|
println!();
|
|
|
|
let pg = Polygon(
|
|
|
|
Coordinates(vec!( Coordinate(to_i32_2(ix) + 100, to_i32_2(iy) + 100)
|
|
|
|
, Coordinate(to_i32_2(jx) + 100, to_i32_2(jy) + 100)
|
|
|
|
, Coordinate(to_i32_2(kx) + 100, to_i32_2(ky) + 100) )));
|
|
|
|
println!("{:>14} : {}", pg, pg.plot());
|
|
|
|
}
|
|
|
|
|
|
|
|
|