Have anyone seen this mathematic line design before and perhaps have some pointers on how to generate it? Preferably using Java.
Asked
Active
Viewed 502 times
2
-
2It looks very similar to a problem where 4 dogs, on vertexes of a square.. starts running towards each other at equal speed. Each line here is a tangent, denoting current direction of dog at time t. – Nishant Sep 04 '12 at 09:21
-
@Nishant: It sure did, thanks! =) – Lasse A Karlsen Sep 04 '12 at 09:24
-
1See http://mathtourist.blogspot.co.uk/2010/06/square-pursuit.html which also points to an algorithm for drawing the figure. – High Performance Mark Sep 04 '12 at 09:29
-
1It's just scaled and rotated squares drawn upon one another. – Alexey Frunze Sep 04 '12 at 09:50
1 Answers
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