示例#1
0
/* Classifies interior of line segment (not including endpoints) as to whether
 * or not any piece is inside or outside an object represented as a BSP tree.
 * If it's on, it's recursively called on both half-spaces to set the flags.
 * There is no explicit on condition like we have with BSPclassifyPoint().
 * 
 * from    - endpoint of line segment
 * to      - other endpoint of line segment
 * bspNode - a node in BSP tree     
 */
static void BSPclassifyLineInterior(const POINT *from,const POINT *to,
				    const BSPNODE *bspNode)
				    
{
   if (bspNode->kind == PARTITION_NODE) { /* compare line segment with plane */
      float ixx,iyy,izz;
      const PLANE *plane= &bspNode->node->sameDir->plane;
      float dp1= plane->aa*from->xx + plane->bb*from->yy +
	         plane->cc*from->zz + plane->dd;
      float dp2= plane->aa*to->xx + plane->bb*to->yy +
	         plane->cc*to->zz + plane->dd;
      SIGN sign1= FSIGN(dp1); SIGN sign2= FSIGN(dp2);

      if ( (sign1 == NEGATIVE && sign2 == POSITIVE) || 
	   (sign1 == POSITIVE && sign2 == NEGATIVE) ) {	/* split! */
	 SIGN check= anyEdgeIntersectWithPlane(from->xx,from->yy,from->zz,
					       to->xx,to->yy,to->zz,
					       plane,&ixx,&iyy,&izz);
	 POINT iPoint;
	 assert(check != ZERO);
	 
	 /* filter split line segments down appropriate branches */
	 iPoint.xx= ixx; iPoint.yy= iyy; iPoint.zz= izz;
	 if (sign1 == NEGATIVE) { assert(sign2 == POSITIVE);
	    BSPclassifyLineInterior(from,&iPoint,bspNode->node->negativeSide);
	    BSPclassifyLineInterior(to,&iPoint,bspNode->node->positiveSide);
	 }
	 else { assert(sign1 == POSITIVE && sign2 == NEGATIVE); 
	    BSPclassifyLineInterior(from,&iPoint,bspNode->node->positiveSide);
	    BSPclassifyLineInterior(to,&iPoint,bspNode->node->negativeSide);
	 }
      }
      else {			/* no split,so on same side */
	 if (sign1 == ZERO && sign2 == ZERO) {
	    BSPclassifyLineInterior(from,to,bspNode->node->negativeSide);
	    BSPclassifyLineInterior(from,to,bspNode->node->positiveSide);
	 }
	 else if (sign1 == NEGATIVE || sign2 == NEGATIVE) {
	    BSPclassifyLineInterior(from,to,bspNode->node->negativeSide);
	 }
	 else { assert(sign1 == POSITIVE || sign2 == POSITIVE);
	    BSPclassifyLineInterior(from,to,bspNode->node->positiveSide);
	 }
      }
   }
   else if (bspNode->kind == IN_NODE) anyPieceOfLineIn= 1; /* line inside */
   else { assert(bspNode->kind == OUT_NODE); anyPieceOfLineOut= 1; }
} /* BSPclassifyLineInterior() */
示例#2
0
_CRTIMP2_PURE float __CLRCALL_PURE_OR_CDECL _FSinh(float x, float y)
	{	/* compute y*sinh(x), |y| <= 1 */
	short neg;

	switch (_FDtest(&x))
		{	/* test for special codes */
	case _NANCODE:
		return (x);
	case _INFCODE:
		return (y != 0.0F ? x : FSIGN(x) ? -y : y);
	case 0:
		return (x * y);
	default:	/* finite */
		if (y == 0.0F)
			return (x < 0.0F ? -y : y);
		if (x < 0.0F)
			x = -x, neg = 1;
		else
			neg = 0;

		if (x < _FRteps._Float)
			x *= y;	/* x tiny */
		else if (x < 1.0F)
			{
			float w = x * x;

			x += ((p[0] * w + p[1]) * w + p[2]) * w * x;
			x *= y;
			}
		else if (x < _FXbig)
			{	/* worth adding in exp(-x) */
			_FExp(&x, 1.0F, -1);
			x = y * (x - 0.25F / x);
			}
		else
			switch (_FExp(&x, y, -1))
				{	/* report over/underflow */
			case 0:
				_Feraise(_FE_UNDERFLOW);
				break;
			case _INFCODE:
				_Feraise(_FE_OVERFLOW);
				}
		return (neg ? -x : x);
		}
	}