1 |
/*****************************************************************
|
2 |
|
3 |
eval_mindis_edge_edge.cpp Type:Func
|
4 |
|
5 |
Calcul la distance minimum entre deux edges
|
6 |
|
7 |
Date de creation : 2-2-1999 10 :25 :59
|
8 |
Derniere version : 2-2-1999 10 :25 :59
|
9 |
|
10 |
Vincent FRANCOIS
|
11 |
|
12 |
*****************************************************************/
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
/**************************/
|
19 |
/* include */
|
20 |
#include <stdio.h>
|
21 |
#include <string.h>
|
22 |
#include <math.h>
|
23 |
#include "struct.h"
|
24 |
#include "const.h"
|
25 |
#include "prototype.h"
|
26 |
|
27 |
/**************************/
|
28 |
/* variables globales */
|
29 |
extern struct s_acis *acis;
|
30 |
|
31 |
|
32 |
|
33 |
/**************************/
|
34 |
/* programme principal */
|
35 |
|
36 |
void eval_mindis_edge_edge(struct s_edge *edge1, struct s_edge *edge2,float *dis, float *par)
|
37 |
{
|
38 |
float g0,g1;
|
39 |
int ok;
|
40 |
float tm,eps,td,ta,lt,ttm,ttd,tta,ltt;
|
41 |
float t1,t2,tt1,tt2;
|
42 |
|
43 |
|
44 |
td=edge1->t1;
|
45 |
ta=edge1->t1+edge1->t2;
|
46 |
ttd=edge2->t1;
|
47 |
tta=edge2->t1+edge2->t2;
|
48 |
|
49 |
MINI(eps,0.0001*(ta-td),0.0001*(tta-ttd));
|
50 |
MAXI(lt,3.*eps,0.0001*(ta-td));
|
51 |
MAXI(ltt,3.*eps,0.0001*(tta-ttd));
|
52 |
ok=0;
|
53 |
do
|
54 |
{
|
55 |
tm=(td+ta)/2.;
|
56 |
ttm=(ttd+tta)/2.;
|
57 |
t1=tm-eps;
|
58 |
t2=tm+eps;
|
59 |
tt1=ttm-eps;
|
60 |
tt2=ttm+eps;
|
61 |
g0=eval_dis_edge_edge(edge1,t1,edge2,ttm,FONCTION);
|
62 |
g1=eval_dis_edge_edge(edge1,t2,edge2,ttm,FONCTION);
|
63 |
if (g0<g1) ta=t2;
|
64 |
else td=t1;
|
65 |
g0=eval_dis_edge_edge(edge1,tm,edge2,tt1,FONCTION);
|
66 |
g1=eval_dis_edge_edge(edge1,tm,edge2,tt2,FONCTION);
|
67 |
if (g0<g1) tta=tt2;
|
68 |
else ttd=tt1;
|
69 |
if ((ta-td<lt)&&(tta-ttd<ltt)) ok=1;
|
70 |
}
|
71 |
while (ok==0);
|
72 |
par[0]=(ta+td)/2.;
|
73 |
par[1]=(tta+ttd)/2.;
|
74 |
*dis=(float)sqrt((double)eval_dis_edge_edge(edge1,par[0],edge2,par[1],FONCTION));
|
75 |
}
|