(*Whatlayer,i.e.whatsquare,isthepointin?*)
In[]:=
quadlayer[q_?(Positive[#]&&IntegerQ[#]&)]:=Ceiling
Sqrt[q]-1
2
(*Howmanypointsaroundthegivenlayeristhepoint?*)
In[]:=
quadaround[q_?(Positive[#]&&IntegerQ[#]&)]:=q-
2
(2quadlayer[q]-1)
In[]:=
quadpoint[q_?(Positive[#]&&IntegerQ[#]&)]:=quadlayer[q]Sqrt[2]AngleVector#1-+(#2)AngleVector(#1+1)&@@Quiet[QuotientRemainder[quadaround[q],2quadlayer[q]]]
π
2
1
2
π
2
In[]:=
ListPlot[quadpoint[#]&/@Range[400],JoinedTrue,AspectRatioAutomatic]
Out[]=
In[]:=
ListPlot[quadpoint[#]&/@(Prime[#]&/@Range[10000]),AspectRatioAutomatic,AxesFalse]
Out[]=
In[]:=
AbsoluteTiming[ListPlot[quadpoint[#]&/@(Prime[#]&/@Range[10000]),AspectRatioAutomatic,AxesFalse]]
Out[]=
0.975403,
In[]:=
ListPlot[quadpoint[#-40]&/@(Prime[#]&/@Range[13,10000]),AspectRatioAutomatic,AxesFalse]
Out[]=
(*Wecanalsoextendthisnotiontootherspiralsaroundtheplane*)
In[]:=
mgonLayer[q_Integer,m_Integer]:=Ceiling1+-1
1
2
-8+m+8q
m
In[]:=
mgonLayer[#,6]&/@Range[20]
Out[]=
{0,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,3}
In[]:=
maround[q_,m_]:=q-1+((mgonLayer[q,m]-1)(mgonLayer[q,m]));
m
2
In[]:=
mpoint[q_,m_]:=mgonLayer[q,m]AngleVector(#1-1)+#22SinAngleVector2(#1-1)++&@@Quiet[QuotientRemainder[maround[q,m],mgonLayer[q,m]]]
2π
m
π
m
π
m
π
2
π
m
In[]:=
ListPlot[mpoint[#,6]&/@Range[1000],AxesFalse,AspectRatioAutomatic,JoinedTrue]
Out[]=