空间点到线

double Line3DDist(Circle * Q1, Circle * Q2, Circle * Q3)//空间点到直线的距离
{

	double d;
	double a1, b1, c1, a2, b2, c2,a3,b3,c3;
	a1 = Q1->CX - Q2->CX;
	b1 = Q1->CY - Q2->CY;
	c1 = Q1->CR - Q2->CR;

	a2 = Q3->CX - Q2->CX;
	b2 = Q3->CY - Q2->CY;
	c2 = Q3->CR - Q2->CR;

	a3 = b1 * c2 - b2 * c1;
	b3 = a2 * c1 - a1 * c2;
	c3 = a1 * b2 - a2 * b1;

	d = sqrt(a3*a3 + b3 * b3 + c3 * c3) / sqrt(a2*a2 + b2 * b2 + c2 * c2);
	return d;
}

你可能感兴趣的:(C++,几何)