Go to the documentation of this file.00001 #ifndef OPENTISSUE_COLLISION_INTERSECT_INTERSECT_TRIANGLE_TRIANGLE_H
00002 #define OPENTISSUE_COLLISION_INTERSECT_INTERSECT_TRIANGLE_TRIANGLE_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <OpenTissue/collision/intersect/intersect_line_triangle.h>
00013
00014 namespace OpenTissue
00015 {
00016 namespace intersect
00017 {
00018
00031 template<typename triangle_type,typename vector3_container>
00032 bool triangle_triangle(triangle_type const & A,triangle_type const & B,vector3_container & points)
00033 {
00034 typedef typename triangle_type::vector3_type vector3_type;
00035
00036 bool collision = false;
00037 vector3_type p;
00038 if(line_triangle(A.p0(),A.p1(),B,p))
00039 {
00040 points.push_back(p);
00041 collision = true;
00042 }
00043 if(line_triangle(A.p1(),A.p2(),B,p))
00044 {
00045 points.push_back(p);
00046 collision = true;
00047 }
00048 if(line_triangle(A.p2(),A.p0(),B,p))
00049 {
00050 points.push_back(p);
00051 collision = true;
00052 }
00053 if(line_triangle(B.p0(),B.p1(),A,p))
00054 {
00055 points.push_back(p);
00056 collision = true;
00057 }
00058 if(line_triangle(B.p1(),B.p2(),A,p))
00059 {
00060 points.push_back(p);
00061 collision = true;
00062 }
00063 if(line_triangle(B.p2(),B.p0(),A,p))
00064 {
00065 points.push_back(p);
00066 collision = true;
00067 }
00068 return collision;
00069 }
00070
00071 }
00072
00073 }
00074
00075
00076 #endif