2

Have anyone seen this mathematic line design before and perhaps have some pointers on how to generate it? Preferably using Java.

enter image description here

Lasse A Karlsen
  • 801
  • 5
  • 14
  • 23

1 Answers1

1

You start with the outer square (rectangle, quad).

1) Draw it.
2) Move each vertex 10 percent of the way towards its neighbor.
3) repeat starting at #1.

The slightly tricky part is in step 2. If you move vertex 1 toward vertex 2, then 2 toward 3, 3 toward 4, the last thing is to move vertex 4 toward where vertex 1 WAS - not where you moved it to. The simplest way is to make a copy of vertex 1 first - call it vertex 5 - and move each vertex toward the next one in the list.

10 percent is an adjustable parameter. Now, to move some percent of the way you can use a weighted average:

x1 = x1 + (x2-x1)*p
y1 = y1 + (y2-y1)*p

where p is 0.1 for 10 percent.

This ensures that the new vertex lies on the line drawn between the 2 old verticies in each case. It works with all quads, not just squares. This is also the beginning of understanding splines.

phkahler
  • 5,687
  • 1
  • 23
  • 31