# Uber KML Icosahedron

Somehow I ended up reading Uber’s articles on H3, a library they wrote to divide up their markets into hexagons. They have a github page : [https://github.com/uber/h3/blob/master/KML/icosa.kml#L204]
that uses kml to draw an icosahedron. I put all the coordinates into a csv file and then read those coordinates to try to draw the shape. What I got is strange and I dont understand why it looks so goofy.

Here’s the code:

``````

Bubble[] bubbles;
Bubble[] bubbles2;

Table table;

public void setup() {

size(1275, 750, P3D);

orientation(LANDSCAPE);

}

public void draw() {
background(0);

}
// Load CSV file into a Table object

// The size of the array of Bubble objects is determined by the total number of rows in the CSV
bubbles = new Bubble[table.getRowCount()];

// You can access iterate over all the rows in a table
int rowCount = 0;
beginShape();
for (TableRow row : table.rows()) {
// You can access the fields via their column name (or index)
float x = row.getFloat("x");
float y = row.getFloat("y");
// Make a Bubble object out of the data read
bubbles[rowCount] = new Bubble(x, y);
for (int i=0; i < rowCount; i ++){
println(rowCount, x, y);
stroke(255,0,0);
strokeWeight(2);
noFill();
curveVertex(x,y);
curveVertex(x,y);
}
rowCount++;
}
endShape();

}

// A Bubble class

class Bubble {
float x,y,z;
//float diameter;
// String name;

boolean over = false;

// Create  the Bubble
Bubble(float x_, float y_){ //, float diameter_, String s) {
x = x_;
y = y_;
//  diameter = diameter_;
//  name = s;
}

// CHecking if mouse is over the Bubble

// Display the Bubble
void display() {

}
}

type or paste code here
``````

1 Like

Hmm.

Glancing at the data, each region is defined by four points, tracing a closed triangle as a path – A-B-C-A (AB BC CA). There are 20 regions for the 20 triangular faces. In dymaxian orientation these should be laid flat.

Again, just glancing at the data, the first few sets of points seem to match exactly across neighboring regions to full floating point precision – that makes me suspect that the tufts are a an error in your code, eg casting float to int or integer division.

Or maybe load the .klm file directly using xml functions:

https://processing.org/reference/XML.html

Wow, that’s a thorough answer. What I probably want to do is build an icosahedron and put a texture to it like a sphere and world map. I’m thinking then unfold that and I have a dymaxion map.

As for my original puzzle, I have the csv below.

``````x,y,z
10.536199,64.700000,0.0
58.157706,10.447345,0.0
122.300000,39.100000,0.0
10.536199,64.700000,0.0
10.536199,64.700000,0.0
122.300000,39.100000,0.0
-143.478490,50.103201,0.0
10.536199,64.700000,0.0
10.536199,64.700000,0.0
-143.478490,50.103201,0.0
-67.132326,23.717925,0.0
10.536199,64.700000,0.0
10.536199,64.700000,0.0
-67.132326,23.717925,0.0
-5.245390,2.300882,0.0
10.536199,64.700000,0.0
10.536199,64.700000,0.0
-5.245390,2.300882,0.0
58.157706,10.447345,0.0
10.536199,64.700000,0.0
112.867674,-23.717925,0.0
122.300000,39.100000,0.0
58.157706,10.447345,0.0
112.867674,-23.717925,0.0
174.754610,-2.300882,0.0
-143.478490,50.103201,0.0
122.300000,39.100000,0.0
174.754610,-2.300882,0.0
-121.842294,-10.447345,0.0
-67.132326,23.717925,0.0
-143.478490,50.103201,0.0
-121.842294,-10.447345,0.0
-57.700000,-39.100000,0.0
-5.245390,2.300882,0.0
-67.132326,23.717925,0.0
-57.700000,-39.100000,0.0
36.521510,-50.103201,0.0
58.157706,10.447345,0.0
-5.245390,2.300882,0.0
36.521510,-50.103201,0.0
122.300000,39.100000,0.0
112.867674,-23.717925,0.0
174.754610,-2.300882,0.0
122.300000,39.100000,0.0
-143.478490,50.103201,0.0
174.754610,-2.300882,0.0
-121.842294,-10.447345,0.0
-143.478490,50.103201,0.0
-67.132326,23.717925,0.0
-121.842294,-10.447345,0.0
-57.700000,-39.100000,0.0
-67.132326,23.717925,0.0
-5.245390,2.300882,0.0
-57.700000,-39.100000,0.0
36.521510,-50.103201,0.0
-5.245390,2.300882,0.0
58.157706,10.447345,0.0
36.521510,-50.103201,0.0
112.867674,-23.717925,0.0
58.157706,10.447345,0.0
-169.463801,-64.700000,0.0
174.754610,-2.300882,0.0
112.867674,-23.717925,0.0
-169.463801,-64.700000,0.0
-169.463801,-64.700000,0.0
-121.842294,-10.447345,0.0
174.754610,-2.300882,0.0
-169.463801,-64.700000,0.0
-169.463801,-64.700000,0.0
-57.700000,-39.100000,0.0
-121.842294,-10.447345,0.0
-169.463801,-64.700000,0.0
-169.463801,-64.700000,0.0
36.521510,-50.103201,0.0
-57.700000,-39.100000,0.0
-169.463801,-64.700000,0.0
-169.463801,-64.700000,0.0
112.867674,-23.717925,0.0
36.521510,-50.103201,0.0
-169.463801,-64.700000,0.0
``````