I use a software called Substance Designer which has a Pixel Processor where I can assign to every pixel of a image a gray-scale value defined by a series of operations.
I am basically trying to generate a "normal gradient" generated by the normals of a semi-ellipse with a given a and b semi-major and semi-minor axis.
This semi ellipse is **origin-centered ** and has the principle axes parallel to the x and y axes.
For all points P(x,y) with y≥0, I want to find the angle or direction θ of the outwards-facing ellipse normal that intersects that point. Both when a>b and if possible when b>a "
Here is a visual representation of what I am after, although I only need the values for y>0
Thanks


This is an extended comment, to solve the following problem that came up in the comments:
We have an axis-aligned ellipse, centered at origin, width $2$, height $2 h$ — so semi-major axis is $1$ and on $x$ axis, and semi-minor axis is $h$ and on $y$ axis, with $0 \lt h \lt 1$. For all points $(x, y)$ on or outside the ellipse, $x \gt 0$, $y \gt 0$, we want to find the direction (angle or slope) of the ellipse normal that passes through that point.
The eccentricity $\epsilon$ of this ellipse is $$\epsilon = \sqrt{1 - h^2} \quad \iff \quad h = \sqrt{1 - \epsilon^2}$$
Using angle parameter $\varphi$ the points on the ellipse can be parametrized as $$\left\lbrace ~ \begin{aligned} x_{\varphi}(\varphi) &= \cos\varphi \\ y_{\varphi}(\varphi) &= h \sin\varphi \\ \end{aligned} \right .$$ The slope of the normal is $$m = \frac{ -\frac{d x_\varphi(\varphi)}{d \varphi} }{ \frac{d y_\varphi(\varphi)}{d \varphi} } = \frac{1}{h}\tan\varphi$$ Solving for $\varphi$ we find $$\varphi = \arctan\left(m h\right)$$ and reparametrizing the points on the ellipse (in the positive quadrant, $x \gt 0$, $y \gt 0$), we get $$\left\lbrace ~ \begin{aligned} \displaystyle x_m(m) &= \frac{1}{\sqrt{1 + h^2 m^2}} \\ \displaystyle y_m(m) &= \frac{h^2 m}{\sqrt{1 + h^2 m^2 }} \\ \end{aligned} \right .$$ The points on the normal are on a line $y = m x + y_0$, i.e. $$y_m(m) = m x_m(m) + y_0(m)$$ and rearranging and simplifying, we find that $$y_0(m) = \frac{(h^2 - 1) m}{\sqrt{1 + h^2 m^2}}$$ If point $(x, y)$ is on the normal with slope $m$, it too fulfills the equation: $$y = m x + y_0(m) = m x + m \frac{h^2 - 1}{\sqrt{h^2 m^2 + 1}}$$ To solve this for $m$ (remembering that $\theta = \arctan m$) we need to solve a quadric equation: $$\begin{aligned} \left( h^2 x^2 \right) & m^4 \\ + \left( - 2 h^2 x y \right) & m^3 \\ + \left( x^2 - h^4 + h^2 y^2 + 2 h^2 - 1 \right) & m^2 \\ + \left( - 2 x y \right) & m \\ + \left( y^2 \right) & ~ = 0 \\ \end{aligned}$$ This has zero to four real roots $m$. At and outside the ellipse, at $x \gt 0$, $y \gt 0$, there is exactly one real root (because the normals for the positive quadrant only intersect at $y \le 0$).
Unfortunately, there is no simple algebraic expression for the solutions $m$ that fulfill above.
For what it is worth, Maple suggests the following operations to find the four candidate real roots:
Above,
cbrt(...)is the cube root operation (same aspow(..., 1.0/3.0)), andsqrt(...)is the square root operation. If the argument of the square root is negative (but note that it could be effectively zero, due to rounding errors and such, even if strictly speaking negative; you should round those to positive zero instead), then those candidate solutions do not exist. Remember that you do still need to verify that $m \gt 0$, to get the desired result, $\theta = \arctan m$.(Also remember that if $y = 0$ and $x \gt 0$, then $\theta = 0$; if $y \gt 0$ and $x = 0$, then $\theta = 90^o$. The rest of the quadrants are symmetric.)
Because of this, it might be worth the effort to consider approximations to the problem; for example, instead of a real ellipse, consider approximating the ellipse using one or two cubic polynomials (perhaps with four cubic Bézier curves). Cubic approximations should yield at least two significant digits of precision (less than 1% of error), and would definitely suffice for human perception and "visual arts". I am not sure if that approach yields any better answers, but it would be the avenue I would explore next.