Heya bplus-
Pretty bang-up job, lots of results crammed into a relatively small amount of code.
Maybe it's my system, or maybe this is a familiar demon from the old plasma days, but it runs slow on my end. This immediately caused me to look at this part:
dx = x - p(n).x: dy = y - p(n).y
dist
= SQR(dx
* dx
+ dy
* dy
) 'dist = _HYPOT(dx, dy) 'this may work faster on another system
d
= d
+ (SIN(dist
* f
(n
)) + 1) / 2
Two things that probably don't need pointing out, but here they are:
1) You can speed things up by using a lookup table for the SIN() function. Even a crappy lookup table with an interpolation formula will certainly get you the precision you need, but probably be faster than the native SIN() function. They did this in the old days, I can only imagine it works now.
2) I see you fiddled with different ways to calculate the square root. Two-and-a-half thoughts on this: (1) Just leave it squared, you'll probably get the same kind of results anyway. (1a) Leave it squared but modify f(n) to compensate, if you can. (2) Use a lookup table for square roots. Linear interpolation for the in-between values will only be arithmetic and won't ever involve a square root in the loop.
I suppose you can also optimize in the direction of _MEM, but it becomes very nontransparent after that.
The third option is I upgrade my system........