From ef61096e0860e29d554d7e426ca4c7ebbed64878 Mon Sep 17 00:00:00 2001 From: Gustavo Jose de Sousa Date: Thu, 12 May 2016 20:27:24 -0300 Subject: [PATCH] AP_Math: geodesic_grid tool: show triangle number for sections too --- libraries/AP_Math/tools/geodesic_grid/plot.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/libraries/AP_Math/tools/geodesic_grid/plot.py b/libraries/AP_Math/tools/geodesic_grid/plot.py index ddf90e1d89..995231b8d6 100644 --- a/libraries/AP_Math/tools/geodesic_grid/plot.py +++ b/libraries/AP_Math/tools/geodesic_grid/plot.py @@ -56,6 +56,7 @@ def sections(sections): def show(subtriangles=False): polygons = [] facecolors = [] + triangles_indexes = set() subtriangle_facecolors = ( '#CCCCCC', @@ -77,17 +78,12 @@ def show(subtriangles=False): if subtriangles: sections(range(i * 4, i * 4 + 4)) else: + triangles_indexes.add(i) polygons.append(p) facecolors.append('#DDDDDD') - mx = my = mz = 0 - for x, y, z in p: - mx += x - my += y - mz += z - ax.text(mx / 2.6, my /2.6, mz / 2.6, i, color='#444444') - for s in added_sections: + triangles_indexes.add(int(s / 4)) subtriangle_index = s % 4 polygons.append(grid.section_triangle(s)) facecolors.append(subtriangle_facecolors[subtriangle_index]) @@ -98,6 +94,15 @@ def show(subtriangles=False): edgecolors="#777777", )) + for i in triangles_indexes: + t = ico.triangles[i] + mx = my = mz = 0 + for x, y, z in t: + mx += x + my += y + mz += z + ax.text(mx / 2.6, my / 2.6, mz / 2.6, i, color='#444444') + if subtriangles: ax.legend( handles=tuple(