# Wiggle Vector and randomness - Animations Nodes

I'm quite new to the animation Nodes concepts, and tried to follow this recent tutorial (https://www.youtube.com/watch?v=GzeP---dP1M&list=WL). The point of the tutorial is to generate a bunch of random splines all from a first spline, and then add some moderate noise (in location) to each point from each generated spline. You get a nice cooked spaghettis effect.

Works ok, but then i tried to replace the script subprogram by a wiggle vector Node (see 6.20 in the video). But i just don't manage to get the vector wiggle randomness (seed) independant from the Getpoints Loop. My splines stay "parallel" whatever i try. My guess is i should try to generate a random integer outside of the GetPoints loop and plug the result into the seed of my vector wiggle, but i just don't get it right.

I'd appreciate any suggestion. It seems you are confusing some concepts. The noise function used in the original tutorial is 3D noise based, meaning it is evaluated at 3D vector locations and not seeds (Integers). The Wiggle Vector Node is 3 1D perlin noise each of which assigned to one of the channels, and it gets evaluated at a float (1D instead of 3D), this float is the evolution value you see in the node. So the wiggle node is now acting merely as a random vector generator. If you really want a similar function to the one used in the Script Node, check my answer here, which explains how such noise function can be used. Now that we got that out of the way, lets examine your node tree and try to get it to work as expected

## Seed

You don't need to generate a random number to use as seed, seed is arbitrary, it only matters that it is different, and thus you can use the index directly. Matter of fact, the random numbers may repeat while the index will never, which ensures different results for each iteration. Moreover, float can be converted to integers implicitly, so you don't need the Round Node.

## Spline Seed

It is true that you are changing the seed for each of the individual points of the spline, however, they are constant across splines, that's why they seems identical, what you need to do is to use the index from GetSpline loop as a factor for computing the seed in the GetSplinePoints, you can use the random number generator for this, or simply use a linear combination between the index from the upper loop and the index from the lower one. An example for the linear combination: Lets look at an example to understand how this works. Lets say you have two splines each of which have four points. We want a different seed (integer) for each of those points in each of those splines. The simplest way of getting such integers is using what is known as a Linear Indexing Function which is a simple bijective function in the form: $$f(x,y) = yn + x$$, where $$n$$ is the number of points (4 in our previous example), $$y$$ is the index of the spline (which in our previous example is either 0 or 1 representing the first and second spline respectively) and $$x$$ is the index of spline point (Which in our previous example is either 0, 1, 2, 3 representing the first, second, third and fourth point respectively). In our node tree, $$n$$ is equal to the Point Amount, $$y$$ is the index of the upper loop and $$x$$ is the index of the lower loop. Lets look at the range (output) of this function:

\begin{aligned} f(0,0) &= 0\cdot 4 + 0 =0\\ f(0,1) &= 0\cdot 4 + 1 =1\\ f(0,2) &= 0\cdot 4 + 2 =2\\ f(0,3) &= 0\cdot 4 + 3 =3\\ f(1,0) &= 1\cdot 4 + 0 =4\\ f(1,1) &= 1\cdot 4 + 1 =5\\ f(1,2) &= 1\cdot 4 + 2 =6\\ f(1,3) &= 1\cdot 4 + 3 =7 \end{aligned}

So you see that for any combination of $$x,y$$ belonging to the domain,the output is distinct and always exist, that is, the function is bijective. And it can be safely used as seed.

## Wiggle Evolution

As described in the foregoing sections, the wiggle node is now merely acting as random vector generator, to actually make use of it as a perlin noise generator (That is 1D, unlike the one used in the tutorial, meaning you will not get the same results), you have to use the evolution parameter which can be the seed of the points. Take a look at the documentation for the Wiggle Nodes to have a better understand of what it does. An example would be as follows: ## Spline Info

Spline info will only return the handles locations, the problem is that the points may be very few and the result of the noise may not be apparent, instead, we can evaluate more points on the spline and use them instead. Evaluate Spline Node can be used: ## Replicate Spline

The use of the Replicate Spline Node in the tutorial or your node tree does not seem to be correct, you don't want to have spline that are distant as they are now, instead, one can simply input the spline as a parameter and control their amount using the number of iteration.

## Poly Spline

Don't create the splines as poly and convert them to bezier after that, just create them as bezier directly.

By using all of the above, and by adding a parameter for the wiggle amplitude and by using the index of the upper loop as the seed of the wiggle, and by adding the speed as a parameter: We get: Which is similar to the result of the tutorial.

• Thank you Omar, for this incredibly detailed explanation. I wasn't expecting that much ! I begin to undestand the subtle difference between the wiggle and the random vector nodes. I had the intuition that i had to utilize the parent spline index in cunjonction with the point index, so that the seed input would be different for each point of each spline; you gave a simple solution to do that. By the way, why did you multiply the index by the point amount (first image), instead of putting the index in the upper seed. Now, i'll try to undestand the remaining concepts (speed, evolution,...) Mar 31, 2018 at 22:16
• @ubiq1er I added an example to illustrate the first image better. Is it clearer now? Apr 1, 2018 at 16:29
• Guess i'm having one more question; how do you get that custom node "Evaluate Spline" ? My "Evaluation Spline" Node has a float parameter input instead of an amount input, as in the doc (animation-nodes-manual.readthedocs.io/en/latest/user_guide/…). Did you use a "Get Spline Samples" Node and rename it ? Apr 1, 2018 at 23:31
• @ubiq1er I am using a beta v2.1 of Animation Nodes. The Get Spline Samples was replaced by the new Evaluate Node. For older versions, you can just use the Get Spline Samples like you guessed. Apr 2, 2018 at 17:37