That's the exact approach, as you know.
Meanwhile, I'd got the impression that Linda wished to present the
quarter-circle approximations, as shown in, eg,
https://en.wikipedia.org/wiki/Golden_spiral#/media/File:Fibonacci_spiral_34.svg
So I've amused myself for a while developing the following. As each quarter
circle has an offset centre, I've reverted to Cartesian coords.
It's ended up less transparent than I hoped. Also, given the fairly rapid
growth of the Fibonacci sequence, the later cycles dominate the plot.
(Cliff's reference to his article has just popped up while I was
drafting this;
it might render all the following redundant!)
NB. Fibonacci spirals:
NB. radii 1 1 2 3 5 8 13 21 34
NB. centres (00) (00) (01) (_1 1) (_1 _1) (2 _1) (2 4) (_6 4) (_6 _9)
NB. differences between centres:
NB. diffs (00) (01) (_1 0) (0 _2) (3 0) (0 5) (_8 0) (0 _13)
NB. multipliers needed to derive these differences:
NB. mults (10) (01) (_1 0) (0 _1) (1 0) (0 1) (_1 0) (0 _1)
mults =: 1 0 0 1 _1 0 0 _1$~ ,&2
radii =: 0 1, fib2"0 @: i. @: -&2 NB. as defined elsewhere in thread
NB. Think I'd prefer a vector fib on a scalar input, but no matter, here!
centres =: +/\@ }:@: (0, radii * mults)
NB. set parameter running over y circles (sets of 2pi) in x steps per
quadrant, from pi/2
param =: (] (0.5p1+(2p1 * (#~>:&0))) @: i:@j. (*(8&*)))
xyvals =: cos,: sin NB. radius 1, centre 0 0
NB. set up approx Fibonacci Spiral for y[0] circles, y[1] steps per
quadrant
spiral =: 3 : 0
'n s' =. 2{. y, 10
nt =. #t =. s param n
offsets =. nt{.s#centres 1+4*n NB. centres in each successive quadrant
rads =. nt{.s#}.radii 2+4*n NB. radii """"""
NB. slight inefficiency here, ^^^, in calling fib2 (or whatever) twice
xy =. (|:offsets) + rads *"1 xyvals t NB. cart coords of quarter
circles
((4*s)%~ i.nt) , xy NB. return scale (fairly arbitrary)
with x y coords
)
'pensize 2;aspect 1'plot <"1 spiral 2 10 NB. 2-d plot of spiral
'pensize 2;aspect 1'plot <"1 }. spiral 2 10 NB. 3-d plot of spiral v
circle counter
I expect it would need simplifying for 10/11 year-olds, if they're who
Linda
has in mind.
But a start, maybe
Mike
On 28/02/2017 15:07, Raul Miller wrote:
It is begining to sound like you might want this approach:
phi=: (1 + %: 5) % 2
spiralfib=: verb define
(phi^y) % %:5
)
fib=: verb define
<. 0.5 + spiralfib y
)
Is that where you were heading?
Thanks,
---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm