Hi @DanielPiker I know this issue has been solved before, but I wasn’t able to find an example which also constrains the number of panels/segments to a multiply of x.

So this is what I have been able to recreate from examples: It basically takes a closed curve, divides it into segments and expands or shrinks its total length to accommodate a specific length segment, while also keeping the angle the end points.

I would like to add a fourth constrain which rounds the number of panels to the nearest multiplier of 6.

I also have some general questions about Kangaroo: for example on this example the solver never ‘converges’ but I can see all line segments are precisely 4.8… maybe a decimal issue?

I also had a question about strengths… I noticed some components come in with a default of 10 000. but other like Line with 10. Angle has a strength of 1 by default. So not sure what to use. I fugured 10 000 for all three…

Here’s how you can constrain the number of divisions to multiples of 6: Curve Optimization.gh (25.6 KB)

About the convergence - Grasshopper does some automatic rounding when it shows numbers. The lengths might actually be something like 4.800000000000054 and 4.800000000000037 but the text panel will show them both as 4.8
The Kangaroo solver has a movement threshold below which it considers the solution converged. By default this is 1e-15, which might often be higher precision than needed, and for complex systems with hundreds of angle constraints it might take a while to reach this level of convergence.
For instance in this definition, setting it to 1e-12 still makes the segment lengths equal to 6 decimal places, and requires far fewer iterations than the default 1e-15.

As for the strengths/weightings. The important thing to understand is that inside the solver these get used in a weighted averaging.
For a simple 1d example, say we have points called A and B along the X axis at 10 and 20.
A weighted average is calculated as:
(wA * A + wB * B) / (wA+wB)
where wA is the weighting for A and wB is the weighting for B

If we use a weighting of 5 for both wA and wB we get

(5 * 10 + 5 * 20) / (5+5) = 15

Note that we could use any value for the weighting here and as long as they are equal, we’d get the same result
(1000 * 10 + 1000 * 20) / (1000 + 1000) = 15

So it is their values relative to each other that matters.

If A was much more important than B we could use something like wA = 100 and wB = 1
(100 * 10 + 1 * 20) / (100+1) = 10.099

So it ends up much closer to A than to B

For simulating systems of elastic materials with known properties and loads we can assign these weights to get accurate deformations.
For solving purely geometric problems the strengths are often unimportant though. If the goals do not conflict with each other, then it should converge to the solution whatever arbitrary weights are set. Most of them default to 1, and a lot of the time there’s no need to change this.
One exception is the Anchor goal, because it is assumed that people will often want this to be enforced more strongly than the other goals, even when they conflict (such as the fixed ends of a hanging chain) so by default it is 10000. (If you want it to really override any other goals you can set it to eg 1e300, which will make it effectively absolutely locked).

About the number of panels, it looks like the way you made it I have to move this slider to get close to 4.8? But I never actually get there. 4.85 is not good enough Im afraid.

Ah perfect! I noticed the points elevate on z and the curve stops being planar, I solved it by projecting the resulting curve to its original plane for now, but maybe that affects the panels distance… Will OnPlane component be the additional goal to keep the points planar?