I’ve been meaning to get a good 3d Perlin noise function ( a method used to create a ‘natural’ kind of randomness, very useful in graphical programming ) into the processing.js library for the past few months, and I must admit to being rather slow at doing so. The task, originally scheduled for the .3 or .4 release, has been pushed back to the .5 and now the .6 release of the library.
Though one reason for this delay has been my lack of extra time and good attention to spend on the problem, I think the main problem has been my newness to Javascript combined with my [ sometimes faulty ] methods of investigation.
Before I get into that, I’d like to write a bit about the meta-process of this whole thing, just in case it makes sense to anyone.
Self-exemplification
In the first post in this series, I shared an image of the paths of investigation shared to us by Tristam Shandy in the fourth of his works, and I must say that the paths represented in that image are rather random, and I would posit that my work with getting 3d Perlin noise into processing.js might resemble one of those paths.
If that were the case, then it could be said that the process of getting 3d Perlin noise ( or ‘natural randomness’ ) working with Javascript is a naturally random process itself. As the late Robert Merton would have said, the process of implementing randomness is a self-exemplifying phenomena, in that its implementation resembles its results. Merton observed a few other processes such as these– the rise of the word ’serendipity’ being one of them ( much more on that in future posts… ). His study of the question over where the phrase, “on the shoulders of giants..” originated from also becomes self-exemplifying rather quickly, as it turns out that the phrase itself, commonly attributed to Sir Isaac Newton, actually stands on giants of its own which date back to the Latin grammarian Priscius, and perhaps even further.
Merton, a lover of dictionaries, lamented in a later work of his that his term ’self-exemplification’ was never included in any dictionary, in his lifetime. Fortunately for him, we don’t use paper dictionaries as much as we used to and perhaps the internet can help spread his concept for us instead of Merriam et al. But back to the task at hand-
inexperience with the path
For a long time I have ignored trying to understand subjects such as how a web page loads, how javascript and HTML work together, all the DOM stuff because I have had the crutch of flash. I’ve not really looked into the intricacies of how to do all of those things properly before, because the only HTML and Javascript I needed to know was enough to embed my flash document.
But things, as they are wont to do, have changed and now that I’m working with these matters I’m just not that good at it. I don’t fully understand Javascript, the DOM, CSS. I have much to learn. I don’t have the expertise with the topic that I have with Actionscript, and that can be frustrating to me. This project seems to be my first attempt to speak accurately in a different language, and in being so I am almost uncomfortable with the task in its enormity. I’m not the best programmer. I’m not sure how I ended up here. Others would have finished it ( and probably are doing so now
) in minutes or hours rather than the days, weeks and months I’ve spent with the problem.
Where do I get lost on the way, where is my time spent?
paths followed backward
In my efforts with Actionscript programming, I’ve always loved to use Perlin noise to create a natural kind of randomness in certain situations. I’ve either used the built in Actionscript perlinNoise( … args ) method ( great for 2d ) and in some cases tried out another’s implementation of 3d Perlin noise. So when I found the need for some noise in Javascript I ported the 3d noise class from Actionscript to Javascript and called ok for now.
At some time, however, I said I could get 3d noise working for processing.js. It was only then that I found the class I was working with, while it worked okay for 2d noise it wasn’t working for the third dimension (’z’ or ‘time’). So I fiddled around for awhile, hoping to make it work until I realized that I wouldn’t even know what it would look like to work. How would I know it was correct? How did I know that the class that had inspired mine was itself correct, and how did I know that the class that inspired me was inspired by something that was correct. I couldn’t do this until I really understood 3d Perlin noise, as Mr. Perlin did. Only after that could I understand it, recognize it, and make it work in Javascript. And, further, only after I had realized how much there was to understand of the subject could I go on to solve the problem.
I think at this point, the .4 release deadline was coming, and I determined to, perhaps as a histriographer, travel back to Ken Perlin’s original code ( written in c in some places, java in others ) in my efforts to bring it forward in time to now. And here I will take pause to share a quote:
Could a histriographer drive on his history, as a muleteer drives on his mule, — straight forward — for instance, from Rome all the way to Loretto, without ever once turning his head aside, either to the right hand or to the left, — he might venture to fortell you to an hour when he should get to his journey’s end; — but the thing is, morally speaking, impossible: for, if he is a man of the least spirit, he will have fifty deviations from a straight line to make with this or that party as he goes along, which he can no ways avoid. … To sum up all; there are archives at every stage to be looked into, and rolls, records, documents, and endless genealogies, which justice ever and anon calls him back to stay the reading of: — In short, there is no end of it
Though I have gotten lost on my trails towards 3d Perlin noise, and there is no end of it, I am getting closer. I am busy reading the documents, the rolls, the genealogies along the way. I apologize that I cannot bring back what I want to bring back as quickly as I had wanted to, and hope you might understand my diversions. I contend that I am close. The solution is just beyond that next horizon. The solution is just behind that previous horizon.
Prime Spiral
In my commitment to look back at abandoned projects, I must share some work with prime numbers and spirals, which deserve a link, an instruction manual and an explanation.
instructions
This application relies mostly on key presses in order for interaction. You may change the state of it in one of three ways:
-press the number keys ( between 0 and 9 ) in order to change the rendering mode
-press one of the following keys to toggle on and off certain things:
d = whether the spiral’s radius increments over time
p = whether to show what range of prime numbers are being shown
u = whether to show updates to the application’s state
-press one of the following keys to change which variables the arrow keys change:
r = spiral radius
c = circle or rectangle width/height
f = frame rate of the application
n = number of prime numbers to render each frame
i = amount by which spiral radius increments over time
t = attraction of particles to the mouse
link
explanation
This project started out as a simple investigation into visualizing prime numbers. I came up with an example or two I liked, but the project was not done. Flickr user AM Radio, in that second link, encouraged me to try a spiral layout, which I went on to do.
Having had some fun with drawing prime numbers in spirals, I wondered what it would look like to traverse the sequence of all prime numbers up to about 1.8 million, a few hundred or so at a time. The application above is what it looks like, to me, to do so. I think it takes a day or more to get to 1.8 million, depending upon how you use it. It is usually neat to look at, and playing with it is fun to me. It is nowhere near complete, and I doubt that it should ever be made so.
There are many who have investigated the phenomena of prime numbers– their existence, their depth, their properties and patterns. I would guess that there were many investigators of the subject that, for some reason, gave up upon their way, as I have. I wonder how many ghosts there are on the trail of prime numbers. How many minds have gone down that path and left never to return? How many have come back with interesting results? How many have come back safely but not spoken of what they saw ?
I share this in order that my thoughts not become a ghost who might later trouble me. This is what I saw when I looked at prime numbers. It was not altogether meaningful, but I enjoyed seeing it.