[Math] Plot points around circumference of circle in 3D space given 3 points

calculuscirclesspherical coordinates

I have a problem relative to robotics where I would like to teach 3 Cartesian points in 3D space that define a circle and then find a number of way-points along that circle to execute – for example move to a point every 3 degrees along the circle between the first point and the third point. I can define points A,B & C. From those 3 points in space I know how to calculate the center of the circle (point D) and the radius. My thought is that I would then shift points A & C relative to the origin and then convert them to spherical coordinates using:

R=x2+y2+z2
θ=cos−1(zR)
ϕ=tan−1(yx)

I might then define a great circle from points A & C but I'm uncertain how to calculate the way-points between them along the arc every 3 degrees for example. Once I have the spherical coordinates for the waypoints I would then convert them back to cartisian and shift them back to point D. I would like to ask if anyone can give me some direction on how to calculate points every (x) degrees between the two points on the great circle and also if I have the right approach on how to accomplish this.

I appreciate the assistance.

enter image description here

1:

Best Answer

One way to do it, given the points $A, B, C,$ the center $D$, and the radius $R$:

Compute the vector $\mathbf v = A - D,$ that is, a vector of length $R$ in the direction from $D$ to $A.$

Compute the vector $\mathbf u = B - D.$ If $\mathbf u$ would be in the opposite direction from $\mathbf v,$ then set $\mathbf u = C - D$ instead.

Project $\mathbf u$ onto $\mathbf v.$ Let the projected vector be $\mathbf u_\parallel.$ The formula to compute this is $$ \mathbf u_\parallel = \left(\frac{\mathbf u \cdot \mathbf v}{\lVert\mathbf v \rVert^2}\right) \mathbf v. $$

Let $\mathbf u_\perp = \mathbf u - \mathbf u_\parallel.$

Then $\mathbf u_\perp$ is in the plane of the circle and is perpendicular to $\mathbf v.$ Let $\mathbf w = \frac{R}{\lVert\mathbf u_\perp\rVert} \mathbf u_\perp,$ that is, $\mathbf w$ is a vector of length $R$ in the same direction as $\mathbf u_\perp.$ Now you have two perpendicular vectors of length $R$ in the plane of the circle.

Alternatively, use some other method to get perpendicular vectors $\mathbf v$ and $\mathbf w$ of length $R$ in the plane of the circle. There are various ways.

Once you have the vectors $\mathbf v$ and $\mathbf w,$ to generate a point $P$ on the circle simply choose an angle $\theta$ and let $$ P = D + (\cos\theta)\mathbf v + (\sin\theta)\mathbf w.$$

You can get points at intervals of $x$ degrees by adding $x$ to the angle repeatedly.