Displaying a Triangle Grid
Explore how to display a grid of equilateral triangles using Ruby by calculating their width, height, and vertex coordinates. Understand how to position triangles based on orientation to implement triangular mazes effectively.
We'll cover the following...
We'll cover the following...
Displaying a grid of triangles in Ruby
Displaying a grid of equilateral triangles turns out to be really straightforward. 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 side is the same length (