I’ve been using GH for a number of years but I’m a beginner to C#. I recently went through the Long Nguyen C# video course on youtube. I was able to take what I learned about RTrees in the last section and apply it to the curve growth script and speed it up. Now I am trying to add some additional functionality to it:

1. Add in a curve boundary (usually a rectangle) that the curve would be contained within
2. Using multiple curves so that they don’t overlap eachother, themselves, or pass through the boundary.

For now I just would like some help with item 1, but if anyone has some advice about 2 I am all ears.

What I have tried so far is to divide the boundary curve into points, then I’ve added those points to the RTree that I later use to search for collisions. But I am a little stuck on how to actually make the boundary points repel the curve points in the way that the curve points repel eachother. This is my script: DifferentialLineGrowth RTree edition_forForum.gh (11.5 KB)

I want it to stay within the boundary. Any suggestions?

I found on page 6 of this thread in the old forum a comment by Vicente Soler showing his curve growth script staying within a boundary, but couldn’t find if he ever uploaded that anywhere.

Thanks.
EDIT: if anyone has any suggestions for resources that would be good for me to learn more continuing off from the level that the Long Nguyen course leaves me I would appreciate it. Preferably geared towards GH/Rhino.

Check if particles position is outside boundary , if it is outside project it to the boundary, after that calculate a reflection vector, then update the particles position with that reflection vector. Google vector reflexión formula, I don’t know it by heart but it involves the normal of the closest point to the boundary curve and taking the vector dot product of the particles velocity with that normal vector. In terms of learning, c# I think Longs tutorials are cool but you should look for other sources outside of an architectural domain to learn the principal cores of programming properly. After that is just persistence, curiosity and endless coding.