Mmg
Simplicial remeshers (mesh adaptation, isovalue discretization, lagrangian movement)
cenrad_2d.c
Go to the documentation of this file.
1/* =============================================================================
2** This file is part of the mmg software package for the tetrahedral
3** mesh modification.
4** Copyright (c) Bx INP/CNRS/Inria/UBordeaux/UPMC, 2004-
5**
6** mmg is free software: you can redistribute it and/or modify it
7** under the terms of the GNU Lesser General Public License as published
8** by the Free Software Foundation, either version 3 of the License, or
9** (at your option) any later version.
10**
11** mmg is distributed in the hope that it will be useful, but WITHOUT
12** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13** FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14** License for more details.
15**
16** You should have received a copy of the GNU Lesser General Public
17** License and of the GNU General Public License along with mmg (in
18** files COPYING.LESSER and COPYING). If not, see
19** <http://www.gnu.org/licenses/>. Please read their terms carefully and
20** use this copy of the mmg distribution only if you accept them.
21** =============================================================================
22*/
31#include "libmmg2d_private.h"
42int MMG2D_cenrad_iso(MMG5_pMesh mesh,double *ct,double *c,double *rad) {
43 double dd,ux,uy,n1[2],n2[2],*c1,*c2,*c3,pl1,pl2;
44 double cc1,cc2;
45
46 c1 = &ct[0];
47 c2 = &ct[2];
48 c3 = &ct[4];
49
50 ux = c3[0] - c1[0];
51 uy = c3[1] - c1[1];
52
53 dd = 1.0 / sqrt(ux*ux + uy*uy);
54 n1[0] = ux*dd;
55 n1[1] = uy*dd;
56
57 /* droite passant par le milieu de c1c3 */
58 pl1 = 0.5*(n1[0]*(c3[0]+c1[0])+ n1[1]*(c3[1]+c1[1])) ;
59
60 ux = c3[0] - c2[0];
61 uy = c3[1] - c2[1];
62
63 dd = 1.0 / sqrt(ux*ux + uy*uy);
64 n2[0] = ux*dd;
65 n2[1] = uy*dd;
66 pl2 = 0.5*(n2[0]*(c3[0]+c2[0])+ n2[1]*(c3[1]+c2[1]));
67
68 /* center = intersection of 3 mediatrice */
69 dd = n1[0]*n2[1] - n2[0]*n1[1] ;
70 if(fabs((dd))<1e-12) return 0;
71 dd = 1./dd;
72
73 cc1 = n2[1]*pl1 - n1[1]*pl2;
74 cc2 = -n2[0]*pl1 + n1[0]*pl2;
75
76 c[0] = dd * cc1;
77 c[1] = dd * cc2;
78
79 /* radius (squared) */
80 *rad = (c[0] - c1[0]) * (c[0] - c1[0]) \
81 + (c[1] - c1[1]) * (c[1] - c1[1]);
82
83 /* printf("check rad %e -- %e %e\n",*rad, (c[0] - c2[0]) * (c[0] - c2[0]) \ */
84 /* + (c[1] - c2[1]) * (c[1] - c2[1]), (c[0] - c3[0]) * (c[0] - c3[0]) \ */
85 /* + (c[1] - c3[1]) * (c[1] - c3[1])); */
86
87 return 1;
88}
MMG5_pMesh * mesh
int MMG2D_cenrad_iso(MMG5_pMesh mesh, double *ct, double *c, double *rad)
Definition: cenrad_2d.c:42
MMG mesh structure.
Definition: libmmgtypes.h:605