AP_Math: AP_GeodesicGrid: make data static

That gives the change of storing that data in flash storage in some
architectures. That doesn't happen yet though, some extra changes are required
for that to happen.
This commit is contained in:
Gustavo Jose de Sousa 2016-04-20 18:16:31 -03:00 committed by Lucas De Marchi
parent fd2428db34
commit 77223a7fcb
2 changed files with 75 additions and 77 deletions

View File

@ -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

View File

@ -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.