Hey. If your not experienced with math, please leave!

I’m trying to make a node system (I’m about to explain what that is dw).

I have a map of parts that act as points. These points form imaginary line segments. I also have a node (a part in this case) that I want to be duplicated and positioned equally between the system of line segments, agreeing with the total node count, the node size, and the padding between the nodes.

TLDR; Parts (nodes) need to be placed equally between parts in a general system of line segments.

Heres a diagram representing this because I know have of you are already lost

As you can see, on the bottom right, I have made a basic algorithm for doing this, but I don’t know if this is going to be good under all circumstances, or if there is a better way to do this in general.

Once again, please respond ONLY if you know what your talking about, and if you know it may contribute or solve my problem! Thanks!

Your formula is pretty good in general. Here’s how I would rework it (you DONT need to follow this, I came up with this method after thinking. It could be inferior to yours)

local segments = {5,10,5,10,20}
for si,sl in ipairs(segments) do
local segstartpart = segstartparts[si]
for i = 1,sl,math.round(nodesize + nodepadding) do
local offset = i
—[[Create part and offset it with
offset var from the start part of the segment (make sure it faces end part first)]]
node.CFrame = CFrame.new(segstartpart.Position + (segstart.CFrame.LookVector * offset)
end
end
— Let’s assume you understand the math :P

Like i said, I haven’t tested this yet so it may not work. If it somehow does (yay), experiment around with the offset and make it fit

[Handdrawn haha]
With every iteration, the offset increases by the size and padding (2 here) which accounts for the node info. You could add the map info limits which I’m too lazy to do in the code above (sry)

Ok let me get this straight. You have a start point and an end point and you want to make nodes inbetween those with a given length and segment amount? If so is the math meant to be made to work with 50 in and 5 segments particularly?