played iwht matrix
This commit is contained in:
11
Cargo.lock
generated
11
Cargo.lock
generated
@@ -1,5 +1,7 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
|
version = 3
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "approx"
|
name = "approx"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
@@ -29,6 +31,14 @@ dependencies = [
|
|||||||
"approx",
|
"approx",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "matrix"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"approx",
|
||||||
|
"structs",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-traits"
|
name = "num-traits"
|
||||||
version = "0.2.14"
|
version = "0.2.14"
|
||||||
@@ -51,5 +61,6 @@ version = "0.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"canvas",
|
"canvas",
|
||||||
"color",
|
"color",
|
||||||
|
"matrix",
|
||||||
"structs",
|
"structs",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -10,3 +10,4 @@ edition = "2018"
|
|||||||
canvas = { path = "canvas" }
|
canvas = { path = "canvas" }
|
||||||
color = { path = "color" }
|
color = { path = "color" }
|
||||||
structs = { path = "structs" }
|
structs = { path = "structs" }
|
||||||
|
matrix = { path = "matrix" }
|
||||||
|
|||||||
32
src/main.rs
32
src/main.rs
@@ -1,6 +1,7 @@
|
|||||||
use canvas::Canvas;
|
use canvas::Canvas;
|
||||||
use color::Color;
|
use color::Color;
|
||||||
use structs::Tuple;
|
use structs::Tuple;
|
||||||
|
use matrix::Matrix;
|
||||||
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
@@ -106,4 +107,35 @@ fn main() {
|
|||||||
Err(e) => panic!("did not write. {}", e),
|
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