示例#1
0
bool check_collinear(Pt &a, Pt &b, Pt &c)
{
	double ratio1 = 0, ratio2 = 0, ratio3 = 0;
	
	ratio1 = (b.X() - a.X()) / (c.X() - a.X());
	ratio2 = (b.Y() - a.Y()) / (c.Y() - a.Y());
	ratio3 = (b.Z() - a.Z()) / (c.Z() - a.Z());

	if ((ratio1 == ratio2) && (ratio3 == ratio2))
		return true;

	return false;
}
示例#2
0
pt_orient Facet::eval_point(Pt &p)
{
	double	a = 0, b = 0, c = 0, d = 0;
	double	distance = 0;
	Pt		A, B, C;

	A = *boundary_edge->getorigin();
	B = *boundary_edge->getnext()->getorigin();
	C = *boundary_edge->getprev()->getorigin();

	a = ((B.Y() - A.Y()) * (C.Z() - A.Z())) -
		((C.Y() - A.Y()) * (B.Z() - A.Z()));

	b = ((B.Z() - A.Z()) * (C.X() - A.X())) -
		((C.Z() - A.Z()) * (B.X() - A.X()));

	c = ((B.X() - A.X()) * (C.Y() - A.Y())) -
		((C.X() - A.X()) * (B.Y() - A.Y()));

	d = -(a * A.X() + b * A.Y() + c * A.Z());

	distance =	(a* p.X() + b * p.Y() + c * p.Z() + d) /
				(sqrt(a*a + b*b + c*c));

	if (distance > (0 - 0.0001) && distance < (0 + 0.0001))
	{
		return E_EQUAL;
	}
	else if (distance < 0)
	{
		return E_BELOW;
	}
	else 
		return E_ABOVE;
}
示例#3
0
PT_ORIENT_T check_coplanar(Pt &p1, Pt &p2, Pt &p3, Pt &check)
{
	double	a = 0, b = 0, c = 0, d = 0;
	double	distance = 0;
	Pt		A, B, C;

	A = p1;
	B = p2;
	C = p3;

	a = ((B.Y() - A.Y()) * (C.Z() - A.Z())) -
		((C.Y() - A.Y()) * (B.Z() - A.Z()));

	b = ((B.Z() - A.Z()) * (C.X() - A.X())) -
		((C.Z() - A.Z()) * (B.X() - A.X()));

	c = ((B.X() - A.X()) * (C.Y() - A.Y())) -
		((C.X() - A.X()) * (B.Y() - A.Y()));

	d = -(a * A.X() + b * A.Y() + c * A.Z());

	distance = (a* check.X() + b * check.Y() + c * check.Z() + d) /
		(sqrt(a*a + b*b + c*c));

	if ((distance > 0 - 0.0001) && (distance < 0 + 0.0001))
	{
		return E_EQUAL;
	}
	else if (distance < 0)
	{
		return E_BELOW;
	}
	else
		return E_ABOVE;

}