Geometry Nodes - Resample curves with consistent lengths (avoid gaps)

Given split splines that are forming a surface shape. Each spline varies in length.
I’d like to instanciate objects with specific lengths (aligned to the tangents of the curves) and I would like my lengths to be consistent (i.e. exactly the value I typed with no gaps).
Yet, there seems to be an approximation of how many “lengths resamples” it can fit on the curve then spaces them evenly, leaving those small gaps in between. And these gaps are not the same either from one spline to the other.

In the following example, I have instanciated arrows by the length of 0.2m and you can see how they do not fit perfectly well.

My initial idea was to trim the curve length with the remainder of a modulo. But that doesn’t affect the initial spacing of the instances (and coincidentally, it also removes the instances on one of the splines, heh).

Any idea how to achieve that perfect fitting?

Resampling curve by length.blend (1.4 MB)

Even if you place the arrows manually and lets say you remove one arrow from the line where it has only very small gaps to get some more room, then the new room will be bigger then needed to grow the gaps to right size.

The left space has to go somewhere. Either equally on all gaps (resulting in to big gaps on this line). Or fit the gaps and put the remainder on the start and end of the line (or somewhere else) and only have there bigger gaps. Which is the best you can get. Is that what you want?

1 Like

By default, the remainder space is equally distributed in between the points.
I want it all to stay either at the beginning or at the end, the important goal is the perfect alignment of the lengths.
Optionnally, to make it even better, the remainder would be divided by 2 so one half could be at the beginning and the other half at the end, effectively centering the perfectly aligned lengths on the middle of the spline (its even more elegant that way).

If you enable edge lenght then you see your slanted edges do have 1.25m then two with 2m and two with 1.97m…
So the greatest common divisor would be 0.01m … but because of float rounding adnd individual distributiion i does…

  2.00 m / 10 = 0.2 m
  1.97 m / 9  = 0.218888 m
  1.25 m / 6  = 0.2083333 m

So your intended goal would be no mathemtacial solution → meaning: impossible…

2 and 1.25 would divide by 8 and 5
2 and 1.2 would divideby 10 and 8
2 and 1.33333 … 9 and 6

So if you wanted equal spaced “fencing”… then use lenghts which are a mutliple of your wanted gap length…

2 Likes

Here you go. This resamples the splines of a curve, so that the elements fit into by a given gap size. And sets the positions of the spline points in a way that the remainder is moved to the start and end of the spline.

center_elems_on spline_by_gap
center_elems_on spline_by_gap.blend (1.7 MB)

You are lucky that i already did a similar nodegroup for faces for my face2face addon. Which will hopefully gets an update regarding geonodes soon (It is already planned for a while).

3 Likes

Wonderful! Really thanks a lot. I will take the time to study it.

1 Like

not working in 3.6 versions
3.5 all good