#include "test_cxc.h"
static void test_latcxlatc(double lon_a, double lat_a, double lon_b, double lat_b,
double lon_c, double lat_c, double lon_d, double lat_d,
double lon_ref_p, double lat_ref_p,
double lon_ref_q, double lat_ref_q, int ref_ret_val);
unsigned const p_between_ab = 1 << 0;
unsigned const q_between_ab = 1 << 1;
unsigned const p_between_cd = 1 << 2;
unsigned const q_between_cd = 1 << 3;
unsigned const circles_are_identically = 1 << 4;
double lon_middle_ab, lat_middle_ab, lon_middle_cd, lat_middle_cd;
for (int i = 0; i < 2; ++i) {
double lon_coords[2][2] = {{-10, 5}, {-5, 10}};
test_latcxlatc(lon_coords[i][0], 30,
lon_coords[i][1], 30,
lon_coords[i^1][0], 30,
lon_coords[i^1][1], 30,
-5, 30,
5, 30,
p_between_ab + p_between_cd + q_between_ab + q_between_cd +
circles_are_identically);
}
for (int i = 0; i < 2; ++i) {
double lon_coords[2][2] = {{20, 25}, {30, 10}};
test_latcxlatc(lon_coords[i][0], -15,
lon_coords[i][1], -15,
lon_coords[i^1][0], -15,
lon_coords[i^1][1], -15,
20, -15,
25, -15,
p_between_ab + p_between_cd + q_between_ab + q_between_cd +
circles_are_identically);
}
for (int i = 0; i < 2; ++i) {
double lon_coords[2][2] = {{-80, -70}, {20, 30}};
&lon_middle_ab, &lat_middle_ab);
&lon_middle_cd, &lat_middle_cd);
test_latcxlatc(lon_coords[i][0], 10,
lon_coords[i][1], 10,
lon_coords[i^1][0], 10,
lon_coords[i^1][1], 10,
lon_middle_ab, 10,
lon_middle_cd, 10,
p_between_ab + q_between_cd +
circles_are_identically);
}
for (int i = 0; i < 2; ++i) {
double lat_coords[2] = {0, 5};
test_latcxlatc(20, lat_coords[i],
30, lat_coords[i],
20, lat_coords[i^1],
30, lat_coords[i^1],
-1, -1,
-1, -1,
-1);
test_latcxlatc(-80, lat_coords[i],
-70, lat_coords[i],
20, lat_coords[i^1],
30, lat_coords[i^1],
-1, -1,
-1, -1,
-1);
}
for (int i = 0; i < 2; ++i) {
double lat_coords[2] = {90, -90};
test_latcxlatc( 0, lat_coords[i],
10, lat_coords[i],
180, lat_coords[i],
190, lat_coords[i],
0, lat_coords[i],
0, lat_coords[i^1],
p_between_ab + p_between_cd);
}
for (int i = 0; i < 2; ++i) {
double lat_coords[2] = {90, -90};
test_latcxlatc( 0, lat_coords[i],
10, lat_coords[i],
5, lat_coords[i],
15, lat_coords[i],
0, lat_coords[i],
0, lat_coords[i^1],
p_between_ab + p_between_cd);
}
for (int i = 0; i < 2; ++i) {
double lat_coords[2] = {-10, 10};
test_latcxlatc(45 , lat_coords[i],
45 , lat_coords[i],
90 , lat_coords[i^1],
90 , lat_coords[i^1],
-1 , -1,
-1 , -1,
-1);
}
test_latcxlatc(45, 10,
46, 10,
90, 10,
91, 10,
45.5, 10,
90.5, 10,
p_between_ab + q_between_cd +
circles_are_identically);
test_latcxlatc( 90, 10,
90, 10,
90, 10,
90, 10,
90, 10,
-90, -10,
p_between_ab + p_between_cd);
test_latcxlatc( 0, 10,
0, 10,
-5, 10,
5, 10,
0, 10,
180, 10,
p_between_ab + p_between_cd);
test_latcxlatc(180, 10,
180, 10,
-5, 10,
5, 10,
180, 10,
0, 10,
p_between_ab + q_between_cd);
test_latcxlatc( 90, 10,
90, 10,
-5, 10,
5, 10,
90, 10,
-90, 10,
p_between_ab);
return TEST_EXIT_CODE;
}
static void test_latcxlatc(double lon_a, double lat_a, double lon_b, double lat_b,
double lon_c, double lat_c, double lon_d, double lat_d,
double lon_ref_p, double lat_ref_p,
double lon_ref_q, double lat_ref_q, int ref_ret_val) {
test_cxc(lon_a, lat_a, lon_b, lat_b, lon_c, lat_c, lon_d, lat_d,
lon_ref_p, lat_ref_p, lon_ref_q, lat_ref_q, ref_ret_val);
}
int main(int argc, char **argv)
@ YAC_LAT_CIRCLE_EDGE
latitude circle
static void get_edge_middle_point(struct yac_basic_grid_data *grid, size_t edge_index, double *point)