APM:Libraries
Classes | Static Public Member Functions | Static Public Attributes | Static Private Member Functions | Static Private Attributes | Friends | List of all members
AP_GeodesicGrid Class Reference

#include <AP_GeodesicGrid.h>

Inheritance diagram for AP_GeodesicGrid:
[legend]
Collaboration diagram for AP_GeodesicGrid:
[legend]

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
 

Detailed Description

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.

Member Function Documentation

◆ _from_neighbor_umbrella()

int AP_GeodesicGrid::_from_neighbor_umbrella ( int  umbrella_index,
const Vector3f v,
const Vector3f u,
bool  inclusive 
)
staticprivate

Find the icosahedron triangle index of the component of _neighbor_umbrellas[umbrella_index] that is crossed by v.

Parameters
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.
Returns
The index of the icosahedron triangle. The value -1 is returned if 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _neighbor_umbrella_component()

int AP_GeodesicGrid::_neighbor_umbrella_component ( int  umbrella_index,
int  component_idx 
)
staticprivate

Get the component_index-th component of the umbrella_index-th neighbor umbrella.

Parameters
umbrella_index[in]The neighbor umbrella's index.
component_index[in]The component's index.
Returns
The icosahedron triangle's index of the component.

Definition at line 202 of file AP_GeodesicGrid.cpp.

Referenced by _from_neighbor_umbrella().

Here is the caller graph for this function:

◆ _subtriangle_index()

int AP_GeodesicGrid::_subtriangle_index ( const unsigned int  triangle_index,
const Vector3f v,
bool  inclusive 
)
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.

Parameters
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.
Returns
The index of the sub-triangle. The value -1 is returned if the triangle isn't found, which might happen when inclusive is false.

Definition at line 440 of file AP_GeodesicGrid.cpp.

Referenced by section(), and GeodesicGridTest::test_triangles_indexes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _triangle_index()

int AP_GeodesicGrid::_triangle_index ( const Vector3f v,
bool  inclusive 
)
staticprivate

Find which icosahedron's triangle is crossed by v.

Parameters
v[in]The vector to be verified.
inclusive[in]This parameter follow the same rules defined in #section() const.
Returns
The index of the triangle. The value -1 is returned if the triangle isn't found, which might happen when inclusive is false.

Definition at line 307 of file AP_GeodesicGrid.cpp.

Referenced by section(), and GeodesicGridTest::test_triangles_indexes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ section()

int AP_GeodesicGrid::section ( const Vector3f v,
bool  inclusive = false 
)
static

Find which section is crossed by v.

Parameters
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.
Returns
The index of the section. The value -1 is returned if 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().

Here is the call graph for this function:
Here is the caller graph for this function:

Friends And Related Function Documentation

◆ GeodesicGridTest

friend class GeodesicGridTest
friend

Definition at line 89 of file AP_GeodesicGrid.h.

Member Data Documentation

◆ _inverses

const Matrix3f AP_GeodesicGrid::_inverses
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().

◆ _mid_inverses

const Matrix3f AP_GeodesicGrid::_mid_inverses
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().

◆ _neighbor_umbrellas

const struct AP_GeodesicGrid::neighbor_umbrella AP_GeodesicGrid::_neighbor_umbrellas[3]
staticprivate

◆ NUM_SUBTRIANGLES

const int AP_GeodesicGrid::NUM_SUBTRIANGLES = 4
static

Number of sub-triangles for an icosahedron triangle.

Definition at line 107 of file AP_GeodesicGrid.h.

Referenced by GeodesicGridTest::test_triangles_indexes().


The documentation for this class was generated from the following files: