Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Rocon/include/triangle.h
Go to the documentation of this file.
1 #ifndef TRIANGLE_H
2 #define TRIANGLE_H
3 
4 #include <cmath>
5 #include "NVec.h"
6 
7 using namespace nvc;
8 
9 /* Ray-Triangle Intersection Test Routines */
10 /* code from journals of graphics tools (JGT) */
11 /* http://www.acm.org/jgt/ */
12 /* by Tomas Moller, May 2000 */
13 
14 #define EPSILON 1e-24
15 
16 #define CROSS(dest,v1,v2) \
17  dest[0]=v1[1]*v2[2]-v1[2]*v2[1]; \
18  dest[1]=v1[2]*v2[0]-v1[0]*v2[2]; \
19  dest[2]=v1[0]*v2[1]-v1[1]*v2[0];
20 #define DOT(v1,v2) (v1[0]*v2[0]+v1[1]*v2[1]+v1[2]*v2[2])
21 #define SUB(dest,v1,v2) \
22  dest[0]=v1[0]-v2[0]; \
23  dest[1]=v1[1]-v2[1]; \
24  dest[2]=v1[2]-v2[2];
25 
26 int intersect_ray_triangle( const Vec3D &RP0,
27  const Vec3D & dir,
28  Vec3D & TV0,
29  Vec3D & TV1,
30  Vec3D & TV2,
31  Vec3D & I );
32 
33 /* the original jgt code */
34 int intersect_triangle(double orig[3], double dir[3],
35  double vert0[3], double vert1[3], double vert2[3],
36  double *t, double *u, double *v);
37 
38 /* code rewritten to do tests on the sign of the determinant */
39 /* the division is at the end in the code */
40 int intersect_triangle1(double orig[3], double dir[3],
41  double vert0[3], double vert1[3], double vert2[3],
42  double *t, double *u, double *v);
43 
44 
45 /* code rewritten to do tests on the sign of the determinant */
46 /* the division is before the test of the sign of the det */
47 int intersect_triangle2(double orig[3], double dir[3],
48  double vert0[3], double vert1[3], double vert2[3],
49  double *t, double *u, double *v);
50 
51 
52 /* code rewritten to do tests on the sign of the determinant */
53 /* the division is before the test of the sign of the det */
54 /* and one CROSS has been moved out from the if-else if-else */
55 int intersect_triangle3(double orig[3], double dir[3],
56  double vert0[3], double vert1[3], double vert2[3],
57  double *t, double *u, double *v);
58 
59 // ray-triangle intersection -- prateek
60 //int P_triRay(const RAYTRI *rt, double &t);
61 
62 /* Wrapper for all other methods ? */
63 bool rayIntersectsTriangle(double *p, double *d,
64  double *v0, double *v1, double *v2, Vec3D &I);
65 
66 #endif
const NT & d
int intersect_triangle3(double orig[3], double dir[3], double vert0[3], double vert1[3], double vert2[3], double *t, double *u, double *v)
int intersect_ray_triangle(const Vec3D &RP0, const Vec3D &dir, Vec3D &TV0, Vec3D &TV1, Vec3D &TV2, Vec3D &I)
int intersect_triangle2(double orig[3], double dir[3], double vert0[3], double vert1[3], double vert2[3], double *t, double *u, double *v)
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
bool rayIntersectsTriangle(double *p, double *d, double *v0, double *v1, double *v2, Vec3D &I)
int intersect_triangle1(double orig[3], double dir[3], double vert0[3], double vert1[3], double vert2[3], double *t, double *u, double *v)
int intersect_triangle(double orig[3], double dir[3], double vert0[3], double vert1[3], double vert2[3], double *t, double *u, double *v)