Find sagitta of a cubic Bézier-described arc

From the equation of a cubic Bézier curve, the midpoint of the curve is $\frac{1}{8}(P_1 + 3 P_2 + 3 P_3 + P_4)$. $x$ is the distance from that midpoint to $\frac{1}{2}(P_1 + P_4)$, i.e. $|\frac{3}{8}(-P_1 + P_2 + P_3 - P_4)|$.


First off, cubic Béziers can only approximate circles.

Anyway, get the midpoint of points 1 and 4 (the Bézier implementation you have does keep the control points around, yes?), get the slope of the segment joining points 1 and 2 (call it $F$), and the segment joining points 3 and 4 (call it $G$), get the intersection point of the line perpendicular to $F$ at point 1 and the line perpendicular to $G$ at point 4 (you still remember how to get the slope of a perpendicular?), determine the distance from that intersection point to either of points 1 or 4 (the radius of that circle), and subtract from that the distance from the intersection point to the midpoint of points 1 and 4.


For explicitness, here's a less verbal way of putting the solution. Let us set point $i$ to have coordinates $(x_i,y_i)$ in what follows:

  1. "get the midpoint of points 1 and 4" $$(x_m,y_m)=\left(\frac{x_1+x_4}{2},\frac{y_1+y_4}{2}\right)$$

  2. "get the slope of the segment joining points 1 and 2 (call it $F$), and the segment joining points 3 and 4 (call it $G$)" $$m_F=\frac{y_2-y_1}{x_2-x_1},\quad m_G=\frac{y_4-y_3}{x_4-x_3}$$

  3. "get the intersection point of the line perpendicular to $F$ at point 1 and the line perpendicular to $G$ at point 4", i.e. solve $$\begin{align*} y_{int}-y_1&=-\frac{x_2-x_1}{y_2-y_1}(x_{int}-x_1) \\ y_{int}-y_4&=-\frac{x_4-x_3}{y_4-y_3}(x_{int}-x_4) \end{align*}$$ for $(x_{int},y_{int})$

  4. "determine the distance from that intersection point to either of points 1 or 4"; using point 1 for instance $$r=\sqrt{(x_{int}-x_1)^2+(y_{int}-y_1)^2}$$

  5. "subtract from that the distance from the intersection point to the midpoint of points 1 and 4."

$$\text{sagitta}=r-\sqrt{(x_{int}-x_m)^2+(y_{int}-y_m)^2}$$

The method is exact for circles. If it helps, think of this as the computer adaptation of the usual compass/straightedge method for finding the center of a circle.