AP_Math: test_geodesic_grid: test also non-centroid vectors

This commit is contained in:
Gustavo Jose de Sousa 2016-04-20 13:26:42 -03:00 committed by Lucas De Marchi
parent 8e8ab3af96
commit b34c04a4f9

View File

@ -175,8 +175,8 @@ INSTANTIATE_TEST_CASE_P(IcosahedronVertices,
GeodesicGridTest, GeodesicGridTest,
::testing::ValuesIn(icosahedron_vertices)); ::testing::ValuesIn(icosahedron_vertices));
/* Generate vectors that pass through the centroid of each section's triangle. */ /* Generate vectors for each triangle */
static std::vector<TestParam> centroid_vectors = []() static std::vector<TestParam> general_vectors = []()
{ {
std::vector<TestParam> params; std::vector<TestParam> params;
for (int i = 0; i < 20 * AP_GeodesicGrid::NUM_SUBTRIANGLES; i++) { for (int i = 0; i < 20 * AP_GeodesicGrid::NUM_SUBTRIANGLES; i++) {
@ -184,14 +184,32 @@ static std::vector<TestParam> centroid_vectors = []()
TestParam p; TestParam p;
section_triangle(i, a, b, c); section_triangle(i, a, b, c);
p.section = i; p.section = i;
p.v = (a + b + c) / 3;
/* Vector that crosses the centroid */
p.v = a + b + c;
params.push_back(p);
/* Vectors that cross the triangle close to the edges */
p.v = a + b + c * 0.001f;
params.push_back(p);
p.v = a + b * 0.001f + c;
params.push_back(p);
p.v = a * 0.001f + b + c;
params.push_back(p);
/* Vectors that cross the triangle close to the vertices */
p.v = a + b * 0.001 + c * 0.001f;
params.push_back(p);
p.v = a * 0.001f + b + c * 0.001f;
params.push_back(p);
p.v = a * 0.001f + b * 0.001f + c;
params.push_back(p); params.push_back(p);
} }
return params; return params;
}(); }();
INSTANTIATE_TEST_CASE_P(MidVectors, INSTANTIATE_TEST_CASE_P(GeneralVectors,
GeodesicGridTest, GeodesicGridTest,
::testing::ValuesIn(centroid_vectors)); ::testing::ValuesIn(general_vectors));
/* Other hardcoded vectors, so we don't rely just on the centroid vectors /* Other hardcoded vectors, so we don't rely just on the centroid vectors
* (which are dependent on how the triangles are *defined by the * (which are dependent on how the triangles are *defined by the