1 |
|
5 |
#include <stdio.h>
|
2 |
|
|
#include <math.h>
|
3 |
|
|
#include "m3d_struct.h"
|
4 |
|
|
#include "m3d_const.h"
|
5 |
|
|
#include "prototype.h"
|
6 |
|
|
int m3d_side(float *coord,int j1,int j2,int j3,int numa,int numb,int numc)
|
7 |
|
|
{
|
8 |
|
|
float vn[3], v12[3], v13[3], vec[3], norme, ps1, ps2, ps3, dref ;
|
9 |
|
|
int i ;
|
10 |
|
|
|
11 |
|
|
/* normale */
|
12 |
|
|
v12[0] = coord[x(j2)] - coord[x(j1)] ;
|
13 |
|
|
v12[1] = coord[y(j2)] - coord[y(j1)] ;
|
14 |
|
|
v12[2] = coord[z(j2)] - coord[z(j1)] ;
|
15 |
|
|
dref = -1.* NORME(v12) * 0.0001 ;
|
16 |
|
|
|
17 |
|
|
v13[0] = coord[x(j3)] - coord[x(j1)] ;
|
18 |
|
|
v13[1] = coord[y(j3)] - coord[y(j1)] ;
|
19 |
|
|
v13[2] = coord[z(j3)] - coord[z(j1)] ;
|
20 |
|
|
|
21 |
|
|
vn[0] = PVECX(v12,v13) ;
|
22 |
|
|
vn[1] = PVECY(v12,v13) ;
|
23 |
|
|
vn[2] = PVECZ(v12,v13) ;
|
24 |
|
|
|
25 |
|
|
norme = NORME(vn) ;
|
26 |
|
|
|
27 |
|
|
for (i=0;i<3;i++) vn[i] = vn[i]/norme ;
|
28 |
|
|
|
29 |
|
|
vec[0] = coord[x(numa)] - coord[x(j1)] ;
|
30 |
|
|
vec[1] = coord[y(numa)] - coord[y(j1)] ;
|
31 |
|
|
vec[2] = coord[z(numa)] - coord[z(j1)] ;
|
32 |
|
|
|
33 |
|
|
ps1 = PROSCA(vn,vec) ;
|
34 |
|
|
|
35 |
|
|
if (ps1 < dref)
|
36 |
|
|
{
|
37 |
|
|
vec[0] = coord[x(numb)] - coord[x(j1)] ;
|
38 |
|
|
vec[1] = coord[y(numb)] - coord[y(j1)] ;
|
39 |
|
|
vec[2] = coord[z(numb)] - coord[z(j1)] ;
|
40 |
|
|
ps2 = PROSCA(vn,vec) ;
|
41 |
|
|
if (ps2 < dref)
|
42 |
|
|
{
|
43 |
|
|
vec[0] = coord[x(numc)] - coord[x(j1)] ;
|
44 |
|
|
vec[1] = coord[y(numc)] - coord[y(j1)] ;
|
45 |
|
|
vec[2] = coord[z(numc)] - coord[z(j1)] ;
|
46 |
|
|
ps3 = PROSCA(vn,vec) ;
|
47 |
|
|
if (ps3 < dref) return(FAUX) ;/* pas d'intersection */
|
48 |
|
|
}
|
49 |
|
|
}
|
50 |
|
|
return(VRAI) ;
|
51 |
|
|
}
|
52 |
|
|
|
53 |
|
|
|
54 |
|
|
|