# Distorting surfaces by proximity

Hi everyone.
I’m new to Grasshopper and I achieved some really interesting results by learning things here in the forum, really appreciate the community!

Right now I’m stuck with a problem that seems to be way too advanced for me.

I have this lines with control points.

I want to design these lines so each one form some kind of a “leaf” shape. I achieved that by using the Rich Mapp Grapher to remap an amplitude scale to move some of the control points of the curves to draw two Nurb Curves from them. One is “positive” and the other “negative”, and the Start and End points are not affected by the Map Grapher, so I merge them and create a surface from each closed curve.

Here is the Grasshopper file and screenshots.

surface_distortion_on_proximity.gh (18.9 KB)

So far so good and the code seems to works well enough for what I need.

The next step would be to create a way of manipulating the size nad shape of these surfaces depending on their proximity to a circle. Let’s say I have a circle placed somewhat in the center of the surfaces. Everything that’s outside the circle gets shrinked down by some factor, retaining their positions but changind their sizes, control points and whatnot. The points that are further away from the circle should shrink the surface more, so it won’t work to only change the size of the whole shape.
Anything inside the circle remains the same, like this:

I studied the Proximity 3D component, and it seems like it could help me achieve this result, but I’m honestly clueless about how to use it to distort the surfaces so much.

Any help or directions will be very much appreciated!
Thank you!

nice stuff!

one thing I would suggest is to make some minor change on the beginning of the definition in order to avoid this complication:

complication: you will notice that your curves are generated by interpolating many more points than necessary (A)
despite the curve being “ok”, if you check its control polygon (B) wil see it’s made of many more points than necessary

this comes from the very beginning, where your C input is not grafted in these locations:

grafting them will produce the right amount of points because each component will run only between items in the same branch

and when you move down in your definition you will see that the number of points is 4 everywhere

surface_distortion_on_proximity_Re.gh (21.3 KB)

speaking of attractors, you just need to have a really clear idea on what you want to happen to geometry, and in relation to what

your intention is clear, but how would you translate that in geometrical terms?

the way it could be implemented, for instance, might be the following:

you have a point B which is the center of the circle, and you measure the distance between each control point of your stripes and the point B

if the distance is less than value R1 (value of your circle) then nothing happens

else if R1 < measured_distance < R2 then “something happens” to those points/curves/you tell me
the way this transformation happens can of course be also controlled by graph mappers

@inno wow, it’s working so much better now! Graft, of course!
I was getting some weird issues in some more complex examples, now it’s working perfectly thanks to you, I really appreciate your time!

So, about the distortion, my intent is clear but my geometrical knowledge is foggy!
Ok I put some more thought into it and that’s what I come up with.
We have those curves in the beginning, before anything.

1. First we create an Ellipse 1 somewhat in the middle of the points (doesn’t matter exactly where).
We trim the curves with Ellipse 1.

2. Using the same code from before, we have this result now:

This is working fine, but I believe that I could get better results if an ellipse was the base for the distortions.

3. So, the idea would be to offset the ellipse towards its center, creating an Ellipse 2 that is inside Ellipse 1.

4. Ellipse 2 will be the shape that will affect the control points in the surfaces.
4.1 Inside Ellipse 2, Control Points will move towards the outside of their shapes following the perpendicular vector from the Tangent of the curve like in current code, creating that effect of becoming thicker. At the center of Ellipse 2 this effect is maximum, at the edges the effect gets to zero - it would be great to control that in a Graph Mapper indeed!
4.2 Outside E2, Control Points will move towards the center of their shapes following the same vector but inverted, creating the impression of “shrinking”.
Control points that are further away from Ellipse 2 should suffer this effect more,Graph Mapper again?
The control points that are on the edges of Ellipse 1 stays there, they don’t actually move anywhere.

Here’s the new file with the ellipses
surface_distortion_on_proximity_Re.gh (19.7 KB)

Does that make more sense now @inno ?
I hope I could explain it and not confuse you.

Thank you!

it makes sense

I would approach the problem by first finding some more points on the curve we’ll be influencing: the more points are evaluated along the original curves, the more “defined” the elastic behavior will be, but this will also result in weird effects where the direction drastically changes

for instance, where the previous point lies inside E1 and the next point lies outside E1, there you will have a sudden change of direction

relevant data might be the distance from any given point from ellipse1 and ellipse2, their relationship inside/outside from ellipse1 and relation between points and ellipse2 (we are just interested in relations = 1 which means the point is exactly over E2 so it should not be changed) and the perpendicular vectors to the curve on each of our point

at this point it’s just a matter of Sifting the data in such a way only the points you are interested on gets influenced

I think it kind of works the way you have described, but the final result is not flowing nicely as you mighe be expecting… will need for sure some tweaks

surface_distortion_on_proximity_Re_Re.gh (33.2 KB)

@inno thank you so much for your help!
I was finaly able to take a closer look to the file.
After a few hours studying the code I don’t quite understand what you did there, a bit too avanced stuff for me!

It’s not quite working properly so far, but I’m at the limits of my math and grasshopper knowledge, I feel I need to go back and study basic stuff before moving on and try to ask the right questions. I can’t even create a surface from the final output anymore

Thank you veyr much for your effort in helping me, I will study your code for a couple of weeks for sure!

So I took a different approach to the problem and it seems to be working better.

1. First I get the offset as you did @inno, it’s our E2.

2. From that offset I create a line from E2 center and each of the control points of the nurbs. Let’s call it line A.

3. I extend each line by a great amount, to make sure it’s lenght will be bigger than Ellipse 1.

From the extended line I trim it to the edge of E2, line B.
I also trimed another line to the edge of E1, just in case I needed, line C.

4. Here’s the core of the whole logic, I subtract line A lenght’s from line B’s.
If the number is negative, it means it’s inside E2. If it’s positive, the higher the number means the control point it’s more distant from the center. I will use this as the “factor” to control how much the control points will be affected by the previous Graph Mapper (that was already working properly). This way I don’t need to divide the curves and add any extra step.

5. I take the subtraction numbers and add it to a new Graph Mapper, inverting the results with a bezier, but never getting to zero, otherwise the curve disappears. So the bigger the distance, smaller it will be the outcome.
All the negative results (that were inside E2) ends up getting a 1 result this way. The positive results will get somewhere around 0 and 1.
I also added another controller (Line Strength 2) in the ReMap, this way I have another layer of control over how much the results will be affected.

Finally I multiply the new ReMap by the previous ReMap.
Smaller numbers (which are more distant from the center) will get less affected by the distortion.

1 Like