Point attracts other points softly

Hello, I have a curve divided by 1 meter intervals of points (Curve Points), and 3 Attractors points. Is there a way to attract the Curve Points along the Z direction to the 3 Attractor points but in a Soft and gradual way? As shown in the image below. Also as an additional rule, can the closest point of each Attractor points be pulled to the same Z value as it’s attractor?

As shown, the blue lines show my goal such that the closest points are the ones pulled and not necessarily all the points.

The final result I’m after. The blue lines represent the new Curve Points. The block dots are the attractor points.

Thanks.Curve Shape Attractor.gh (9.7 KB) CrvAttr.3dm (51.1 KB)

Here is a solution, the idea is to replace points on curve near the attractor by the attractor itself. This is depending upon the distance. And at the end using Cull Duplicates to suppress the attractors and let only one of each and then Interpolate

Curve Shape Attractor_LD.gh (13.2 KB)


Great solution by Laurent!
Because I recently had to solve a similar problem I want to contribute the Gaussian way of doing that. Not perfect because only 1 attractor is affected yet but it offers some more possibilities for the shape af the curve. (I have to study Laurents list-sorting, maybe there is a way to get all 3 points managed.)

CrvPtAttract.gh (17.4 KB)

1 Like

Hello @ferry59
here a more general solution with 4 different kernels,

All the kernels I use have max value of 1, because I want the curve passing on (near indeed) the attractor point.
Kernel windows is depending on the distance of the attractor point, it could easily changed if needed.

A version with constant height and width of kernel depending on this height * coefficient

CurveShapeAttractor_LEGACY.gh (11.7 KB)


Wow thank you so much Laurent, this problem has been bugging me a bit for a while. I’ll try to learn this technique. You see I’m trying to create a 3d Road script and this is good for the intersections problems. I’m happy I can now apply this elegant solution. Thank you so much!!

You are welcome. I’ll add another kernel, the half circle one. But you’ll probably see some “bugs” if attractors points are too close. A blending could become necessary.

1 Like

Thanks again Laurent, I’ll update you if I see some problems, I’m planning to share the script in the forum so that it could be dissected by experts like you. I think it could help or at least give a starting point on how to make a Civil 3d-esque and Autodesk Infraworks - esque functionality. Thanks again so much :smiley: