3 ms·
That's strange. To double-check that i typed it into my blog correctly, I copy-and-pasted the code from the post into my python IDE and it compiles and runs pr
by extremelearning 8y ago
That's strange.
To double-check that i typed it into my blog correctly, I copy-and-pasted the code from the post into my python IDE and it compiles and runs properly in my environment. For what it is worth, I am using Python 2.7 on a 64-bit windows machine. Maybe someone else reading has some ideas?
You should notice that after my example code, I have included two other people's code demos so that you can see the same algorithm from a different perspective. Maybe these will help you understand what's required.
In summary, for 2 dimensions, x and y coordinates of the n-th term (n = 1,2,3,....) are defined as:
g = 1.32471795724474602596090885447809
a1 = 1.0/g
a2 = 1.0/(g*g)
x[n] = (0.5+a1*n) %1
y[n] = (0.5+a2*n) %1
where %1 is the mod 1 operator and takes the fractional part of the argument.
Hope that helps.
- strainer 8y agoI pasted it wrong blush And, Thankyou that seems as clear as can be, when I get my head screwed on straight I will have a better read through your fine insights of the workings. I will be trying include your sequence in my quirky collection of random helpers for Javascript, illustrated here. http://strainer.github.io/Fdrandom.js/ http://strainer.github.io/Fdrandom.js/ And will be sure to attribute you and message when I get it in.
- extremelearning 8y agoThat's great. I'm glad you got it working. ;)