Changeset 2505 for XIOS3/branches/xios-3.0-beta/extern/remap/src/polyg.cpp
- Timestamp:
- 05/23/23 16:20:10 (14 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS3/branches/xios-3.0-beta/extern/remap/src/polyg.cpp
r2282 r2505 18 18 (because computing intersection area requires both polygons to have same orientation) 19 19 */ 20 20 21 void orient(int N, Coord *vertex, Coord *edge, double *d, const Coord &g) 21 22 { … … 24 25 Coord vertical = crossprod(ga, gb); 25 26 if (N > 2 && scalarprod(g, vertical) < 0) // (GAxGB).G 26 { 27 for (int i = 0; i < N/2; i++) 28 swap(vertex[i], vertex[N-1-i]); 29 30 for (int i = 0; i < (N-1)/2; i++) 31 { 32 swap(edge[N-2-i], edge[i]); 33 swap(d[i], d[N-2-i]); 34 } 35 } 36 } 37 27 switchOrientation(N, vertex, edge, d) ; 28 29 } 30 31 void switchOrientation(int N, Coord *vertex, Coord *edge, double *d) 32 { 33 for (int i = 0; i < N/2; i++) swap(vertex[i], vertex[N-1-i]); 34 35 for (int i = 0; i < (N-1)/2; i++) 36 { 37 swap(edge[N-2-i], edge[i]); 38 swap(d[i], d[N-2-i]); 39 } 40 41 } 38 42 39 43 void normals(Coord *x, int n, Coord *a) … … 94 98 { 95 99 return proj(gc_normalintegral(x, n)); 100 //return new_barycentre(x,n) ; 96 101 } 97 102 else if (n == 0) return ORIGIN; 98 103 else if (n == 2) return midpoint(x[0], x[1]); 99 104 else if (n == 1) return x[0]; 100 101 error_exit( "Missing return in : Coord exact_barycentre(const Coord *x, int n)" ); 102 return ORIGIN; 103 } 105 } 106 107 /* other methode to compute barycenter of spherical polygon 108 for a spherical polygon, the moment is half the sum of (a x b) / ||a x b|| * (angle between a and b) 109 for each pair of consecutive vertices a,b. 110 */ 111 112 Coord new_barycentre(const Coord *x, int n) 113 { 114 if (n >= 3) 115 { 116 Coord sum=ORIGIN ; 117 for (int i = 0; i < n; i++) 118 { 119 sum=sum+crossprod(x[i],x[(i+1)%n])*(1./norm(crossprod(x[i],x[(i+1)%n]))*2.*atan2(norm(x[i]-x[(i+1)%n]),norm(x[i]+x[(i+1)%n]))) ; 120 } 121 return proj(sum) ; 122 } 123 else if (n == 0) return ORIGIN; 124 else if (n == 2) return midpoint(x[0], x[1]); 125 else if (n == 1) return x[0]; 126 } 127 128 104 129 105 130 Coord sc_gc_moon_normalintegral(Coord a, Coord b, Coord pole)
Note: See TracChangeset
for help on using the changeset viewer.