Changeset 1328 for XIOS/dev/branch_openmp/extern/remap/src/polyg.cpp
- Timestamp:
- 11/15/17 12:14:34 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/branch_openmp/extern/remap/src/polyg.cpp
r1289 r1328 7 7 8 8 #include "polyg.hpp" 9 #include <stdio.h>10 9 11 10 namespace sphereRemap { … … 46 45 Coord barycentre(const Coord *x, int n) 47 46 { 48 49 47 if (n == 0) return ORIGIN; 50 48 Coord bc = ORIGIN; 51 49 for (int i = 0; i < n; i++) 52 {53 50 bc = bc + x[i]; 54 }55 51 /* both distances can be equal down to roundoff when norm(bc) < mashineepsilon 56 52 which can occur when weighted with tiny area */ 57 58 59 //assert(squaredist(bc, proj(bc)) <= squaredist(bc, proj(bc * (-1.0)))); 53 54 assert(squaredist(bc, proj(bc)) <= squaredist(bc, proj(bc * (-1.0)))); 55 //if (squaredist(bc, proj(bc)) > squaredist(bc, proj(bc * (-1.0)))) return proj(bc * (-1.0)); 60 56 61 57 return proj(bc); … … 165 161 { 166 162 if (N < 3) 167 163 return 0; /* polygons with less than three vertices have zero area */ 168 164 Coord t[3]; 169 165 t[0] = barycentre(x, N); … … 177 173 t[1] = x[i]; 178 174 t[2] = x[ii]; 179 double sc=scalarprod(crossprod(t[1] - t[0], t[2] - t[0]), t[0]) ;175 double sc=scalarprod(crossprod(t[1] - t[0], t[2] - t[0]), t[0]) ; 180 176 assert(sc >= -1e-10); // Error: tri a l'env (wrong orientation) 181 177 double area_gc = triarea(t[0], t[1], t[2]); 182 //if(area_gc<=0) printf("area_gc = %e\n", area_gc);183 178 double area_sc_gc_moon = 0; 184 179 if (d[i]) /* handle small circle case */ … … 188 183 char sgl = (mext > 0) ? -1 : 1; 189 184 area_sc_gc_moon = sgl * alun(arcdist(t[1], t[2]), fabs(scalarprod(t[1], pole))); 190 //if(area_sc_gc_moon<=0) printf("area_sc_gc_moon = %e\n", area_sc_gc_moon);191 185 gg_exact = gg_exact + sc_gc_moon_normalintegral(t[1], t[2], pole); 192 186 } 193 187 area += area_gc + area_sc_gc_moon; /* for "spherical circle segment" sum triangular part (at) and "small moon" and => account for small circle */ 194 188 g[i] = barycentre(t, 3) * (area_gc + area_sc_gc_moon); 195 //printf("g[%d] = (%e,%e,%e) * (%e+%e) = (%e,%e,%e) norm = %e\n", i, barycentre(t, 3).x, barycentre(t, 3).y, barycentre(t, 3).z, area_gc, area_sc_gc_moon, g[i].x, g[i].y, g[i].z, norm(g[i]));196 189 } 197 190 gg = barycentre(g, N);
Note: See TracChangeset
for help on using the changeset viewer.