I have written a code to extend "n" points, constituting "n-1" lines ,to constitute more lines so you can map "m" data to "m" lines with m > n-1.
This is the function I wrote : https://github.com/embeddedmz/split_a_string_of_2d_line_segments/blob/d4137c087d0c2df1917f3b57170db96d81aca3b9/mainwindow.cpp#L137 It was really hard to write, I did it in 2019 with the VTK framework (coloring lines on a map background with data, there was not enough GeoJSON points) and I want to improve the code (the dot added towards the end is not precise).
Has anyone ever coded something like this ?
In my french blog post (you can translate it), I briefly describe what the algorithm is supposed to do: https://mmzoughi.wordpress.com/2022/08/22/decouper-une-chaine-de-segments-de-ligne-en-plusieurs-autres-segments-de-ligne/
Update : the extended points with my function are the green points and the black points are the ones created with lightxbulb function (notice a black point at 0,0 that's a bug) :
q[i] = (1-t) * p[segment_idx-1] + t * p[segment_idx];
wheret
is always in[0,1]
. The previous expression is known as a convex linear combination in mathematics and it results in points only on the line segment with endpointsp[segment_idx-1]
andp[segment_idx]
. The first and last point are also placed to coincide with the red first and last ones as you wanted in your blog. $\endgroup$