Random Walk Question

Hello,

I’m trying to create a file that generates a line full of breaks and turns (like in the screenshot I shared), but I haven’t been successful so far. In the file I created, as you can see, the result is almost a linear line. It only moves along certain axes, but on the X axis it keeps going forward endlessly.

What I want is for the line to be able to loop back over itself if necessary, or start straight and then move back and forth in different directions. But I’d also like to keep this within a certain range. For example, if it starts at 0,0,0, then each next point should stay within 0 ± a range that I define, so that the bends or overlaps don’t happen too suddenly or violently.

Since I’m just a beginner, I couldn’t figure out exactly what I should be doing. I tried to use one of the older examples that is shared in the forum but that was too advanced for me. Any guidance would be much appreciated.

Cosmic Strings.gh (10.6 KB)

I added a Mass Addition here in such a way the original point is moved along the partial sums of each Vector:

The main issue you are facing is in the random x, y, z number generation: you need to specify a Domain in the likes of -x to +x

if you plug a single number, the component automatically interprets it as zero up to x:

you might want to do something like:

result:

Cosmic Strings_inno.gh (13.5 KB)

Hey, thank you for taking the time to write such a detailed and helpful response. I only had the chance to look at the file now, so I apologize for the late reply.

I have one more question: right now, when I increase the Count value in the Divide Curve component, the curve itself gets longer. I’d like to keep the curve length the same but reduce the distance or increase the point count if I wanted to. I couldn’t figure out how to control this properly.

Could you advise me on how to set up the definition so that I can shorten the spacing between points along the curve without extending the overall curve?

Hi

you can use this plugin:”physarealm”

https://www.food4rhino.com/en/app/physarealm![image|625x88](upload://2IvKPSqiJtOEaPZiIehKTzCSwig.png)

you can measure the length of the final polyline and scale it by a factor, in such a way to get a final curve with the total length that you desire

if you do so, you can plug any same Domain in the random generators, the only important thing is that those go from -x to +x and that x is not zero, but their amplitude does not matter anymore

Cosmic Strings_inno_2.gh (13.4 KB)

This might also inspire/help (i.e. an angle constrained zig-zag random walker):

I’ve modified inno’s script here. The length can’t be guaranteed to be exactly as specified with this method (I think because the random offsets are in xyz instead of polar coordinates) but it’s approximately bound. It’s worth noting that although the length stays about the same, the volume occupied by the curves shrinks, as it gets more and more tightly curled up on itself

Scaled Cosmic Strings_inno.gh (11.4 KB)

EDIT: Yes, or you could just scale the whole thing afterwards, duh :rofl:

Ah yes, of course, the vector you get from random XYZ will have random lengths. An Amplitude component fixes that, so now all segments are the same length, and the total is fixed.

Uniform Scaled Cosmic Strings_inno.gh (12.1 KB)

Thank you all for the help. It’s been very informative.

I modified (just added two domains and random modifiers to length and angles to have a little bit more control over the generated curves) one of the files provided in the topic to achieve exactly what I wanted. Sharing it so it may help others as well.

Thank you.

Constrained Random Walk.gh (14.9 KB)