APM:Libraries
|
#include <AP_GeodesicGrid.h>
Classes | |
struct | neighbor_umbrella |
Static Public Member Functions | |
static int | section (const Vector3f &v, bool inclusive=false) |
Static Public Attributes | |
static const int | NUM_SUBTRIANGLES = 4 |
Static Private Member Functions | |
static int | _neighbor_umbrella_component (int umbrella_index, int component_idx) |
static int | _from_neighbor_umbrella (int umbrella_index, const Vector3f &v, const Vector3f &u, bool inclusive) |
static int | _triangle_index (const Vector3f &v, bool inclusive) |
static int | _subtriangle_index (const unsigned int triangle_index, const Vector3f &v, bool inclusive) |
Static Private Attributes | |
static const Matrix3f | _inverses [10] |
static const Matrix3f | _mid_inverses [10] |
static const struct AP_GeodesicGrid::neighbor_umbrella | _neighbor_umbrellas [3] |
Friends | |
class | GeodesicGridTest |
AP_GeodesicGrid is a class for working on geodesic sections.
For quick information regarding geodesic grids, see: https://en.wikipedia.org/wiki/Geodesic_grid
The grid is formed by a tessellation of an icosahedron by a factor of 2, i.e., each triangular face of the icosahedron is divided into 4 by splitting each edge into 2 line segments and projecting the vertices to the icosahedron's circumscribed sphere. That will give a total of 80 triangular faces, which are called sections in this context.
A section index is given by the icosahedron's triangle it belongs to and by its index in that triangle. Let i in [0,20) be the icosahedron's triangle index and j in [0,4) be the sub-triangle's (which is the section) index inside the greater triangle. Then the section index is given by s = 4 * i + j .
The icosahedron's triangles are defined by the tuple (T_0, T_1, ..., T_19), where T_i is the i-th triangle. Each triangle is represented with a tuple of the form (a, b, c), where a, b and c are the triangle vertices in the space.
Given the definitions above and the golden ration as g, the triangles must be defined in the following order:
( ((-g, 1, 0), (-1, 0,-g), (-g,-1, 0)), ((-1, 0,-g), (-g,-1, 0), ( 0,-g,-1)), ((-g,-1, 0), ( 0,-g,-1), ( 0,-g, 1)), ((-1, 0,-g), ( 0,-g,-1), ( 1, 0,-g)), (( 0,-g,-1), ( 0,-g, 1), ( g,-1, 0)), (( 0,-g,-1), ( 1, 0,-g), ( g,-1, 0)), (( g,-1, 0), ( 1, 0,-g), ( g, 1, 0)), (( 1, 0,-g), ( g, 1, 0), ( 0, g,-1)), (( 1, 0,-g), ( 0, g,-1), (-1, 0,-g)), (( 0, g,-1), (-g, 1, 0), (-1, 0,-g)), -T_0, -T_1, -T_2, -T_3, -T_4, -T_5, -T_6, -T_7, -T_8, -T_9, )
Where for a given T_i = (a, b, c), -T_i = (-a, -b, -c). We call -T_i the opposite triangle of T_i in this specification. For any i in [0,20), T_j is the opposite of T_i iff j = (i + 10) % 20.
Let an icosahedron triangle T be defined as T = (a, b, c). The "middle triangle" M is defined as the triangle formed by the points that bisect the edges of T. M is defined by:
M = (m_a, m_b, m_c) = ((a + b) / 2, (b + c) / 2, (c + a) / 2)
Let elements of the tuple (W_0, W_1, W_2, W_3) comprise the sub-triangles of T, so that W_j is the j-th sub-triangle of T. The sub-triangles are defined as the following:
W_0 = M W_1 = (a, m_a, m_c) W_2 = (m_a, b, m_b) W_3 = (m_c, m_b, c)
Definition at line 110 of file AP_GeodesicGrid.cpp.
|
staticprivate |
Find the icosahedron triangle index of the component of _neighbor_umbrellas[umbrella_index] that is crossed by v
.
umbrella_index[in] | The umbrella index. Must be in [0,6). |
v[in] | The vector to be tested. |
u[in] | The vector u must be v expressed with respect to the base formed by the umbrella's 0-th, 1-th and 3-th vertices, in that order. |
inclusive[in] | This parameter follows the same rules defined in #section() const. |
v
is the null vector or the triangle isn't found, which might happen when inclusive
is false. Definition at line 210 of file AP_GeodesicGrid.cpp.
Referenced by _triangle_index().
|
staticprivate |
Get the component_index-th component of the umbrella_index-th neighbor umbrella.
umbrella_index[in] | The neighbor umbrella's index. |
component_index[in] | The component's index. |
Definition at line 202 of file AP_GeodesicGrid.cpp.
Referenced by _from_neighbor_umbrella().
|
staticprivate |
Find which sub-triangle of the icosahedron's triangle pointed by triangle_index
is crossed by v
.
The vector v
must belong to the super-section formed by the triangle pointed by triangle_index
, otherwise the result is undefined.
triangle_index[in] | The icosahedron's triangle index, it must be in the interval [0,20). Passing invalid values is undefined behavior. |
v[in] | The vector to be verified. |
inclusive[in] | This parameter follow the same rules defined in #section() const. |
inclusive
is false. Definition at line 440 of file AP_GeodesicGrid.cpp.
Referenced by section(), and GeodesicGridTest::test_triangles_indexes().
|
staticprivate |
Find which icosahedron's triangle is crossed by v
.
v[in] | The vector to be verified. |
inclusive[in] | This parameter follow the same rules defined in #section() const. |
inclusive
is false. Definition at line 307 of file AP_GeodesicGrid.cpp.
Referenced by section(), and GeodesicGridTest::test_triangles_indexes().
|
static |
Find which section is crossed by v
.
v[in] | The vector to be verified. |
inclusive[in] | If true, then if v crosses one of the edges of one of the sections, then that section is returned. If inclusive is false, then v is considered to cross no section. Note that, if inclusive is true, then v can belong to more than one section and only the first one found is returned. The order in which the triangles are checked is unspecified. The default value for inclusive is false. |
v
is the null vector or the section isn't found, which might happen when inclusive
is false. Definition at line 187 of file AP_GeodesicGrid.cpp.
Referenced by BM_GeodesicGridSections(), TEST_P(), and CompassCalibrator::update_completion_mask().
|
friend |
Definition at line 89 of file AP_GeodesicGrid.h.
|
staticprivate |
The inverses of the change-of-basis matrices for the icosahedron triangles.
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.
Definition at line 171 of file AP_GeodesicGrid.h.
Referenced by _from_neighbor_umbrella(), and _triangle_index().
|
staticprivate |
The inverses of the change-of-basis matrices for the middle triangles.
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.
Definition at line 179 of file AP_GeodesicGrid.h.
Referenced by _subtriangle_index().
|
staticprivate |
Referenced by _from_neighbor_umbrella(), and _neighbor_umbrella_component().
|
static |
Number of sub-triangles for an icosahedron triangle.
Definition at line 107 of file AP_GeodesicGrid.h.
Referenced by GeodesicGridTest::test_triangles_indexes().