ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/acismesh/m3d_int_triangle.cpp
Revision: 1
Committed: Mon Jun 11 22:53:07 2007 UTC (17 years, 11 months ago)
File size: 2122 byte(s)
Log Message:

File Contents

# User Rev Content
1 1 /*****************************************************************
2    
3     m3d_int_triangle.c Type:Func
4    
5     un point est il dans un triangle
6    
7     Date de creation : Mon Jun 30 12:05:37 1997
8    
9     Derniere version : Thu Jul 3 09:41:51 1997
10    
11    
12    
13    
14     Vincent FRANCOIS
15    
16     *****************************************************************/
17    
18    
19    
20    
21    
22     /**************************/
23     /* include */
24     #include <stdio.h>
25     #include <math.h>
26     #include "const.h"
27     #include "memoire.h"
28     #include "struct.h"
29     #include "prototype.h"
30    
31     /**************************/
32     /* variables globales */
33     extern struct environnement env;
34     extern struct s_mesh *mesh;
35    
36    
37    
38     /**************************/
39     /* programme principal */
40    
41     int m3d_int_triangle(int n1,int n2,int n3,float x,float y,float z)
42     {
43     struct s_noeud *no1,*no2,*no3;
44     float n1n2[3],n1n3[3],n2n3[3],n[3],n1p[3],n2p[3],n3p[3],pv1[3],pv2[3],pv3[3];
45     float ps1,ps2,ps3,eps;
46    
47     no1=ADRESSE(n1,noeud,mesh->);
48     no2=ADRESSE(n2,noeud,mesh->);
49     no3=ADRESSE(n3,noeud,mesh->);
50     VEC(n1n2,no1,no2);
51     VEC(n1n3,no1,no3)
52     PVEC(n,n1n2,n1n3);
53     eps=PSCA(n1n2,n1n2);
54     eps=eps*eps*4.*0.0001;
55     n1p[0]=x-no1->x;n1p[1]=y-no1->y;n1p[2]=z-no1->z;
56     n2p[0]=x-no2->x;n2p[1]=y-no2->y;n2p[2]=z-no2->z;
57     n3p[0]=x-no3->x;n3p[1]=y-no3->y;n3p[2]=z-no3->z;
58     PVEC(pv1,n1n2,n1p);
59     ps1=PSCA(pv1,n);
60     if (ps1>(-eps))
61     {
62     VEC(n2n3,no2,no3);
63     PVEC(pv2,n2n3,n2p);
64     ps2=PSCA(pv2,n);
65     if (ps2>(-eps))
66     {
67     PVEC(pv3,n1n3,n3p)
68     ps3=(-1)*PSCA(pv3,n);
69     if (ps3>(-eps)) return(1);
70     }
71     }
72    
73     return(0);
74     }