Hacker News new | past | comments | ask | show | jobs | submit login

I would like to be able to make this sequence, it looks nice. ~~Unfortunately the included python code is not valid~~. ( * ) It will take me quite a while to grok the math discussion well enough to implement it.

* - pasted it wrong.




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.


I 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/

And will be sure to attribute you and message when I get it in.


That's great. I'm glad you got it working. ;)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: