Commit d14044d4 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Added function set_cell_corners_xyz

parent 416944c3
......@@ -316,7 +316,6 @@ compute_child_from_bounds(CellIndex *cellindex2, long ncells2, double *grid_cent
size_t *nbr_addr = &knnWeights.m_addr[0];
int ncorner = 3;
double corner_coordinates[3];
double center_point_xyz[3];
double cell_corners_xyz[12];
double cell_corners_plane_projection[8];
......@@ -328,22 +327,8 @@ compute_child_from_bounds(CellIndex *cellindex2, long ncells2, double *grid_cent
{
for (int k = 0; k < MAX_CHILDS; ++k) child2[cell_no2 * MAX_CHILDS + k] = -1;
for (int corner_no = 0; corner_no < ncorner; corner_no++)
{
// Conversion of corner spherical coordinates to Cartesian coordinates.
gcLLtoXYZ(grid_corner_lon2[cell_no2 * ncorner + corner_no], grid_corner_lat2[cell_no2 * ncorner + corner_no],
corner_coordinates);
// The components of the result vector are appended to the list of cell corner coordinates.
const auto off = corner_no * 3;
cell_corners_xyz[off + 0] = corner_coordinates[0];
cell_corners_xyz[off + 1] = corner_coordinates[1];
cell_corners_xyz[off + 2] = corner_coordinates[2];
}
cell_corners_xyz[ncorner * 3 + 0] = cell_corners_xyz[0];
cell_corners_xyz[ncorner * 3 + 1] = cell_corners_xyz[1];
cell_corners_xyz[ncorner * 3 + 2] = cell_corners_xyz[2];
set_cell_corners_xyz(ncorner, &grid_corner_lon2[cell_no2 * ncorner], &grid_corner_lat2[cell_no2 * ncorner], cell_corners_xyz);
const auto coordinate_to_ignore = find_coordinate_to_ignore(cell_corners_xyz);
bool invert_result = false;
......
......@@ -377,6 +377,25 @@ get_no_unique_center_points(size_t gridsize, size_t nx, const Varray<double> &ce
return no_unique_center_points;
}
void set_cell_corners_xyz(int ncorner, const double *cell_corners_lon, const double *cell_corners_lat, double *cell_corners_xyz)
{
double corner_coordinates[3];
for (int corner_no = 0; corner_no < ncorner; corner_no++)
{
// Conversion of corner spherical coordinates to Cartesian coordinates.
gcLLtoXYZ(cell_corners_lon[corner_no], cell_corners_lat[corner_no], corner_coordinates);
// The components of the result vector are appended to the list of cell corner coordinates.
const auto off = corner_no * 3;
cell_corners_xyz[off + 0] = corner_coordinates[0];
cell_corners_xyz[off + 1] = corner_coordinates[1];
cell_corners_xyz[off + 2] = corner_coordinates[2];
}
cell_corners_xyz[ncorner * 3 + 0] = cell_corners_xyz[0];
cell_corners_xyz[ncorner * 3 + 1] = cell_corners_xyz[1];
cell_corners_xyz[ncorner * 3 + 2] = cell_corners_xyz[2];
}
void set_center_point_plane_projection(int coordinate_to_ignore, const double (&center_point_xyz)[3], double (&center_point_plane_projection)[2])
{
switch (coordinate_to_ignore)
......
......@@ -17,6 +17,7 @@
#ifndef VERIFYGRID_H
#define VERIFYGRID_H
void set_cell_corners_xyz(int ncorner, const double *cell_corners_lon, const double *cell_corners_lat, double *cell_corners_xyz);
void set_center_point_plane_projection(int coordinate_to_ignore, const double (&center_point_xyz)[3], double (&center_point_plane_projection)[2]);
void set_cell_corners_plane_projection(int coordinate_to_ignore, int ncorner, const double *cell_corners_xyz, double *cell_corners_plane_projection);
int find_coordinate_to_ignore(const double *cell_corners_xyz);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment