用向量计算点到直线的距离


image

https://blog.csdn.net/tracing/article/details/46563383

https://learn.microsoft.com/en-us/previous-versions/ms969920(v=msdn.10)?redirectedfrom=MSDN


typedef struct tagVECTOR2D { double x; double y; } VECTOR2D, *PVECTOR2D; double vGetLengthOfNormal(PVECTOR2D a, PVECTOR2D b) { VECTOR2D c, vNormal; // //Obtain projection vector. // //c = ((a * b)/(|b|^2))*b // c.x = b->x * (vDotProduct(a, b)/vDotProduct(b, b)); c.y = b->y * (vDotProduct(a, b)/vDotProduct(b, b)); // //Obtain perpendicular projection : e = a - c // vSubtractVectors(a, &c, &vNormal); // //Fill PROJECTION structure with appropriate values. // return (vVectorMagnitude(&vNormal)); }


先求出向量a在b上的投影c

然后计算垂直投影e

然后再计算e的长度(模)


e7aefc8b0a3bc837092cd559b070cf0


posted on 2023-03-08 16:53  katago  阅读(323)  评论(0编辑  收藏  举报