July 2015
Intermediate to advanced
286 pages
6h 31m
English
Displaying a grid of equilateral triangles turns out to be really straightforward. If you previously worked through the derivation of the measurements for the hexagons, then you’ve already worked through most of what we need for the triangles, too. Again, we won’t go over the derivation itself here, but we’ll walk through the resulting measurements, and then we’ll implement it all in code.
Because we’re working with equilateral triangles, we know that each of their sides are the same length (s). Further, geometry tells us that the height of an equilateral triangle is s√3/2. Our triangle’s dimensions, then, are:
| | width = s |
| | half_width = width / 2.0 |
| | |
| | height = s * Math.sqrt(3) / 2 |
| | half_height = height / 2.0 |
We’ll let ...
Read now
Unlock full access