📜  unity 在线查找最近点 - C# 代码示例

📅  最后修改于: 2022-03-11 14:49:04.849000             🧑  作者: Mango

代码示例1
public Vector2 FindNearestPointOnLine(Vector2 origin, Vector2 direction, Vector2 point)
{
    direction.Normalize();
    Vector2 lhs = point - origin;

    float dotP = Vector2.Dot(lhs, direction);
    return origin + direction * dotP;
}