played iwht matrix
This commit is contained in:
32
src/main.rs
32
src/main.rs
@@ -1,6 +1,7 @@
|
||||
use canvas::Canvas;
|
||||
use color::Color;
|
||||
use structs::Tuple;
|
||||
use matrix::Matrix;
|
||||
|
||||
use std::fmt;
|
||||
use std::fs::File;
|
||||
@@ -106,4 +107,35 @@ fn main() {
|
||||
Err(e) => panic!("did not write. {}", e),
|
||||
};
|
||||
|
||||
|
||||
let i = Matrix::identity(4);
|
||||
println!("{:#?}", i);
|
||||
let inverse_i = i.inverse();
|
||||
println!("{:#?}", inverse_i);
|
||||
|
||||
|
||||
let mut a = Matrix::from_array([
|
||||
[1.0, 2.0, 3.0],
|
||||
[4.0, 5.0, 6.0],
|
||||
[7.0, 8.0, 1.0]
|
||||
]);
|
||||
|
||||
let mut b = a.inverse();
|
||||
println!("{:?}", b);
|
||||
let c = &a * &b;
|
||||
println!("{:?}", c);
|
||||
|
||||
b.transpose();
|
||||
a.transpose();
|
||||
let at = a.inverse();
|
||||
println!("{:?}", b);
|
||||
println!("{:?}", at);
|
||||
|
||||
|
||||
let t = Tuple::point(1.0, 2.0, 3.0);
|
||||
let mut id = Matrix::identity(4);
|
||||
id[1][3] = -3.0;
|
||||
let q = &id * &t;
|
||||
println!("{:?}", id);
|
||||
println!("{:?}", q);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user