Skip to content

ray: Intersect triangle does not work #244

Description

@A6GibKm

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions