#include <cmath>
#include "NVec.h"
Go to the source code of this file.
|
#define | EPSILON 1e-24 |
|
#define | CROSS(dest, v1, v2) |
|
#define | DOT(v1, v2) (v1[0]*v2[0]+v1[1]*v2[1]+v1[2]*v2[2]) |
|
#define | SUB(dest, v1, v2) |
|
|
int | intersect_ray_triangle (const Vec3D &RP0, const Vec3D &dir, Vec3D &TV0, Vec3D &TV1, Vec3D &TV2, Vec3D &I) |
|
int | intersect_triangle (double orig[3], double dir[3], double vert0[3], double vert1[3], double vert2[3], double *t, double *u, double *v) |
|
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_triangle2 (double orig[3], double dir[3], double vert0[3], double vert1[3], double vert2[3], double *t, double *u, double *v) |
|
int | intersect_triangle3 (double orig[3], double dir[3], double vert0[3], double vert1[3], double vert2[3], double *t, double *u, double *v) |
|
bool | rayIntersectsTriangle (double *p, double *d, double *v0, double *v1, double *v2, Vec3D &I) |
|
#define CROSS |
( |
|
dest, |
|
|
|
v1, |
|
|
|
v2 |
|
) |
| |
Value:dest[0]=v1[1]*v2[2]-v1[2]*v2[1]; \
dest[1]=v1[2]*v2[0]-v1[0]*v2[2]; \
dest[2]=v1[0]*v2[1]-v1[1]*v2[0];
Definition at line 16 of file Rocon/include/triangle.h.
#define DOT |
( |
|
v1, |
|
|
|
v2 |
|
) |
| (v1[0]*v2[0]+v1[1]*v2[1]+v1[2]*v2[2]) |
#define SUB |
( |
|
dest, |
|
|
|
v1, |
|
|
|
v2 |
|
) |
| |
Definition at line 283 of file Rocon/src/ray-triangle.C.
294 if (n ==
Vec3D(0,0,0))
319 double uu, uv, vv, wu, wv, D;
326 D = (uv * uv) -( uu * vv);
330 s = (uv * wv - vv * wu) / D;
331 if (s < 0.0 || s > 1.0)
333 t = (uv * wu - uu * wv) / D;
334 if (t < 0.0 || (s + t) > 1.0)
NVec< 3, T > cross(const NVec< 3, T > &u, const NVec< 3, T > &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
int intersect_triangle |
( |
double |
orig[3], |
|
|
double |
dir[3], |
|
|
double |
vert0[3], |
|
|
double |
vert1[3], |
|
|
double |
vert2[3], |
|
|
double * |
t, |
|
|
double * |
u, |
|
|
double * |
v |
|
) |
| |
Definition at line 344 of file Rocon/src/ray-triangle.C.
Referenced by rayIntersectsTriangle().
348 double edge1[3], edge2[3], tvec[3], pvec[3], qvec[3];
352 SUB(edge1, vert1, vert0);
353 SUB(edge2, vert2, vert0);
356 CROSS(pvec, dir, edge2);
359 det =
DOT(edge1, pvec);
366 SUB(tvec, orig, vert0);
369 *u =
DOT(tvec, pvec) * inv_det;
370 if (*u < 0.0 || *u > 1.0)
374 CROSS(qvec, tvec, edge1);
377 *
v =
DOT(dir, qvec) * inv_det;
378 if (*v < 0.0 || *u + *v > 1.0)
382 *t =
DOT(edge2, qvec) * inv_det;
#define SUB(dest, v1, v2)
*********************************************************************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
double det(const Matrix3D &A)
#define CROSS(dest, v1, v2)
int intersect_triangle1 |
( |
double |
orig[3], |
|
|
double |
dir[3], |
|
|
double |
vert0[3], |
|
|
double |
vert1[3], |
|
|
double |
vert2[3], |
|
|
double * |
t, |
|
|
double * |
u, |
|
|
double * |
v |
|
) |
| |
Definition at line 393 of file Rocon/src/ray-triangle.C.
397 double edge1[3], edge2[3], tvec[3], pvec[3], qvec[3];
401 SUB(edge1, vert1, vert0);
402 SUB(edge2, vert2, vert0);
405 CROSS(pvec, dir, edge2);
408 det =
DOT(edge1, pvec);
413 SUB(tvec, orig, vert0);
416 *u =
DOT(tvec, pvec);
417 if (*u < 0.0 || *u > det)
421 CROSS(qvec, tvec, edge1);
425 if (*v < 0.0 || *u + *v > det)
432 SUB(tvec, orig, vert0);
435 *u =
DOT(tvec, pvec);
438 if (*u > 0.0 || *u < det)
442 CROSS(qvec, tvec, edge1);
445 *
v =
DOT(dir, qvec) ;
446 if (*
v > 0.0 || *u + *
v < det)
455 *t =
DOT(edge2, qvec) * inv_det;
#define SUB(dest, v1, v2)
*********************************************************************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
double det(const Matrix3D &A)
#define CROSS(dest, v1, v2)
int intersect_triangle2 |
( |
double |
orig[3], |
|
|
double |
dir[3], |
|
|
double |
vert0[3], |
|
|
double |
vert1[3], |
|
|
double |
vert2[3], |
|
|
double * |
t, |
|
|
double * |
u, |
|
|
double * |
v |
|
) |
| |
Definition at line 464 of file Rocon/src/ray-triangle.C.
468 double edge1[3], edge2[3], tvec[3], pvec[3], qvec[3];
472 SUB(edge1, vert1, vert0);
473 SUB(edge2, vert2, vert0);
476 CROSS(pvec, dir, edge2);
479 det =
DOT(edge1, pvec);
482 SUB(tvec, orig, vert0);
488 *u =
DOT(tvec, pvec);
489 if (*u < 0.0 || *u > det)
493 CROSS(qvec, tvec, edge1);
497 if (*v < 0.0 || *u + *v > det)
504 *u =
DOT(tvec, pvec);
505 if (*u > 0.0 || *u < det)
509 CROSS(qvec, tvec, edge1);
512 *
v =
DOT(dir, qvec) ;
513 if (*
v > 0.0 || *u + *
v < det)
519 *t =
DOT(edge2, qvec) * inv_det;
#define SUB(dest, v1, v2)
*********************************************************************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
double det(const Matrix3D &A)
#define CROSS(dest, v1, v2)
int intersect_triangle3 |
( |
double |
orig[3], |
|
|
double |
dir[3], |
|
|
double |
vert0[3], |
|
|
double |
vert1[3], |
|
|
double |
vert2[3], |
|
|
double * |
t, |
|
|
double * |
u, |
|
|
double * |
v |
|
) |
| |
Definition at line 529 of file Rocon/src/ray-triangle.C.
533 double edge1[3], edge2[3], tvec[3], pvec[3], qvec[3];
537 SUB(edge1, vert1, vert0);
538 SUB(edge2, vert2, vert0);
541 CROSS(pvec, dir, edge2);
544 det =
DOT(edge1, pvec);
547 SUB(tvec, orig, vert0);
550 CROSS(qvec, tvec, edge1);
554 *u =
DOT(tvec, pvec);
555 if (*u < 0.0 || *u > det)
560 if (*v < 0.0 || *u + *v > det)
567 *u =
DOT(tvec, pvec);
568 if (*u > 0.0 || *u < det)
572 *
v =
DOT(dir, qvec) ;
573 if (*
v > 0.0 || *u + *
v < det)
578 *t =
DOT(edge2, qvec) * inv_det;
#define SUB(dest, v1, v2)
*********************************************************************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
double det(const Matrix3D &A)
#define CROSS(dest, v1, v2)
bool rayIntersectsTriangle |
( |
double * |
p, |
|
|
double * |
d, |
|
|
double * |
v0, |
|
|
double * |
v1, |
|
|
double * |
v2, |
|
|
Vec3D & |
I |
|
) |
| |
Definition at line 586 of file Rocon/src/ray-triangle.C.
Referenced by MeshBndSurf::intersection().
630 I[
j]=p[
j]+ (*t)*
d[
j];
*********************************************************************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
int P_triRay(double *p, double *d, double *v0, double *v1, double *v2, Vec3D &I)
int intersect_triangle(double orig[3], double dir[3], double vert0[3], double vert1[3], double vert2[3], double *t, double *u, double *v)