Generate evenly spaced points on 2D graph

936 Views Asked by At

I want to draw dots on an image that is W by W pixels. The image is stored as a 1-D array of pixels. The pixel (x,y) is at array index x + y * W. I am thinking that I can use a fixed step size, N, and draw a dot at every Nth pixel. What value of N will produce equilateral triangles?

Here is the result using W = 100 and N = 673 W = 100 and N = 673

As you can see the triangles formed are nearly equilateral. Given W, how can I find "good" values for N, which will form near equilateral triangles?

1

There are 1 best solutions below

1
On

I doubt if there is a simple answer to this question. Below is a plot of the "goodness" of the 10 triangles that can be formed using the first five points. Goodness is min side length over max side length. W = 100, and the first point is at (50,0). The horizontal axis is N, from 600 to 1200.

enter image description here

You can see there are 10 peaks above 0.9 goodness. These correspond to N = 628, 674, 726, 759, 826, 860, 926, 1026, 1137, 1165. The very last "good" spot is at N = 2850 where the points 0,1,2 form a nearly equilateral triangle. I have a theory that for any W, there will be an nearly equilateral formed when N = 0.2885 * W^2 (approximately).