diff --git a/libraries/AP_Math/AP_GeodesicGrid.cpp b/libraries/AP_Math/AP_GeodesicGrid.cpp index d7786812d4..ff461ff2e9 100644 --- a/libraries/AP_Math/AP_GeodesicGrid.cpp +++ b/libraries/AP_Math/AP_GeodesicGrid.cpp @@ -105,78 +105,78 @@ #include "AP_GeodesicGrid.h" -AP_GeodesicGrid::AP_GeodesicGrid() - : _neighbor_umbrellas{ - {{ 9, 8, 7, 12, 14}, 1, 2, 0, 0, 2}, - {{ 1, 2, 4, 5, 3}, 0, 0, 2, 2, 0}, - {{16, 15, 13, 18, 17}, 2, 2, 0, 2, 1}, - } - , _inverses{ - {{-0.309017f, 0.500000f, 0.190983f}, - { 0.000000f, 0.000000f, -0.618034f}, - {-0.309017f, -0.500000f, 0.190983f}}, - {{-0.190983f, 0.309017f, -0.500000f}, - {-0.500000f, -0.190983f, 0.309017f}, - { 0.309017f, -0.500000f, -0.190983f}}, - {{-0.618034f, 0.000000f, 0.000000f}, - { 0.190983f, -0.309017f, -0.500000f}, - { 0.190983f, -0.309017f, 0.500000f}}, - {{-0.500000f, 0.190983f, -0.309017f}, - { 0.000000f, -0.618034f, 0.000000f}, - { 0.500000f, 0.190983f, -0.309017f}}, - {{-0.190983f, -0.309017f, -0.500000f}, - {-0.190983f, -0.309017f, 0.500000f}, - { 0.618034f, 0.000000f, 0.000000f}}, - {{-0.309017f, -0.500000f, -0.190983f}, - { 0.190983f, 0.309017f, -0.500000f}, - { 0.500000f, -0.190983f, 0.309017f}}, - {{ 0.309017f, -0.500000f, 0.190983f}, - { 0.000000f, 0.000000f, -0.618034f}, - { 0.309017f, 0.500000f, 0.190983f}}, - {{ 0.190983f, -0.309017f, -0.500000f}, - { 0.500000f, 0.190983f, 0.309017f}, - {-0.309017f, 0.500000f, -0.190983f}}, - {{ 0.500000f, -0.190983f, -0.309017f}, - { 0.000000f, 0.618034f, 0.000000f}, - {-0.500000f, -0.190983f, -0.309017f}}, - {{ 0.309017f, 0.500000f, -0.190983f}, - {-0.500000f, 0.190983f, 0.309017f}, - {-0.190983f, -0.309017f, -0.500000f}}, - } - , _mid_inverses{ - {{-0.000000f, 1.000000f, -0.618034f}, - { 0.000000f, -1.000000f, -0.618034f}, - {-0.618034f, 0.000000f, 1.000000f}}, - {{-1.000000f, 0.618034f, -0.000000f}, - {-0.000000f, -1.000000f, 0.618034f}, - { 0.618034f, -0.000000f, -1.000000f}}, - {{-0.618034f, -0.000000f, -1.000000f}, - { 1.000000f, -0.618034f, -0.000000f}, - {-0.618034f, 0.000000f, 1.000000f}}, - {{-1.000000f, -0.618034f, -0.000000f}, - { 1.000000f, -0.618034f, 0.000000f}, - {-0.000000f, 1.000000f, -0.618034f}}, - {{-1.000000f, -0.618034f, 0.000000f}, - { 0.618034f, 0.000000f, 1.000000f}, - { 0.618034f, 0.000000f, -1.000000f}}, - {{-0.618034f, -0.000000f, -1.000000f}, - { 1.000000f, 0.618034f, -0.000000f}, - { 0.000000f, -1.000000f, 0.618034f}}, - {{ 0.000000f, -1.000000f, -0.618034f}, - { 0.000000f, 1.000000f, -0.618034f}, - { 0.618034f, -0.000000f, 1.000000f}}, - {{ 1.000000f, -0.618034f, -0.000000f}, - { 0.000000f, 1.000000f, 0.618034f}, - {-0.618034f, 0.000000f, -1.000000f}}, - {{ 1.000000f, 0.618034f, -0.000000f}, - {-1.000000f, 0.618034f, 0.000000f}, - { 0.000000f, -1.000000f, -0.618034f}}, - {{-0.000000f, 1.000000f, 0.618034f}, - {-1.000000f, -0.618034f, -0.000000f}, - { 0.618034f, 0.000000f, -1.000000f}}, - } -{ -} +const struct AP_GeodesicGrid::neighbor_umbrella +AP_GeodesicGrid::_neighbor_umbrellas[3]{ + {{ 9, 8, 7, 12, 14}, 1, 2, 0, 0, 2}, + {{ 1, 2, 4, 5, 3}, 0, 0, 2, 2, 0}, + {{16, 15, 13, 18, 17}, 2, 2, 0, 2, 1}, +}; + +const Matrix3f AP_GeodesicGrid::_inverses[10]{ + {{-0.309017f, 0.500000f, 0.190983f}, + { 0.000000f, 0.000000f, -0.618034f}, + {-0.309017f, -0.500000f, 0.190983f}}, + {{-0.190983f, 0.309017f, -0.500000f}, + {-0.500000f, -0.190983f, 0.309017f}, + { 0.309017f, -0.500000f, -0.190983f}}, + {{-0.618034f, 0.000000f, 0.000000f}, + { 0.190983f, -0.309017f, -0.500000f}, + { 0.190983f, -0.309017f, 0.500000f}}, + {{-0.500000f, 0.190983f, -0.309017f}, + { 0.000000f, -0.618034f, 0.000000f}, + { 0.500000f, 0.190983f, -0.309017f}}, + {{-0.190983f, -0.309017f, -0.500000f}, + {-0.190983f, -0.309017f, 0.500000f}, + { 0.618034f, 0.000000f, 0.000000f}}, + {{-0.309017f, -0.500000f, -0.190983f}, + { 0.190983f, 0.309017f, -0.500000f}, + { 0.500000f, -0.190983f, 0.309017f}}, + {{ 0.309017f, -0.500000f, 0.190983f}, + { 0.000000f, 0.000000f, -0.618034f}, + { 0.309017f, 0.500000f, 0.190983f}}, + {{ 0.190983f, -0.309017f, -0.500000f}, + { 0.500000f, 0.190983f, 0.309017f}, + {-0.309017f, 0.500000f, -0.190983f}}, + {{ 0.500000f, -0.190983f, -0.309017f}, + { 0.000000f, 0.618034f, 0.000000f}, + {-0.500000f, -0.190983f, -0.309017f}}, + {{ 0.309017f, 0.500000f, -0.190983f}, + {-0.500000f, 0.190983f, 0.309017f}, + {-0.190983f, -0.309017f, -0.500000f}}, +}; + +const Matrix3f AP_GeodesicGrid::_mid_inverses[10]{ + {{-0.000000f, 1.000000f, -0.618034f}, + { 0.000000f, -1.000000f, -0.618034f}, + {-0.618034f, 0.000000f, 1.000000f}}, + {{-1.000000f, 0.618034f, -0.000000f}, + {-0.000000f, -1.000000f, 0.618034f}, + { 0.618034f, -0.000000f, -1.000000f}}, + {{-0.618034f, -0.000000f, -1.000000f}, + { 1.000000f, -0.618034f, -0.000000f}, + {-0.618034f, 0.000000f, 1.000000f}}, + {{-1.000000f, -0.618034f, -0.000000f}, + { 1.000000f, -0.618034f, 0.000000f}, + {-0.000000f, 1.000000f, -0.618034f}}, + {{-1.000000f, -0.618034f, 0.000000f}, + { 0.618034f, 0.000000f, 1.000000f}, + { 0.618034f, 0.000000f, -1.000000f}}, + {{-0.618034f, -0.000000f, -1.000000f}, + { 1.000000f, 0.618034f, -0.000000f}, + { 0.000000f, -1.000000f, 0.618034f}}, + {{ 0.000000f, -1.000000f, -0.618034f}, + { 0.000000f, 1.000000f, -0.618034f}, + { 0.618034f, -0.000000f, 1.000000f}}, + {{ 1.000000f, -0.618034f, -0.000000f}, + { 0.000000f, 1.000000f, 0.618034f}, + {-0.618034f, 0.000000f, -1.000000f}}, + {{ 1.000000f, 0.618034f, -0.000000f}, + {-1.000000f, 0.618034f, 0.000000f}, + { 0.000000f, -1.000000f, -0.618034f}}, + {{-0.000000f, 1.000000f, 0.618034f}, + {-1.000000f, -0.618034f, -0.000000f}, + { 0.618034f, 0.000000f, -1.000000f}}, +}; int AP_GeodesicGrid::section(const Vector3f& v, const bool inclusive) const diff --git a/libraries/AP_Math/AP_GeodesicGrid.h b/libraries/AP_Math/AP_GeodesicGrid.h index feb8e071b3..865888d93f 100644 --- a/libraries/AP_Math/AP_GeodesicGrid.h +++ b/libraries/AP_Math/AP_GeodesicGrid.h @@ -106,8 +106,6 @@ public: */ static const int NUM_SUBTRIANGLES = 4; - AP_GeodesicGrid(); - /** * Find which section is crossed by \p v. * @@ -170,7 +168,7 @@ private: * The i-th matrix is the inverse of the change-of-basis matrix from * natural basis to the basis formed by T_i's vectors. */ - Matrix3f _inverses[10]; + static const Matrix3f _inverses[10]; /** * The inverses of the change-of-basis matrices for the middle triangles. @@ -178,7 +176,7 @@ private: * The i-th matrix is the inverse of the change-of-basis matrix from * natural basis to the basis formed by T_i's middle triangle's vectors. */ - Matrix3f _mid_inverses[10]; + static const Matrix3f _mid_inverses[10]; /** * The representation of the neighbor umbrellas of T_0. @@ -202,7 +200,7 @@ private: * the umbrellas' vertices and components is convertioned to be with * respect to those pairs. */ - struct neighbor_umbrella { + static const struct neighbor_umbrella { /** * The umbrella's components. The value of #components[i] is the * icosahedron triangle index of the i-th component.