直线的点斜公式
y=kx+b, k为直线斜率, b为直线在y轴上的交点
两条直线平行则不相交, 否则就相交
public static bool IsLineIntersect(float k1, float b1, float k2, float b2, out Vector2 intersectPoint) { intersectPoint = Vector2.zero; if (Mathf.Approximately(k1, k2)) //直线平行 return false; float x = (b1 - b2) / (k2 - k1); float y = k1 * x + b1; intersectPoint = new Vector2(x, y); return true; }
标签:直线,Vector2,float,相交,k2,k1,b1,交点 From: https://www.cnblogs.com/sailJs/p/17801194.html