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

File Contents

# Content
1 /*****************************************************************
2
3 eval_distance.c Type:Func
4
5 calcul d'une distance sur une surface
6
7 Date de creation : Thu Feb 13 12:01:14 1997
8
9 Derniere version : Wed May 7 12:17:04 1997
10
11
12
13
14
15
16
17
18 Vincent FRANCOIS
19
20 *****************************************************************/
21
22
23
24
25
26 /**************************/
27 /* include */
28 #include <stdio.h>
29 #include <string.h>
30 #include <math.h>
31 #include "const.h"
32 #include "memoire.h"
33 #include "struct.h"
34 #include "prototype.h"
35
36 /**************************/
37 /* variables globales */
38 extern struct s_acis *acis;
39 extern struct environnment env;
40 extern struct s_mesh *mesh;
41
42
43
44 /**************************/
45 /* programme principal */
46
47 float eval_distance(struct s_face *face,float u1,float v1,float u2,float v2,float du,float dv)
48 {
49 struct s_plane *plane;
50 float up,vp,x,y,z,long_par,long_reel;
51 int i;
52 float ti,tii,t,u,v,e,f,g,terme1,terme2,terme3;
53
54
55 plane=NULL;
56 if (strcmp(acis->type_entite[face->surface],"plane-surface")==0)
57 plane=(struct s_plane *)acis->entity[face->surface];
58
59 long_par=(u2-u1)*(u2-u1)+(v2-v1)*(v2-v1);
60 long_par=(float)sqrt((double)long_par);
61 if (plane!=NULL) return(long_par);
62
63 up=u2-u1;
64 vp=v2-v1;
65 long_reel=0.;
66 for (i=0;i<PAS;i++)
67 {
68 ti=i*1./PAS;
69 tii=(i+1)*1./PAS;
70
71 t=0.8872983345*ti+0.1127016654*tii;
72 u=u1+t*(u2-u1);
73 v=v1+t*(v2-v1);
74 e=eval_face(face,&u,&v,E,&x,&y,&z,du,dv);
75 f=eval_face(face,&u,&v,F,&x,&y,&z,du,dv);
76 g=eval_face(face,&u,&v,G,&x,&y,&z,du,dv);
77 terme1=e*up*up+2*f*up*vp+g*vp*vp;
78 terme1=(float)sqrt((double)terme1);
79
80 t=0.5*ti+0.5*tii;
81 u=u1+t*(u2-u1);
82 v=v1+t*(v2-v1);
83 e=eval_face(face,&u,&v,E,&x,&y,&z,du,dv);
84 f=eval_face(face,&u,&v,F,&x,&y,&z,du,dv);
85 g=eval_face(face,&u,&v,G,&x,&y,&z,du,dv);
86 terme2=e*up*up+2*f*up*vp+g*vp*vp;
87 terme2=(float)sqrt((double)terme2);
88
89 t=0.8872983345*tii+0.1127016654*ti;
90 u=u1+t*(u2-u1);
91 v=v1+t*(v2-v1);
92 e=eval_face(face,&u,&v,E,&x,&y,&z,du,dv);
93 f=eval_face(face,&u,&v,F,&x,&y,&z,du,dv);
94 g=eval_face(face,&u,&v,G,&x,&y,&z,du,dv);
95 terme3=e*up*up+2*f*up*vp+g*vp*vp;
96 terme3=(float)sqrt((double)terme3);
97
98 long_reel=long_reel+0.55555556*terme1+0.8888888889*terme2+0.5555556*terme3;
99 }
100 long_reel=long_reel*0.5/PAS;
101 return(long_reel);
102
103
104 }