/// <summary>
/// 求点到直线的垂足
/// </summary>
/// <param name="x1">点横坐标</param>
/// <param name="y1">点纵坐标</param>
/// <param name="A">直线方程一般式系数A</param>
/// <param name="B">直线方程一般式系数B</param>
/// <param name="C">直线方程一般式系数C</param>
/// <param name="x">垂足横坐标</param>
/// <param name="y">垂足纵坐标</param>
/// <returns>成功返回真,失败返回假</returns>
public static bool footOfPerpendicular(double x1, double y1, double A, double B, double C, ref double x,ref double y)
{
if (A * A + B * B < 1e-13) return false;
if (Math.Abs(A * x1 + B * y1 + C) < 1e-13)
{
x = x1;
y = y1;
}
else
{
x = (B * B * x1 - A * B * y1 - A * C) / (A * A + B * B);
y = (-A * B * x1 + A * A * y1 - B * C) / (A * A + B * B);
}
return true;
}