Parametric equation of an elliptical arc

344 Views Asked by At

Edit: My code had an error which is why I could not obtain the correct parametric plot. Hence, there is nothing wrong with the resource I used from W3 to create the ellipse plot.

I would like some help with this problem.

I have an SVG path that contains an elliptical arc defined by the following parameters:

x1 y1 rx ry x-axis-rotation large-arc-flag sweep-flag x2 y2

(x1, y1) is the start-point on the arc, and (x2, y2) is the end-point, and what I want to do is find out when that time is, from the parametric equation.

The parametric equation: $$ \mathbf{r}(t) = \bigl(R_x \cos{(\theta)}\cos{(t)}-R_y \sin{(\theta)}\sin{(t)},\: R_x \sin{(\theta)}\cos{(t)}+R_y \cos{(\theta)}\sin{(t)}\bigr) $$ where $\theta$ is the rotation angle, and $C_x$ and $C_y$ are shifts applied to the ellipse from the center. The form it currently uses makes it hard to use the startpoint and endpoint as that would require me to know the parameterised time that they have.

I came up with the following two expressions: $$ t(x, y)= \begin{cases} -\arcsin\left(\frac{\sin\left(\alpha\right)}{R_{y}}\left(-C_{x}+x+\left(C_{y}-y\right)\cot\left(\alpha\right)\right)\right) & t\in\left(0,\:\frac\pi2\right] \cup\left[\frac3 2 \pi,\:2\pi\right] \\ \pi+\arcsin\left(\frac{\sin\left(\alpha\right)}{R_{y}}\left(-C_{x}+x+\left(C_{y}-y\right)\cot\left(\alpha\right)\right)\right) & t\in\left[\frac\pi 2,\:\frac3 2\pi\right] \end{cases} $$

which give me the time at which a point on the ellipse was at, but only with specific domains, other than that, I do not know how I would use this alongside the SVG path attributes? i.e. How would I think about the two flags?

Example of elliptical arcs: Example elliptical arc Link: https://www.w3.org/TR/SVG/images/paths/arcs02.svg

The reason I want it in parametric form is so that I can "draw" the curve using Python, so feel free to share code alongside any math, as required.

I really appreciate the help, thanks.

Desmos I made: https://www.desmos.com/calculator/31janr0rym

Guide I tried to follow to develop a program to find parametric equation (unfortunately did not work for me):

https://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes

Resources for SVG elliptical arcs:

https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths#arcs https://www.w3.org/TR/SVG/paths.html#PathDataEllipticalArcCommands