点到直线的距离即为平行四边形面积除以底的商(外积除以AB模长的积的绝对值)
double Distancetoline(Point P, Point A, Point B){
Vector v1 = B - A, v2 = P - A; //得向量AB,向量PA
return fabs(Cross(v1, v2)) / Length(v1);
}
点到直线的距离即为平行四边形面积除以底的商(外积除以AB模长的积的绝对值)
double Distancetoline(Point P, Point A, Point B){
Vector v1 = B - A, v2 = P - A; //得向量AB,向量PA
return fabs(Cross(v1, v2)) / Length(v1);
}
本文标题:点到直线的距离
本文链接:https://www.haomeiwen.com/subject/vkzceftx.html
网友评论