3
$\begingroup$

I have implemented the conversion from endpoint to center parameterization of an elliptical arc following the instructions of the SVG spec at https://www.w3.org/TR/SVG/implnote.html#ArcConversionEndpointToCenter.

However, while checking whether the implementation works correctly I found that

  • if I create an arc in center parameterization,
  • get the endpoints of that arc and
  • use those endpoints together with the other needed parameters to create the same arc in endpoint parameterization

that the endpoints of this second arc don't coincide with the endpoints of the first.

Looking through my implementation it followed the spec of the SVG note exactly. However, if I change the last part where the start angle is calculated to

$$ \theta_1 = \angle (\begin{pmatrix}1 \\ 0 \end{pmatrix}, \begin{pmatrix}x_1^\prime - c_x^\prime \\ y_1^\prime - c_y^\prime \end{pmatrix} $$

i.e. leaving out the division with $r_x$ and $r_y$ respectively, the endpoints coincide.

So my question is: Why is this division done if the endpoints are then wrong? Or am I missing something?

$\endgroup$
2
  • $\begingroup$ The angle you get should be independent from the length of vectors. There must be something wrong in the way you compute the angle. $\endgroup$ Commented Oct 24, 2021 at 15:08
  • $\begingroup$ @Intelligentipauca Yes, but I think this would only apply if each component of the vector was divided by the same amount, i.e. either $r_x$ or $r_y$? In this case the x-component is divided by $r_x$ and the y-component by $r_y$, so it would be a different direction. $\endgroup$
    – gettalong
    Commented Oct 24, 2021 at 17:36

1 Answer 1

1
$\begingroup$

An important (and potentially confusing) part of the center parameterization for elliptical arcs is that $\theta_1$ and $\Delta\theta\ $ do not represent angles on the ellipse itself. Rather, these angles correspond to an unscaled, unrotated circle having the same center as the ellipse. Here is the crucial part of the spec you linked (emphasis mine):

If one thinks of an ellipse as a circle that has been stretched and then rotated, then $\theta_1$, $\theta_2$ and $\Delta\theta$ are the start angle, end angle and sweep angle, respectively of the arc prior to the stretch and rotate operations.

Working with a circle in the center parameterization has the effect of decoupling the arc angles from information about the semi-major and semi-minor axis lengths of the ellipse, producing a normalized representation of the arc. The stretch and rotation are then applied when you need calculate the endpoints (as in section B.2.3 of the spec).

The approach you mention (omitting the division by these axis lengths) essentially "bakes" the ellipse scaling into the angle parameters. To see why this might be undesirable, consider how your parameters would change if you needed to, say, double the semi-major axis of the ellipse. In the circular model, only $r_x$ needs to be doubled. But if you've baked the scaling into your angle parameters, in most cases those would need to be recalculated as well.

$\endgroup$
1
  • $\begingroup$ Thank you! I will have to read the spec again to fully understand what you are saying but my guess is that my center parameterization is different from the one in the SVG in exactly the way you specify, leading to the invalid values. $\endgroup$
    – gettalong
    Commented Feb 1, 2022 at 22:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .