I have some legacy code which is supposed to draw an arc with constant radius in 3d space however it is drawing the arc in the wrong position. I would like to know and understand the mathematical algorithm for doing this so I can verify the current code.
Given a start point in 3d space [x1, y1, z1], end point in 3d space[x2, y2, z2], centrepoint[c1, c2, c3] and number of segments, where segments define the number of points between the start and end point which will help draw the arc with straight lines, what is the math to help achieve this?
Update: The centrepoint is the midpoint of the sphere.
If I understand the question correctly, you want the arc generated by a center point $C[c_1;c_2;c_3]$, a start vector $u[x_1;y_1;z_1]$ and an end vector $v[x_2;y_2;z_2]$.
The starting point of your arc is therefore $C+u$, and the end point $C+v$ (thus forcing $u$ and $v$ to have same norm). Let $\alpha$ be the angle $(u;v)$
Your arc is defined by the set of points $C+\dfrac{\sin(\alpha-\theta)u+\sin(\theta)v}{\sin(\alpha)}$, for $\theta\in[0;\alpha]$. Using values of $\theta=\dfrac{k\alpha}{n}$ should give you the points you need to approximate the arc with $n$ segments.
Edit : Now that I have written this I realize that this does not work for $\alpha=\pi$, witch is to be expected as in 3D, two opposite vectors and the center of the sphere do not define an arc (as they don't define a plane). It does work otherwise. Given the midpoint instead of the center, one can find the center and make this work for all cases where $u \neq -v$. I'll look into this tomorrow, as well as computing the above formula using the cartesian coordinates.
Edit2 : after giving it some more thought, I think the best way to define an arc is giving the center of the sphere, the start vector, and the mid vector/point. That way the two vectors you are using are not colinear (thus defining the arc uniquely), unless you are trying to draw a circle. With those inputs, the above parametrisation should work with minor fixes. But first, some much needed sleep.