## Circular arcs 2 - evaluation

Continuing the series on circular arc representations, we next discuss the most fundamental operation of curve representation: evaluation at an arbitrary parameter value.

The typically most desirable parameterization is arc length parameterization. We will use instead a parameter $$s\in[0,1]$$ that is proportional to the arc length parameterization. The scale factor is simply the arc's length, equal to $$2 r \theta$$, where $$r = \frac{2g}{1+g^2}t$$ and $$g = \tan \frac{\theta}{2}$$. Computation of the arc's length will be discussed in detail in a later article.

The naive thing to do would be to compute the center of the circle, and rotate the radius vector along the arc. However, as discussed in the previous article, the circle center and radius are ill-defined for nearly-straight arcs. In other words, we would like our parameterization to be valid and robust for straight line segments.

All is not lost, however. We will begin with this approach and shore it up into something robust. To begin with, the circle center is:

$$C = \frac{A+B}{2} + \frac{1-g^2}{2g} \frac{(B-A)^\perp}{2}$$

$$r = \frac{1+g^2}{2g} \left\lVert \frac{B-A}{2} \right\rVert$$

Our desired operation now is to apply a rotation matrix to obtain the point on the arc. Let $$X(s)$$ be the desired point:

$$X(s) = C - \begin{bmatrix} \cos \sigma \theta & -\sin\sigma\theta \\ \sin\sigma\theta & \cos\sigma\theta \end{bmatrix} \frac{1+g^2}{2g} \frac{(B-A)^\perp}{2} = C - \frac{1+g^2}{2g} R(\sigma\theta) h^\perp$$

where $$\sigma = 2s-1 \in [-1,1]$$. We change notation slightly from last time and let $$h=\frac{B-A}{2}$$ be the half-chord vector. Since the chord midpoint is a well defined point, we let $$M=\frac{A+B}{2}$$. We can expand the equation above to obtain:

$$X(s) - M = \left[ \frac{1-g^2}{2g} + \frac{1+g^2}{2g} R(\sigma \theta) \right] h^\perp$$

The off-diagonal element of the matrix in brackets is

$$-\frac{1+g^2}{2g} \sin \sigma\theta = -\frac{1+g^2}{g} \sin\frac{\sigma\theta}{2}\cos\frac{\sigma\theta}{2}$$

The diagonal element is

$$\frac{1-g^2}{2g} - \frac{1+g^2}{2g}\cos\sigma\theta = \frac{1}{g}\sin^2 \frac{\sigma\theta}{2} - g\cos^2\frac{\sigma\theta}{2}$$

Both of these expression depend on two quantities that are bounded:

$$\chi_c = \cos\frac{\sigma\theta}{2} \qquad \chi_s = \frac{1}{g}\sin\frac{\sigma\theta}{2}$$

The final expression is then

$$X(s) - M = \begin{bmatrix} g\left(\chi_s^2 - \chi_c^2\right) & \left(1+g^2\right) \chi_s\chi_c \\ -\left(1+g^2\right) \chi_s\chi_c & g\left(\chi_s^2 - \chi_c^2\right) \end{bmatrix} h^\perp$$

All that remains is to compute the required quantities stably. The angle can be computed simply by $$\frac{\theta}{2} = \tan^{-1} g$$. The quantity $$\chi_s$$ can be expanded about $$g = 0$$ as:

$$\chi_s(g) = s\left[ 1 - \frac{g}{6}\left(s^2+2\right) + O(g^2) \right]$$

One may wonder if this is the "best" way to perform the evaluation. Due to the uniqueness of the parameterization, any other method that correctly computes the parameterized point must, in some sense, be equivalent to this one. The principal argument, to me, that this is a good algorithm, is that it respects affine geometry (coordinate free) and applies a transformation matrix to the chord half-vector. In the perfectly conditioned semicircular case of $$g=\pm1$$, the matrix reduces to a simple orthogonal rotation matrix. For $$\left|g\right|<1$$, the point is effectively computed as an affine combination of the endpoints and $$M-h^\perp$$, all of which are well-defined points.