I am looking for a script that creates a polyline between two points with the segment lengths equalling a given value. The segment lengths need to match the given value exactly.
thanks:)
I am looking for a script that creates a polyline between two points with the segment lengths equalling a given value. The segment lengths need to match the given value exactly.
thanks:)
Do you want a polyline as straight as possible ? If yes you just need to make a sort of arc.
But you could also make a zig zag. There are an infinity of solutions
A polyline between two points is simply a straight line, eh?
polyLineBetween2pts.gh (10.8 KB)
Was using this method initially to try create a polyline between two points that had segments to a set length. This method has the issue of the final segment not reaching the point. How could I generate a polyline between these two points with my intended segment lengths that reaches both points?
thanks for the quick reply:)
I would prefur it to be the least jaggered solution
thanks for the quick reply:)
Figured it out! thanks anyways:)
Will post my solution in the morning
You didn’t mention that you are converting a curve to a polyline. No image or code/geometry in your initial post.
![]()
Nah not trying to convert a curve. Was only using the curve as a method to generate the polyline with set segment lengths between the two points.
You haven’t stated all the elements of what you are trying to achieve. This seems like a minimization problem, but you might want to minimize the distance of all the intermediate vertices to the optimal line or perhaps you don’t care and just want the first solution.
A simple approach would be to just divide the straight line into equal segments and then to a triangulation. Note that in this case, division of the straight line are smaller sides of a triangle and your predefined length is the longest side. There are some edge cases but it does seem complicated to solve.
It is not possible with a random curve but an arc. Because when you convert a curve into polygon, the curve lenght is changing. Sorry someone has posted the solution already. Mine is a little bit simplistic version.
polyLineBetween2pts_hok.gh (17.2 KB)
Assuming that means a two segment polyline with equal lengths, one could implement a right angle triangle solution. Here’s an implementation using the native RTrig component (note that it crashes Rhino if the solution is impossible, ping @DavidRutten), but one could compute the angle using e.g. a cosine relation:
Thanks Laurent! would love to try this if you want to upload it some time:)
Here is my version.
I use a line, it is more simple than 2 points.
Precision is an angle precision.
Iterations is the max number of iteration allowed.
The output is on an arc, so if want more realistic solution use @Filipe_Brandao solution and add gravity, you will have a chain.
polyLineBetween2pts_LD.gh (15.3 KB)
Where is your solution ?