# Deform curves after random walk

Hi all,

So I came across this topic.

Thank you
@laurent_delrieu,
@Joseph_Oster,
and of course @akilli for posting.

I found your replies (as usual) extremely elegant - and coincidentally immensely helpful for my current project.

I began playing and created a bit of a conundrum I think.

Here’s one beautiful result of innumerable possitiblities:

I do not need a particular solution, though I sense enough of what I am doing is a bit brute-force.

CASE:
I am trying to come up with what looks like a ball of ‘strands’ exhibiting numerous kinks and twists, which I then want to deform, as if trying to scrunch and compact it - though without distorting its shape too much - a somewhat ‘soft edit’.

My previous result I had ‘settled for’:

It involved interpolating many points then tweaking generated curve(s) via deformations aided by ellipses:

Upon playing with the random walk examples, I wanted to ‘take control’ of the ‘scrunching’, so I set up a series of constraints and ways to ‘force’ the strands back a bit more into ‘their sphere’. One important thing is to have ‘influence points’ to ‘dictate’ said ‘scrunching’.

I am using a few ‘tactics’ like spatial deform or stretch - before that, I attempted bending, then point deform.

I didn’t like all results, so went back to spatial deform using points to find ‘regions’ on the strand:

Indeed playful and fun, though evidently the more I deform Spatially the more I ‘pinch’ the curve when in reality I want to ‘softly’ treat the kinks to alter the scrunching:

I started attempting multiple ‘stretches’ to then grab an averaged curve:

though my multi-axis set-up isn’t adequate.

I am having more ideas as I type, yet I would be very delighted to see what your take on this would be, if you have a chance of course.

Thank you for reading and looking:
strand_play_01.gh (62.1 KB)

Regards

1 Like

You may want to look at this thread from the old forum, including input from the legendary Nik Wilmore.

2 Likes

woah - thanks @akilli - definitely {now} looking

This probably isn’t what you asked for… The idea popped into my head before I finished reading your post and I didn’t look at your code (yet). The ‘morph’ slider (blue group) moves points between one branch and the other. Each branch has its own seed slider (‘Seed 1’ and ‘Seed 2’).

random_walk_2020Sep8a.gh (22.7 KB)

1 Like

If you’re still interested in trying this with random movers, I guess my previous post is probably a good starting point, however you need to extend the script a little:

First, you’d have to evaluate for each mover at each iteration whether it is still inside the desired boundary volume. If not or intersecting with the boundary, you need to compute a reflection vector as new velocity to make the mover turn back. You want to be a little lenient here, so that the mover can depass the boundary a little. Its trail will overall be much smoother, when it doesn’t have to make abrupt turns. Rope or twine does also flow nicely.

Furthermore, you’d have to record all particle trails, and check for collisions. Each trail would have an imaginary radius (twine thickness) that you want all movers to steer away from. This will come in handy later, because when you pipe the trails, you don’t want intersections.

@akilli’s suggestions seems easier to accomplish, although I think particles could potentially present more random, chaotic results, if that’s something that interests you.

Thank you.

1 Like

Oh my! You gave me more than what I needed! Much appreciated!

I am light-years behind your python knowledge, though I made use (I think) of what you laid out - at least in thought (lol) and more brute-force

One of the latest attempts involved using the curve derivative component to facilitate ‘averaging’ a ‘velocity’ vector from targeted regions, to then spatially deform the ‘ball of hairs’.

Here’s a screengrab where I played with multiple strands and difference in targeted region:

Here’s how it behaves when it’s a single strand:

So smooth and playful - I can only imagine what you’d come up with via your python expertise now that you can ‘see’ more of what I wanted.

Thanks again and best, @diff-arch

1 Like

Man, do I know this dilemma - that’s how come I can’t finish anything!

Nonetheless…

yes - I was oblivious to this potential route, which actually ended up making sense deformation-wise, expanding my play.

A quick look at what you did allowed me to change direction and think of ‘deformation planes’ for the spatial deform:

And then the breakthrough happened:

I learned so much!

Thanks!

This is what I call an “art project”. The outcome seems arbitrary, in the eye of the beholder. Cheers.

1 Like

Haha, I’m sure you did. I think maybe 1 to 2 years, not light years, and I’m a slow learner.

Sounds great and the results speak for themselves! Nice job and thanks for sharing some of it. I like how neatly you seem to organize, group, and annotate everything!

1 Like

You couldn’t have said it better - arbitrary indeed!

Reminded me of this ultimate truth:

4 Likes
2 Likes
1 Like

You kept playing!
Thank you for sharing! I opened the file and felt immediately provoked.

First, more from what you helped me with on this ‘art project’ :

Here’s your ‘morph’ idea in full integration

Fun stuff!

Now with my interest on ‘the more scrunched the better’, I started playing with galapagos, very simple approach - just minimizing length of fitted line - maybe I can incorporate this logic to the big ball - what would you do?

random_walk_2020Sep11_b.gh (18.5 KB)

Thanks!

*edit:
I added ‘negatives’ to the domain start and swapped the graph for the perlin graph mapper because it ‘feels’ more ‘scrunchy’

*edit2:
Also I guess if galapagos cannot manipulate the graph mapper then it only serves the game partially, as playing with the graph mapper definitely predetermines the level (and beauty) of the ‘grown strand’

2 Likes

I don’t see any value in letting Galapagos manipulate the ‘Number’ (of points) slider since it will converge on just two points. Likewise, I don’t see any reason to allow negative values (or even near zero values) on the ‘d’ (Offset distance) domain since lengths near zero will always be favored by shortest line “Fitness”. So that leaves only the ‘Seed’ slider which could be replaced by a Series component to compare 300 seed values.

Cheers.

1 Like

you’d be surprised! Not mine, but definitely in charge of making the arbitrary look ‘believable’.

got you, I do ‘favor’ the ‘maltreatment’ of the polylines once you go a bit negative - though at this point it’s irrelevant - I have achieved way more than what was needed!

Allow me to ‘come back’ with improved results after the pandemic

YES:
“fully acknowledge the emptiness of the experience”

LOL

1 Like

Well,
Two weeks later…

Everything obtained from this thread was magnificent and pretty, though I couldn’t achieve what I inquired about - and with good reason: {my own} stupidity

You can’t expect SpatialDeform to do what you want without understanding what it does first…

(starting) random walk or growth or strand:

spatially deformed (what was needed):

Not as ‘arbitrary’ as my question was!

Thanks again for all you do,
keep rocking!

I don’t get why so many people always write about being/feeling stupid. In my opinion, there are no stupid people, some are just more motivated than others, and/or have easier access to information and knowledge that others don’t.

Yeah, there was maybe a little too much talk about “art projects”, which frankly was completely irrelevant, and ultimately got me disinterested.

You’re welcome, although I feel like I maybe wasn’t that helpful.

I must agree - I thank you and I acknowledge your sane judgment

I feel you - at the same time I didn’t mean to make you work, so it’s all fair!

You were! And by ‘disengaging’ I was soon reminded of what I had to pay attention to.

I have come to a very handy and precise solution I can now be ‘artistic’ with

Again, I can only imagine what your imput would have been with less arbitrary inquiry!
Now I’m trying to find ways to speed this up.

As I should have expected, the more complex (point count) the curve, the longer it takes to achieve what I want. Talk about ‘beauty has a price’.

I must wait 30+ seconds if I want to get the curve I prefer.

Cheers @diff-arch

Ah, cool to hear!

What exactly do you want to speed up? The many colored curves are quite pretty, but I fail to understand what you do them. Do the vectors move the curve control points?

It’s a refined random walk within spherical bounds and the agents have a little leeway to surpass the bounds and turn around. Their trails are recorded too. This shows about 3 to 4 minutes of trail drawing and each trail is about 5000 document units long.

Thank you for your continued feedback.
The main difference is that your curves are random walks, while mine come from a pre-determined shape + point population.

Admirable! I would love to play with that! See more below.

I wanted to { not anymore } speed up the SpatialDeform.
I did so with less points.

Made sense: less points = less to deform.

All OK there.

Pardon me - here we go,

Shape (mesh) + points:

Curve from the points:

Random ‘walks’ along curve segments (via FlowAlongCurve):

note: these ‘random walks’ are not from your random walks example

The vectors were dictating syntax/forces for SpatialDeform to ‘pull’ the whole curve to the points - while maintaining its shape:

The dashed (yellow) curve being the spatially deformed curve.
I was doing that because I cared about new point locations for new spatial deformations.
Then tried different expressions/fall-off functions until I found what I liked.

loved it, but it’s slow. So I’m skipping it for now.

However, back to you:

I care about the ‘spherical bound’ even if it’s a mesh thinking it’s a sphere

Is there a way to inhibit this and instead have the agents simply ‘crash and bounce off’ or (even better) ‘crash and stick’ then turn around?

For clarity:
My most important goal aside from hitting the pre-determined points is to keep the curve(s) within the boundary and never trespassing it.

Here’s what I mean,

In this quick example walks-on-strands_01.gh (67.1 KB) (image below), I used your random movers (previous system), yet matching point count to my points.

Once recorded, I grab your ‘walks’ and flow them to my strands (LoL sounds funny).
Will most likely look too jagged past 2 or 3 iterations because of the scale of walks vs my model. It’s okay for illustrating, though.

So, now

<3
I envision your current refined method, producing one deliberately continuous walk, hitting all my predetermined points, never trespassing the {mesh} boundary - then I could deform the resulting curves later if I truly needed to.

Thank you for your patience/attention, I wish you the best!