diff --git a/fractional/notes/polyhedra.pdf b/fractional/notes/polyhedra.pdf new file mode 100644 index 0000000..92e1eef Binary files /dev/null and b/fractional/notes/polyhedra.pdf differ diff --git a/fractional/src/geometry.rs b/fractional/src/geometry.rs index b3cdfcd..f4c38ec 100644 --- a/fractional/src/geometry.rs +++ b/fractional/src/geometry.rs @@ -245,29 +245,25 @@ where T: Add + Sub + Neg } } - // https://rechneronline.de/pi/tetrahedron.php + // construct via cube, see polyhedra.pdf pub fn tetrahedron(a :T) -> Polyeder { - let f0 :T = 0.into(); - let f3 :T = 3.into(); - let f4 :T = 4.into(); - let f6 :T = 6.into(); - let f12 :T = 12.into(); - - let yi :T = a / f12 * T::sqrt(f6).unwrap(); - let yc :T = a / f4 * T::sqrt(f6).unwrap(); - let zi :T = T::sqrt(f3).unwrap() / f6 * a; - let zc :T = T::sqrt(f3).unwrap() / f3 * a; - let ah :T = a / 2.into(); - - let ps = vec!( Point::new( f0, yc, f0) - , Point::new(-ah, -yi, -zi) - , Point::new( ah, -yi, -zi) - , Point::new( f0, -yi, zc) ); - - let fs = vec!( Face::new(vec!(1, 2, 3), &ps) - , Face::new(vec!(1, 0, 2), &ps) - , Face::new(vec!(3, 0, 1), &ps) - , Face::new(vec!(2, 0, 3), &ps) ); + let f2 :T = 2.into(); + let ch = a / (f2 * T::sqrt(f2).unwrap()); + + let ps = vec!( Point::new(-ch, -ch, ch) // A + , Point::new(-ch, ch, -ch) // C + , Point::new( ch, -ch, -ch) // E + , Point::new( ch, ch, ch) ); // G + + // bottom: 1, 2, 3 + let fs = vec!( Face::new(vec!(2, 1, 0), &ps) // bottom + , Face::new(vec!(3, 2, 0), &ps) + , Face::new(vec!(0, 1, 3), &ps) + , Face::new(vec!(1, 2, 3), &ps) ); + //let fs = vec!( Face::new(vec!(0, 1, 2), &ps) // bottom + // , Face::new(vec!(0, 2, 3), &ps) + // , Face::new(vec!(3, 1, 0), &ps) + // , Face::new(vec!(3, 2, 1), &ps) ); Polyeder{ points: ps, faces: fs } } diff --git a/fractional/src/main.rs b/fractional/src/main.rs index 33a50f8..bd9352a 100644 --- a/fractional/src/main.rs +++ b/fractional/src/main.rs @@ -36,8 +36,7 @@ use fractional::trigonometry::Trig; use fractional::vector::Vector; use fractional::transform::{TMatrix, Transformable}; use fractional::xcb::XcbEasel; - -use fractional::geometry::{Camera,DirectLight,Polyeder,Primitives}; +use fractional::geometry::{Camera, DirectLight, Polyeder, Primitives}; fn mean(v: &Vec) -> Result { let r = v.iter().fold(0, |acc, x| acc + x); @@ -403,10 +402,11 @@ fn main() { let xcb = XcbEasel::new().unwrap(); let (tx, rx) = mpsc::channel(); + _democanvas( &xcb, "Something...(f64)", tx.clone() , Polyeder::triangle(60.0) , Polyeder::tetrahedron(80.0) - , Polyeder::cube(55.0) + , Polyeder::cube(45.0) , DirectLight::new(Vector(0.0, 0.0, 1.0)) ); /* _democanvas( &xcb, "Something...(Fractional)", tx.clone()