ebassi / graphene

A thin layer of graphic data types

Home Page:http://ebassi.github.io/graphene

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ray: Intersect triangle does not work

A6GibKm opened this issue · comments

The following code tries to intersect a ray from the origin to (1, 0) to a triangle right on its right

                        let a = graphene::Point3D::new(2.0, 0.0, 0.0);
                        let b = graphene::Point3D::new(3.0, -1.0, 0.0);
                        let c = graphene::Point3D::new(3.0, 1.0, 0.0);

                        let triangle = graphene::Triangle::from_point3d(Some(&a), Some(&b), Some(&c));

                        let o = graphene::Point3D::new(0.0, 0.0, 0.0);
                        let v = graphene::Vec3::new(1.0, 0.0, 0.0);

                        let ray = graphene::Ray::new(Some(&o), Some(&v));
                        let (kind, t_out) = ray.intersect_triangle(&triangle);
                        
                        println!("Kind: {:?}, t: {}", kind, t_out);

The result is

Kind: None, t: 0.000000000000000000000000000000000000000045914

I also tried it on gtk using a drag source to intersect a ray from (0, 0) to the pointer location with a fixed triangle (that does not intersect the origin) without success, getting the exact same result.