Skip to content

Commit 33dd65c

Browse files
committed
FEAT: start to ion->neu grid matchup
1 parent d491d43 commit 33dd65c

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

src/grid_match.cpp

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright 2025, the Aether Development Team (see doc/dev_team.md for members)
2+
// Full license can be found in License.md
3+
4+
#include "aether.h"
5+
6+
bool grid_match(Grid gGrid,
7+
Grid mGrid,
8+
Quadtree gQuadtree,
9+
Quadtree mQuadtree) {
10+
11+
// Let's do magnetic to geographic first:
12+
13+
int64_t iX, mnX = mGrid.get_nX();
14+
int64_t iY, mnY = mGrid.get_nY();
15+
int64_t iZ, mnZ = mGrid.get_nZ();
16+
int64_t mGCs = mGrid.get_nGCs();
17+
precision_t lon, lat;
18+
precision_t normX, normY, normZ;
19+
arma_vec norms(3);
20+
int64_t iNode;
21+
22+
for (iX = mGCs; iX < mnX - mGCs; iX++) {
23+
for (iY = mGCs; iY < mnY - mGCs; iY++) {
24+
for (iZ = mGCs; iZ < mnZ - mGCs; iZ++) {
25+
lon = mGrid.geoLon_scgc(iX, iY, iZ);
26+
lat = mGrid.geoLat_scgc(iX, iY, iZ);
27+
if (gGrid.iGridShape_ == gGrid.iSphere_) {
28+
norms(0) = lon / cPI;
29+
norms(1) = lat / cPI;
30+
norms(2) = 0.0;
31+
iNode = gQuadtree.find_point(norms);
32+
} else {
33+
norms = sphere_to_cube(lon, lat);
34+
iNode = gQuadtree.find_point(norms);
35+
}
36+
std::cout << "lon, lat, node: " << lon*cRtoD << " "
37+
<< lat*cRtoD << " "
38+
<< norms(0) << " "
39+
<< norms(1) << " "
40+
<< norms(2) << " "
41+
<< iNode << "\n";
42+
}
43+
}
44+
}
45+
return true;
46+
}

0 commit comments

Comments
 (0)