Is it possible to convert Cartesian equation to polar or parametric equation?

38 Views Asked by At

I was reading Wikipedia to find interesting curves to be plotted using a polar coordinate system. And I've found an interesting shape, which is Squircle:

Illustration of Squircle that looks like rounded square

Wikipedia shows this equation:

$$ {\vert \frac{x - a}{r_a} \vert}^n + {\vert \frac{y - b}{r_b} \vert}^n = 1 $$

Can this equation be converted to a polar coordinates equation or parametric equation?

I'm asking because I want to write code that will plot the shape and I have no idea how to do that if I have an equation that has both x and y in it, it would be silly to iterate over every pixel on the screen to draw a shape that looks like something that should have polar or parametric representation.

1

There are 1 best solutions below

3
On BEST ANSWER

For parametric equations, relationship $\cos^2 a + \sin^2 a= 1$ invites to set:

$$\begin{cases}\frac{x-a}{r_a}&=&(\cos t)^{2/n}\\ \frac{y-b}{r_b}&=&(\sin t)^{2/n}\end{cases}$$

giving:

$$\begin{cases}x(t)&=&r_a \cos(t)^{2/n} + a\\ y(t)&=&r_b \sin(t)^{2/n}+b \end{cases}$$