This is more or less the same answer as Howard gave but pressed into C# ... I hope this helps with your code-base.
This code snippet should do the trick (finding the mid-points from your 4, but only if all are colinear) - also note I don't check for real intersection, you can do this easily youself by inspecting the answer and your points.
I did not take the time and implement the Vector3D struct in a sensible manner (operators, ...) - you can do this easily too.
Also note that this will work for not only 4 points but keep your diagram in mind.
private struct Vector3D
{
public double X { get; set; }
public double Y { get; set; }
public double Z { get; set; }
}
static class Vectors
{
static public double ScalProd(Vector3D v1, Vector3D v2)
{
return v1.X*v2.X + v1.Y*v2.Y + v1.Z*v2.Z;
}
static public Vector3D Minus(Vector3D v1, Vector3D v2)
{
return new Vector3D {X = v1.X - v2.X, Y = v1.Y - v2.Y, Z = v1.Z - v2.Z};
}
static public Vector3D Normalize(Vector3D v)
{
var len = Math.Sqrt(ScalProd(v, v));
return new Vector3D {X = v.X/len, Y = v.Y/len, Z = v.Z/len};
}
}
private Vector3D[] FindIntersectionOnCoLinearVectors(params Vector3D[] input)
{
if (input.Length < 2) throw new Exception("you need a minimum of two vectors");
var v0 = input[0];
var direction = Vectors.Normalize(Vectors.Minus(input[1], v0));
Func<Vector3D, double> projectOntoLineStartingAtv0 =
v => Vectors.ScalProd(direction, Vectors.Minus(v, v0));
var mapped = input.OrderBy(projectOntoLineStartingAtv0).ToArray();
return new Vector3D[] {mapped[1], mapped[2] };
}