APM:Libraries
AP_GeodesicGrid.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Intel Corporation. All rights reserved.
3  *
4  * This file is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the
6  * Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This file is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12  * See the GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 #pragma once
18 
19 #include "AP_Math.h"
20 
88 class AP_GeodesicGrid {
89  friend class GeodesicGridTest;
90 
91 public:
92  /*
93  * The following concepts are used by the description of this class'
94  * members.
95  *
96  * Vector crossing objects
97  * -----------------------
98  * We say that a vector v crosses an object in space (point, line, line
99  * segment, plane etc) iff the line, being Q the set of points of that
100  * object, the vector v crosses it iff there exists a positive scalar alpha
101  * such that alpha * v is in Q.
102  */
103 
107  static const int NUM_SUBTRIANGLES = 4;
108 
126  static int section(const Vector3f &v, bool inclusive = false);
127 
128 private:
129  /*
130  * The following are concepts used in the description of the private
131  * members.
132  *
133  * Neighbor triangle with respect to an edge
134  * -----------------------------------------
135  * Let T be a triangle. The triangle W is a neighbor of T with respect to
136  * edge e if T and W share that edge. If e is formed by vectors a and b,
137  * then W can be said to be a neighbor of T with respect to a and b.
138  *
139  * Umbrella of a vector
140  * --------------------
141  * Let v be one vertex of the icosahedron. The umbrella of v is the set of
142  * icosahedron triangles that share that vertex. The vector v is called the
143  * umbrella's pivot.
144  *
145  * Let T have vertices v, a and b. Then, with respect to (a, b):
146  * - The vector a is the umbrella's 0-th vertex.
147  * - The vector b is the 1-th vertex.
148  * - The triangle formed by the v, the i-th and ((i + 1) % 5)-th vertex is
149  * the umbrella's i-th component.
150  * - For i in [2,5), the i-th vertex is the vertex that, with the
151  * (i - 1)-th and v, forms the neighbor of the (i - 2)-th component with
152  * respect to v and the (i - 1)-th vertex.
153  *
154  * Still with respect to (a, b), the umbrella's i-th component is the
155  * triangle formed by the i-th and ((i + 1) % 5)-th vertices and the pivot.
156  *
157  * Neighbor umbrella with respect to an icosahedron triangle's edge
158  * ----------------------------------------------------------------
159  * Let T be an icosahedron triangle. Let W be the T's neighbor triangle wrt
160  * the edge e. Let w be the W's vertex that is opposite to e. Then the
161  * neighbor umbrella of T with respect to e is the umbrella of w.
162  */
163 
171  static const Matrix3f _inverses[10];
172 
179  static const Matrix3f _mid_inverses[10];
180 
203  static const struct neighbor_umbrella {
212  uint8_t components[5];
221  uint8_t v0_c0;
222  uint8_t v1_c1;
223  uint8_t v2_c1;
224  uint8_t v4_c4;
225  uint8_t v0_c4;
226  } _neighbor_umbrellas[3];
227 
238  static int _neighbor_umbrella_component(int umbrella_index, int component_idx);
239 
259  static int _from_neighbor_umbrella(int umbrella_index,
260  const Vector3f &v,
261  const Vector3f &u,
262  bool inclusive);
263 
275  static int _triangle_index(const Vector3f &v, bool inclusive);
276 
295  static int _subtriangle_index(const unsigned int triangle_index,
296  const Vector3f &v,
297  bool inclusive);
298 };
static const Matrix3f _mid_inverses[10]
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 const Matrix3f _inverses[10]
float v
Definition: Printf.cpp:15
static const struct AP_GeodesicGrid::neighbor_umbrella _neighbor_umbrellas[3]
static const int NUM_SUBTRIANGLES
static int section(const Vector3f &v, bool inclusive=false)
static int _subtriangle_index(const unsigned int triangle_index, const Vector3f &v, bool inclusive)
static int _neighbor_umbrella_component(int umbrella_index, int component_idx)