As I get more familiar JavaScript & Typescript, I noticed the need in my Wolfram code to continually pass big arrays into my functions. I guess this leads me to two questions I haven't been able to figure out.
- Does this have any negative performance implications as the arrays of values get bigger and/or multiple noise samples need to be take for multiple rings at the same time? (Notice how I keep needing to passing the array and points into the function. I'm not sure if there is a performance hit for this configuration.)
- How can I refactor this code from a block into it's own function? Though rather straightforward with JS/TS, it's not clear to me exact how to rewrite the block into a main function that can be called.
sampleNoise[index_, n_, pts_, arr_] := Module[{noise, sample},
sample = arr[[index]];
noise = getvalue[sample, #] & /@ pts;
If[Length@pts == Length@noise, MapThread[Times, {basicRing[n], noise}], Throw["Error: Sample Noise Length Mismatch"]]
]
Block[{array, val, pts, frames = 80, n = 200, size = 256, dispersion = 12},
(* Global Var for block *)
array = noisyArray[frames, size, dispersion]; (* 3D array of noisy values *)
pts = translatedCoods[n, size]; (* circular pts to sample from along array zaxis *)
(* Create frame data *)
val = Table[Catch[sampleNoise[i, n, pts, array]], {i, frames}];
val = val[[5 ;; -5]]; (* Removes top and bottom frames for consistency *)
ListAnimate[graphicsEngine[val], 10] (* Adds graphial elements to data points / not animated in question *)
]

Times
has theListable
attribute so no need forMapThread
justbasicRing[n] * noise
is equivalent. $\endgroup$