GodZza

导航

2013年4月11日 #

点乘(内积)

摘要: 今天在项目中看到了“点到线段最短距离”的函数:float GetDistanceToLine(Vector2 point, Vector2 p0, Vector2 p1){ //2D Vector2 v = p1 - p0; Vector2 w = point - p0; float c1 = Vector2.Dot(w,v); if ( c1 <= 0 ) return w.Length(); float c2 = Vector2.Dot(v); if ( c2 <= c1 ) return Vector2.Distance(p... 阅读全文

posted @ 2013-04-11 02:10 GodZza 阅读(6052) 评论(4) 推荐(1) 编辑