I'm working with the program Maya, and i need to script a way to find various fractions up a line for each 3D vector.
For example, lets say I have the vector (0, 0, 0), and the vector (12, 12, 12).
The midpoint formula would be x1+x2/2, y1+y2/2, z1+z2/2 = (6, 6, 6)
And that's great if I only need the midpoint, but I need to calculate points on a line at different distances.
For example, if I need 2 points, I need to be able to put a point at the 1/3 mark of the line, and the 2/3 mark of the line.
If i have 3 points, i need to put the points on the 1/4, 1/2, and 3/4 of the line.
Dividing this formula by 3 or 4 doesn't work, so is there any formula or expression that will allow me to do something like this? Preferably with one variable to plug in rather than a different way to calculate for every single possibility, or is that not possible.
If not, I may be able to work with the nodes in the program instead to maybe accomplish this, but I would rather solve this problem with pure math instead.
Let $A=(a_1,a_2,a_3)$ and $B=(b_1,b_2,b_3)$. The points you are looking for have shape $$\left((1-t)a_1+tb_1,(1-t)a_2+tb_2 , (1-t)a_3+tb_3\right),$$ where $t$ is a parameter of your choosing.
For the point half-way between $A$ and $B$, we use $t=\frac{1}{2}$. This gives the same result as the formula you mentioned in the post.
For the point $\frac{1}{3}$ of the way from $A$ to $B$, use $t=\frac{1}{3}$. For the point $\frac{7}{9}$ of the way from $A$ to $B$, use $t=\frac{7}{9}$. For the three points $\frac{1}{4}$, $\frac{1}{2}$, and $\frac{3}{4}$ of the way from $A$ to $B$, use $t=\frac{1}{4}$, $t=\frac{1}{2}$, and $t=\frac{3}{4}$. And so on.