Example #1
0
//
//	Return the position of the third link compared to this link and
// the second link
// Result = IS_ON | IS_LEFT | IS_RIGHT
//
LinkStatus KBoolLink::PointOnCorner(KBoolLink* const two, KBoolLink* const third)
{
	LinkStatus
	TwoToOne,		// Position of two to this line
	ThirdToOne,    // Position of third to this line
	ThirdToTwo,		// Position of third to two
	Result;

//m		Node*	center;

//the this link should connect to the other two link at at least one node
//m		if (endnode==two->endnode || endnode==two->beginnode)
//m			center=endnode;
//m		else
//m		{	center=beginnode;
//		assert(center==two->endnode || center==two->beginnode);
//m	}
//	assert(center==third->endnode || center==third->beginnode);



	// Calculate the position of the links compared to eachother
	TwoToOne	 = OutProduct(two,_GC->GetAccur());
	ThirdToOne= OutProduct(third,_GC->GetAccur());
	//center is used in outproduct to give de direction of two
	// this is why the result should be swapped
	ThirdToTwo=	two->OutProduct(third,_GC->GetAccur());
	if (ThirdToTwo==IS_RIGHT)
	  ThirdToTwo=IS_LEFT;
	else if (ThirdToTwo==IS_LEFT)
	  ThirdToTwo=IS_RIGHT;

	// Select the result
	switch(TwoToOne)
	{
		// Line 2 lies on  leftside of this line
		case IS_LEFT : if ((ThirdToOne==IS_RIGHT) || (ThirdToTwo==IS_RIGHT))	return IS_RIGHT;
							else if ((ThirdToOne==IS_LEFT) && (ThirdToTwo==IS_LEFT))	return IS_LEFT;
							else	Result=IS_ON;	break;
		// Line 2 lies on this line
		case IS_ON	 :	if ((ThirdToOne==IS_RIGHT) && (ThirdToTwo==IS_RIGHT))		  return IS_RIGHT;
							else if ((ThirdToOne==IS_LEFT) && (ThirdToTwo==IS_LEFT))   return IS_LEFT;
					  //		else if ((ThirdToOne==IS_RIGHT) && (ThirdToTwo==IS_LEFT))   return IS_RIGHT;
					  //		else if ((ThirdToOne==IS_LEFT) && (ThirdToTwo==IS_RIGHT))   return IS_LEFT;
							else	Result=IS_ON;	break;
		// Line 2 lies on right side of this line
		case IS_RIGHT :if ((ThirdToOne==IS_RIGHT) && (ThirdToTwo==IS_RIGHT))	return IS_RIGHT;
							else if ((ThirdToOne==IS_LEFT) || (ThirdToTwo==IS_LEFT)) return IS_LEFT;
							else	Result=IS_ON;	break;
    default: Result = IS_ON; assert( false );
	}
	return Result;
}
Example #2
0
			const Float3 Triangle::Normal() const
			{
				return Normalize( OutProduct( y - x, z - x ) );
			}