I would like to find an equation to this problem:

The problem is that I have an ellipse at a given center point C, with radius a (x axis), and radius b (y-axis). So far so good. Now I have the points P1-Pn anywhere around (P1 for example), even inside (P2). Now I want to get projection (I1-In) on ellipse for any possible P (except center I guess).
So basically a ray/ellipse intersection. Or maybe somehow detect angle between x-axis and P (Θ), and then project it back on ellipse.
Let's assume that the ellipse is centered at the origin. If it's not, then translate the ellipse and the points to make this so.
Given a point $(x_0, y_0)$ that you want to project, you first find the angle $\theta$ between the $x$-axis and the ray leading to the point: in code, use $\theta = \text{atan2}(y_0, x_0)$. Then the projected point $(x,y)$ can be calculated using
$$k = \frac{ab}{\sqrt{ {b^2}\cos^2{\theta} + {a^2}\sin^2{\theta} }}$$
$$x = k \cos\theta$$
$$y = k \sin\theta$$