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

File Contents

# Content
1 /*****************************************************************
2
3 m3d_angle_front.cpp Type:func
4
5 Calcul l'angle entre deux triangles de front voisins
6
7 Date de creation : 8-3-1999 15 :56 :44
8 Derniere version : 8-3-1999 15 :56 :44
9
10 Vincent FRANCOIS
11
12 *****************************************************************/
13
14
15
16
17
18 /**************************/
19 /* include */
20 #include <stdio.h>
21 #include <string.h>
22 #include <stdlib.h>
23 #include <math.h>
24 #include "const.h"
25 #include "memoire.h"
26 #include "struct.h"
27 #include "prototype.h"
28
29 /**************************/
30 /* variables globales */
31 extern struct environnement env;
32 extern struct s_mesh *mesh;
33
34
35
36 /**************************/
37 /* programme principal */
38
39 float m3d_angle_front(struct s_front3d *ft1, struct s_front3d *ft2)
40 {
41 struct s_noeud *no1,*no2,*no3,*no4,*no5,*no6,*noa,*nob,*noc,*nod;
42 float n1n2[4],n1n3[4],n1[4],n[4],bc[4];
43 float n2[4];
44 float nbnd[4],milieu[4];
45 float angle;
46 float ps;
47
48 no1=ADRESSE(ft1->n1,noeud,mesh->);
49 no2=ADRESSE(ft1->n2,noeud,mesh->);
50 no3=ADRESSE(ft1->n3,noeud,mesh->);
51 no4=ADRESSE(ft2->n1,noeud,mesh->);
52 no5=ADRESSE(ft2->n2,noeud,mesh->);
53 no6=ADRESSE(ft2->n3,noeud,mesh->);
54
55
56 if (!(no1==no4))
57 if (!(no1==no5))
58 if (!(no1==no6))
59 {
60 noa=no1;
61 nob=no2;
62 noc=no3;
63 }
64 if (!(no2==no4))
65 if (!(no2==no5))
66 if (!(no2==no6))
67 {
68 noa=no2;
69 nob=no1;
70 noc=no3;
71 }
72 if (!(no3==no4))
73 if (!(no3==no5))
74 if (!(no3==no6))
75 {
76 noa=no3;
77 nob=no1;
78 noc=no2;
79 }
80 if (!(no4==nob))
81 if (!(no4==noc))
82 nod=no4;
83 if (!(no5==nob))
84 if (!(no5==noc))
85 nod=no5;
86 if (!(no6==nob))
87 if (!(no6==noc))
88 nod=no6;
89
90 milieu[0]=0.5*(nob->x+noc->x);
91 milieu[1]=0.5*(nob->y+noc->y);
92 milieu[2]=0.5*(nob->z+noc->z);
93
94 VEC(bc,nob,noc);
95 NORME(bc);
96
97 n1[0]=noa->x-milieu[0];
98 n1[1]=noa->y-milieu[1];
99 n1[2]=noa->z-milieu[2];
100 NORME(n1);
101 PVEC(n,bc,n1);
102 PVEC(n1,n,bc);
103 NORME(n1);
104
105 n2[0]=nod->x-milieu[0];
106 n2[1]=nod->y-milieu[1];
107 n2[2]=nod->z-milieu[2];
108 NORME(n2);
109 PVEC(n,bc,n2);
110 PVEC(n2,n,bc);
111 NORME(n2);
112
113
114 ps=PSCA(n1,n2);
115 if (ps>1.) ps=1.;
116 if (ps<-1.) ps=-1.;
117 angle=(float)acos((double)ps);
118 VEC(n1n2,no1,no2);
119 VEC(n1n3,no1,no3);
120 PVEC(n,n1n2,n1n3);
121 VEC(nbnd,nob,nod);
122 NORME(n);
123 NORME(nbnd);
124 if (PSCA(n,nbnd)<0.0001) angle=2*PI-angle ;
125 return(angle);
126 }