Q:

Find an index for a given Point coordinate from an array of Points

Given an Point array and an arbitrary x,y coordinate, find the index for _points that is closest to the given coordinate.  
PointD[] _points
//create a list of x,y coordinates:
for (int i = 0; i < _numberOfArcSegments + 1; i++)
{

    double x1 = _orbitEllipseSemiMaj * Math. Sin(angle) - _focalDistance; //we add the focal distance so the focal point is "center"
    double y1 = _orbitEllipseSemiMinor * Math. Cos(angle);

    //rotates the points to allow for the LongditudeOfPeriapsis.  
    double x2 = (x1 * Math. Cos(_orbitAngleRadians)) - (y1 * Math. Sin(_orbitAngleRadians));
    double y2 = (x1 * Math. Sin(_orbitAngleRadians)) + (y1 * Math. Cos(_orbitAngleRadians));
    angle += _segmentArcSweepRadians;
    _points[i] = new PointD() { x = x2, y = y2 };
}

I'm drawing an ellipse which represents an orbit.  I'm first creating the point array above, then when I draw it, I (attempt) to find the point closest to where the orbiting body is.  
To do this I've been attempting to calculate the angle from the center of the ellipse to the body:
public void Update()
{    
    //adjust so moons get the right positions (body position - focal point position) 
    Vector4 pos = _bodyPositionDB.AbsolutePosition - _positionDB.AbsolutePosition;   
    //adjust for focal point
    pos. X += _focalDistance; 

    //rotate to the LonditudeOfPeriapsis.  
    double x2 = (pos. X * Math. Cos(-_orbitAngleRadians)) - (pos. Y * Math. Sin(-_orbitAngleRadians));
    double y2 = (pos. X * Math. Sin(-_orbitAngleRadians)) + (pos. Y * Math. Cos(-_orbitAngleRadians));

    _ellipseStartArcAngleRadians = (float)(Math. Atan2(y2, x2));  //Atan2 returns a value between -180 and 180; 
}

then:
double unAdjustedIndex = (_ellipseStartArcAngleRadians / _segmentArcSweepRadians);
while (unAdjustedIndex < 0)
{
    unAdjustedIndex += (2 * Math. PI);
}
int index = (int)unAdjustedIndex;

The ellipse draws fine, (the point array is correct and all is good once adjusted for viewscreen and camera offsets and zoom) 
But does not start at the correct point (I'm decreasing the alpha in the color so the resulting ellipse fades away the further it gets from the body)
I've spend days trying to figure out what I'm doing wrong here and tried a dozen different things trying to figure out where my math is wrong, but I'm not seeing it.   

A:

I assume that _points should be an array of PointD;
This is the shortest way to get the closest point to your array (calcdistance should be a simple function that calculate the euclidean distance):
PointD p = _points. OrderBy(p => CalcDistance(p, gievnPoint)).First();

