float3 IntersectionOf(float3 a, float3 da, float3 b, float3 db)
{
var crossA = a.X * (a.Y + da.Y) - a.Y * (a.X + da.X);
var crossB = b.X * (b.Y + db.Y) - b.Y * (b.X + db.X);
var x = da.X * crossB - db.X * crossA;
var y = da.Y * crossB - db.Y * crossA;
var d = da.X * db.Y - da.Y * db.X;
return new float3(x / d, y / d, 0.5f * (a.Z + b.Z));
}