Subject: CGAL users discussion list
List archive
- From: Kuan <>
- To:
- Subject: Re: [cgal-discuss] Problem about Intersection
- Date: Sun, 21 Oct 2007 11:50:20 +0200
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=rEOqAcxdOw0ZsPmuG/O35sM0Z3KH3hk83mQa97ox+vhUkvl48+HPF07UdfEoXkUF4CzMPjmSL3dYVsD8m1LbBqezOc7yVBQev516ekVcfLHVUnA+0LB4hdjM4xtEcCqYF7tDiPH0QgMD9JWvIbnWuffL4j5yXh08S6sSs0MRD2c=
Thank you for your help.
I forget to mention that the mesh is very large, so is there any efficient way to do it? Like kd-tree
best wishes
Kuan
2007/10/21, Wesley Smith <>:
I peresonally found this operation in CGAL a bit lacking, so I use the
code from Tomas Moller:
http://www.cs.lth.se/home/Tomas_Akenine_Moller/raytri/raytri.c
You can google their paper describing the method. It gives values (t,
u, v) where t is the distance along the ray to the intersection point
and u and v are barycentric coordinates of the intersection on the
triangle.
Sample usage:
void ray_mesh_intersction(vector<Facet> &facets, const Ray &r)
{
Point o = r.source();
Direction d = r.direction();
double orig[] = {o.x(), o.y(), o.z()};
double dir[] = {d.dx(), d.dy(), d.dz()};
for(int f = 0; f < facets.size(); f++) {
Triangle tri = V->dual().triangle(facets[f]);
double vert0[] = {tri.vertex(0).x(), tri.vertex(0).y(), tri.vertex(0).z()};
double vert1[] = { tri.vertex(1).x(), tri.vertex(1).y(), tri.vertex(1).z()};
double vert2[] = {tri.vertex(2).x(), tri.vertex(2).y(), tri.vertex(2).z()};
double t, u, v;
if(intersect_triangle2(orig, dir, vert0, vert1, vert2, &t, &u, &v)) {
if(t > 0) {
//printf("intersect: %f %f %f\n", t, u, v);
//intersect point is Point(t*dir[0]+orig[0], t*dir[1]+orig[1],
t*dir[2]+orig[2]);
}
}
}
}
--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss
- Problem about Intersection, Kuan, 10/20/2007
- Re: [cgal-discuss] Problem about Intersection, Wesley Smith, 10/21/2007
- Re: [cgal-discuss] Problem about Intersection, Kuan, 10/21/2007
- Re: [cgal-discuss] Problem about Intersection, Wesley Smith, 10/21/2007
Archive powered by MHonArc 2.6.16.