Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I have a situation where I have an arc that was mangled (irrelevant: by c#'s GraphicsPath.AddArc() function). The original arc is guaranteed to be circular, and the new data I have describes the Bézier approximation for the arc instead. I'm not hugely up on Béziers, or complex geometry, so am hoping someone can help me!

Knowns:

  • I have four points which describe a circular arc
  • Points 1 and 4 are the two end points of the arc
  • Points 2 and 3 are the cubic Bézier control points, i.e are tangential to the arc at each end

It looks like this: Problem

I'm trying to find the length of the line labelled as 'x', which I understand is the Sagitta.

share|improve this question
add comment

3 Answers 3

up vote 3 down vote accepted

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)|$.

share|improve this answer
    
This actually gets me closest easiest, with an added step at the end to get the length of the resulting line. Thanks! –  Geoff May 9 '11 at 16:06
add comment

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.

share|improve this answer
    
Yes, from what I read Béziers only approximate circles (note my wording in my question). I do have the control points (points 2 and 3), although my maths is weak enough that I had trouble putting all the pieces together in your solution (although I'm sure it's right) –  Geoff May 9 '11 at 16:09
add comment

Can't you just use the equation of the Bezier curve (this is a cubic one) and then find the midpoint? It seems easy to find the coordinates of all four points.

share|improve this answer
    
That's where I was going, but I was kind of stuck - Peter's answer helped make sense of it for me –  Geoff May 9 '11 at 16:07
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.