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

File Contents

# User Rev Content
1 1 /*****************************************************************
2    
3     m2d_int_seg_seg.c Type:Func
4    
5     Intersection entre segment AB et le sement MN
6    
7     Date de creation : Wed Feb 19 14:36:10 1997
8    
9     Derniere version : Thu May 8 10:09:04 1997
10    
11    
12    
13    
14    
15    
16    
17    
18    
19    
20    
21    
22    
23    
24    
25     Vincent FRANCOIS
26    
27     *****************************************************************/
28    
29    
30    
31    
32    
33     /**************************/
34     /* include */
35     #include <stdio.h>
36     #include <math.h>
37     #include <math.h>
38     #include "const.h"
39     #include "struct.h"
40     #include "memoire.h"
41     #include "prototype.h"
42    
43    
44     /**************************/
45     /* variables globales */
46     extern struct environnement env;
47     extern struct s_mesh *mesh;
48    
49     /**************************/
50     /* programme principal */
51     #define VRAI 1
52     #define FAUX 0
53    
54    
55    
56     int m3d_int_seg_seg(int a,int b,int m,int n)
57     {
58     struct s_noeud *noa,*nob,*nom,*non;
59     float ab[3],nm[3],am[3],an[3],det,sol1,sol2,tmp;
60     float eps,eps2;
61     int equation[4],ne1,ne2;
62    
63    
64     noa=ADRESSE(a,noeud,mesh->);
65     nob=ADRESSE(b,noeud,mesh->);
66     nom=ADRESSE(m,noeud,mesh->);
67     non=ADRESSE(n,noeud,mesh->);
68     VEC(ab,noa,nob);
69     VEC(nm,non,nom);
70     VEC(am,noa,nom);
71     equation[0]=1; /* etat de l'equation 0 */
72     equation[1]=1;
73     equation[2]=1;
74     equation[3]=3; /* cette variable comporte le bilan du nombre d'equation */
75     eps2=PSCA(ab,ab);
76     eps=(float)sqrt((double)eps2);
77     eps=eps*0.0001;
78     eps2=eps2*0.0001;
79     /* recherche du nombre d'equation -> inter franche ou para ou confondu */
80     if ( (EGAL(ab[0],0,eps)) && (EGAL(nm[0],0,eps)) )
81     if (EGAL(am[0],0,eps)) equation[0]=0; else return(FAUX);
82     if ( (EGAL(ab[1],0,eps)) && (EGAL(nm[1],0,eps)) )
83     if (EGAL(am[1],0,eps)) equation[1]=0; else return(FAUX);
84     if ( (EGAL(ab[2],0,eps)) && (EGAL(nm[2],0,eps)) )
85     if (EGAL(am[2],0,eps)) equation[2]=0; else return(FAUX);
86     equation[3]=equation[0]+equation[1]+equation[2];
87     if (equation[3]==3)
88     {
89     det=DETER(ab[0],nm[0],ab[1],nm[1]);
90     if ((float)fabs((double)det)>eps2)
91     {
92     det=1/det;
93     sol1=det*DETER(am[0],nm[0],am[1],nm[1]);
94     sol2=det*DETER(ab[0],am[0],ab[1],am[1]);
95     if ( (float)fabs((double)(sol1*ab[2]-sol2*nm[2]-am[2]))>eps2) return(FAUX);
96     return(m2d_ex_sol(sol1,sol2,1));
97     }
98     else
99     {
100     equation[0]=0;
101     equation[3]=2;
102     /* on verifie la compatibilite des deux equations dont le det est nul*/
103     if (ab[0]!=0) tmp=ab[1]*am[0]/ab[0]; else tmp=nm[1]*am[0]/nm[0];
104     if (!(EGAL(tmp,am[1],eps))) return(FAUX);
105     }
106     }
107     if (equation[3]==2)
108     {
109     /* on repere les equations qui existent */
110     if (equation[0]!=0)
111     {
112     ne1=0;
113     if (equation[1]!=0) ne2=1; else ne2=2;
114     }
115     else
116     {
117     ne1=1;
118     ne2=2;
119     }
120    
121     det=DETER(ab[ne1],nm[ne1],ab[ne2],nm[ne2]);
122     if ((float)fabs((double)det)>eps2)
123     {
124     det=1/det;
125     sol1=det*DETER(am[ne1],nm[ne1],am[ne2],nm[ne2]);
126     sol2=det*DETER(ab[ne1],am[ne1],ab[ne2],am[ne2]);
127     return(m2d_ex_sol(sol1,sol2,1));
128     }
129     else
130     {
131     equation[ne1]=0;
132     equation[3]=1;
133     /* on verifie la compatibilite des deux equations dont le det est nul */
134     if (ab[ne1]!=0) tmp=ab[ne2]*am[ne1]/ab[ne1]; else tmp=nm[ne2]*am[ne1]/nm[ne1];
135     if (!(EGAL(tmp,am[ne2],eps))) return(FAUX);
136     }
137    
138     }
139     if (equation[3]==1)
140     {
141     /* on repere l' equation qui existe */
142     if (equation[0]!=0) ne1=0; else
143     if (equation[1]!=0) ne1=1; else ne1=2;
144     VEC(an,noa,non);
145     tmp=1/ab[ne1];
146     sol1=am[ne1]*tmp;
147     sol2=an[ne1]*tmp;
148     return(m2d_ex_sol(sol1,sol2,2));
149     }
150     return(0);
151     }