19,466
社区成员
发帖
与我相关
我的任务
分享
/***********************************************************************
vDistFromPointToLine:
The function vDistFromPointToLine computes the distance from the point
ptTest to the line defined by endpoints pt0 and pt1. This is done by
resolving the the vector from pt0 to ptTest into its components. The
length of the component vector that is attached to the head of the
vector from pt0 to ptTest is the distance of ptTest from the line.
Parameters:
pt0 A pointer to a POINT structure containing the first endpoint of the
line.
pt1 A pointer to a POINT structure containing the second endpoint of the
line.
ptTest A pointer to a POINT structure containing the point for which the
distance from the line is to be computed.
Return value:
A double value that contains the distance of ptTest to the line defined
by the endpoints pt0 and pt1.
HISTORY : - created - denniscr
************************************************************************/
double vDistFromPointToLine(LPPOINT pt0, LPPOINT pt1, LPPOINT ptTest)
{
VECTOR2D ttLine, ttTest;
PROJECTION pProjection;
POINTS2VECTOR2D(*pt0, *pt1, ttLine);
POINTS2VECTOR2D(*pt0, *ptTest, ttTest);
vProjectAndResolve(&ttTest, &ttLine, &pProjection);
return(pProjection.LenPerpProjection);
}
Distance=0 (abs <=1) 就是 在线上