Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ray: Intersect triangle does not work #244

Open
A6GibKm opened this issue Jan 11, 2022 · 0 comments
Open

ray: Intersect triangle does not work #244

A6GibKm opened this issue Jan 11, 2022 · 0 comments

Comments

@A6GibKm
Copy link

A6GibKm commented Jan 11, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant