First time poster here. I don't know if this is the correct forum. If not, feel free to direct me to a more appropriate form, or even suggest a different website.
The background here, is that I'm trying to find an easy way to find a gravity direction in relation to non-spherical surfaces in the context of a video game. Since I want to ignore terrain variations, I think an underlying surface of an ellipse will suffice for simpler shapes, such as flattened planets/asteroids.
In that regard, for an object at a given point, I want to know how to find the line that is perpendicular to the surface of an ellipse. I think this will also happen to be the closest point to the target of that ellipse surface.
Eventually, this will need to work in a 3D environment. And, ideally, I'd like to be able to use more complicated shapes than ellipses (multiple foci, I guess), but I'd like to get ellipses working first before getting too crazy.
Now then, I've tried googling the problem without much luck.
I've also tried to take a stab at a formula myself, but I'm a bit out of my depth. I can almost see a solution though, so I'm certain there's got to be some established math.