Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Rocprop/include/triangle.h
Go to the documentation of this file.
1 #ifndef TRIANGLE_H
2 #define TRIANGLE_H
3 
4 #include <math.h>
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 0.000001
15 #define CROSS(dest,v1,v2) \
16  dest[0]=v1[1]*v2[2]-v1[2]*v2[1]; \
17  dest[1]=v1[2]*v2[0]-v1[0]*v2[2]; \
18  dest[2]=v1[0]*v2[1]-v1[1]*v2[0];
19 #define DOT(v1,v2) (v1[0]*v2[0]+v1[1]*v2[1]+v1[2]*v2[2])
20 #define SUB(dest,v1,v2) \
21  dest[0]=v1[0]-v2[0]; \
22  dest[1]=v1[1]-v2[1]; \
23  dest[2]=v1[2]-v2[2];
24 
25 int intersect_ray_triangle( const Vec3D &RP0,
26  const Vec3D & dir,
27  Vec3D & TV0,
28  Vec3D & TV1,
29  Vec3D & TV2,
30  Vec3D & I );
31 
32 /* the original jgt code */
33 int intersect_triangle(double orig[3], double dir[3],
34  double vert0[3], double vert1[3], double vert2[3],
35  double *t, double *u, double *v);
36 
37 /* code rewritten to do tests on the sign of the determinant */
38 /* the division is at the end in the code */
39 int intersect_triangle1(double orig[3], double dir[3],
40  double vert0[3], double vert1[3], double vert2[3],
41  double *t, double *u, double *v);
42 
43 
44 /* code rewritten to do tests on the sign of the determinant */
45 /* the division is before the test of the sign of the det */
46 int intersect_triangle2(double orig[3], double dir[3],
47  double vert0[3], double vert1[3], double vert2[3],
48  double *t, double *u, double *v);
49 
50 
51 /* code rewritten to do tests on the sign of the determinant */
52 /* the division is before the test of the sign of the det */
53 /* and one CROSS has been moved out from the if-else if-else */
54 int intersect_triangle3(double orig[3], double dir[3],
55  double vert0[3], double vert1[3], double vert2[3],
56  double *t, double *u, double *v);
57 
58 // ray-triangle intersection -- prateek
59 //int P_triRay(const RAYTRI *rt, double &t);
60 
61 /* Wrapper for all other methods ? */
62 bool rayIntersectsTriangle(double *p, double *d,
63  double *v0, double *v1, double *v2, Vec3D &I);
64 
65 #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)