1 |
|
1 |
/*****************************************************************
|
2 |
|
|
|
3 |
|
|
geo_ind_point_edge.cpp Type:Func
|
4 |
|
|
|
5 |
|
|
Calcul de l indice d un point sur une edge
|
6 |
|
|
|
7 |
|
|
Date de creation : 19-9-1997 18 :27 :20
|
8 |
|
|
Derniere version : 19-9-1997 18 :27 :20
|
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 |
|
|
|
31 |
|
|
/**************************/
|
32 |
|
|
/* variables globales */
|
33 |
|
|
extern struct s_acis *acis;
|
34 |
|
|
|
35 |
|
|
|
36 |
|
|
/**************************/
|
37 |
|
|
/* programme principal */
|
38 |
|
|
|
39 |
|
|
float geo_ind_point_edge(struct s_edge *edge,struct s_noeud *no)
|
40 |
|
|
{
|
41 |
|
|
struct s_straight *straight;
|
42 |
|
|
struct s_ellipse *ellipse;
|
43 |
|
|
float xtmp,ytmp,ztmp,tt,vec[4],t[4];
|
44 |
|
|
|
45 |
|
|
if (strcmp(acis->type_entite[edge->curve],"straight-curve")==0)
|
46 |
|
|
{
|
47 |
|
|
straight=(struct s_straight *)acis->entity[edge->curve];
|
48 |
|
|
t[0]=no->x-straight->param->root[0];
|
49 |
|
|
t[1]=no->y-straight->param->root[1];
|
50 |
|
|
t[2]=no->z-straight->param->root[2];
|
51 |
|
|
PVEC(vec,t,straight->param->dir);
|
52 |
|
|
NORME(vec);
|
53 |
|
|
if (EGAL(vec[3],0.,0.0001))
|
54 |
|
|
{
|
55 |
|
|
if (!(EGAL(straight->param->dir[0],0.0,0.0001))) tt=t[0]/straight->param->dir[0];
|
56 |
|
|
else if (!(EGAL(straight->param->dir[1],0.0,0.0001))) tt=t[1]/straight->param->dir[1];
|
57 |
|
|
else tt=t[2]/straight->param->dir[2];
|
58 |
|
|
}
|
59 |
|
|
return(tt);
|
60 |
|
|
}
|
61 |
|
|
if (strcmp(acis->type_entite[edge->curve],"ellipse-curve")==0)
|
62 |
|
|
{
|
63 |
|
|
ellipse=(struct s_ellipse *)acis->entity[edge->curve];
|
64 |
|
|
xtmp=ellipse->param->u[0]*(no->x-ellipse->param->centre[0])+ellipse->param->u[1]*(no->y-ellipse->param->centre[1])+ellipse->param->u[2]*(no->z-ellipse->param->centre[2]);
|
65 |
|
|
ytmp=ellipse->param->v[0]*(no->x-ellipse->param->centre[0])+ellipse->param->v[1]*(no->y-ellipse->param->centre[1])+ellipse->param->v[2]*(no->z-ellipse->param->centre[2]);
|
66 |
|
|
ztmp=ellipse->param->w[0]*(no->x-ellipse->param->centre[0])+ellipse->param->w[1]*(no->y-ellipse->param->centre[1])+ellipse->param->w[2]*(no->z-ellipse->param->centre[2]);
|
67 |
|
|
t[0]=xtmp/ellipse->param->a;
|
68 |
|
|
t[1]=ytmp/ellipse->param->b;
|
69 |
|
|
t[2]=t[0]*t[0]+t[1]*t[1];
|
70 |
|
|
if (EGAL(ztmp,0.0,0.0001))
|
71 |
|
|
if (EGAL(t[2],1.,0.0001))
|
72 |
|
|
{
|
73 |
|
|
if (t[0]<(-1.)) t[0]=(-1);
|
74 |
|
|
if (t[0]>1.) t[0]=1;
|
75 |
|
|
tt=(float)acos((double)t[0]);
|
76 |
|
|
if (t[1]<0.) tt=(-tt);
|
77 |
|
|
if (tt<0.) tt=tt+2*PI;
|
78 |
|
|
if (tt<edge->t1) tt=tt+2*PI;
|
79 |
|
|
}
|
80 |
|
|
return(tt);
|
81 |
|
|
}
|
82 |
|
|
return(tt);
|
83 |
|
|
}
|