# Points on a normal to a superellipse at distance $d$ from the curve

Given a point P0 $(x0, y0)$ lying on a super ellipse, $(x/a)^n + (y/b)^n = 1$, where $2 <= n <= 5$, I'm trying to derive an equation to describe the point P1 (x1, y1) lying on the normal through $(x0, y0)$ at a distance d from the curve. Note there are actually two points that satisfy this condition: one inside the super ellipse and one external to it. I want to be able to specify either one or both points.

So far I've been able to:

(1) derive the equations for x0 and y0 parametrically as shown below. I'm showing these in a C-like pseudo-language, since I'm working on a computer algorithm to generate and plot my results:

x = a * sign(t) * pow(abs(cos(t)), 2/n) and
y = b * sign(t) * pow(abs(sin(t)), 2/n),


(2) I can also derive the equation for the slope of the normal through (x0, y0) and (x1, y1), which looks something like this:

m = (b/a)^n * x^(n-1)/y^(n-1)


It's been many years though since my last calculus class (40 anyway!), and that's where I'm stuck. I can also see that the point (or more precisely points) (x1, y1) lying along the normal at distance d from the curve need to satisfy (x1 - x0)^2 + (y1 - y0)^2 = d^2, but so far haven't been able to figure out how to use that information.

TIA!

Let $$F(x,y)=\left(\frac{x}{a}\right)^n+\left(\frac{y}{b}\right)^n.$$ Then your superellipse is the level set $$S=\{(x,y)\in\Bbb{R^2}\mid F(x,y)=1\}.$$ The unit normal vector at $(x_0,y_0)\in S$ is given by $$n(x_0,y_0)=\dfrac{\nabla F}{\|\nabla F\|}\mid_{(x_0,y_0)}$$ where $$\nabla F(x,y)=\left(n\left(\frac{x}{a}\right)^{n-1},n\left(\frac{y}{b}\right)^{n-1}\right).$$
Now you have $$(x_1,y_1)=(x_0,y_0)\pm dn(x_0,y_0).$$