   Christer Ericsson Point in Polygon with Radius?
  Hello, i am using the formula Point inside polygon from Christer Ericssons book Collision Detection.if anyone have successfully adapt this so the point has a radius of a value. ex the point is still in the polygon (of all vertex) if the point hasn´t cleared with all of its radius.tnx   
  What you'd do is find the point on triangle the closest to your point, of the distance between the polygon and the point, and check if it is within the radius.This is some code I've lifted from Dave Eberly's website, although there are other (and probably simpler, but less efficient) solutions of getting the closest point on a triangle. //-------------------------------------------------------------------// Calculate the squared distance of a point to the triangle//// Nicked code from David Eberly's most excelent physics site// Don't ask me how it works. It just does :)// (http://www.magic-software.com)//// Parameters.// -----------//  : Point in question.// [V0, V1, V2] : triangle vertices.//// return values.// --------------// [s, t] : closest point, in Parametric form (for tex coord reconstruction).// [ClosestPoint] : The point on the triangle the closest, as a vector.// Returns : The squared distance of the point to the triangle.//-------------------------------------------------------------------float PointTriangleDistanceSquared(const Vector& P, const Vector& V0, const Vector& V1, const Vector& V2, float* s, float* t, Vector* pClosestPoint){    //-------------------------------------------------------------------    // 2 edges of the triangle    //-------------------------------------------------------------------    Vector E0    = (V1 - V0);    Vector E1    = (V2 - V0);    Vector kDiff = (V0 -  P);    float fA00 = E0.DotProduct(E0);    float fA01 = E0.DotProduct(E1);    float fA11 = E1.DotProduct(E1);    float fB0  = kDiff.DotProduct(E0);    float fB1  = kDiff.DotProduct(E1);    float fC   = kDiff.DotProduct(kDiff);    float fDet = (float) fabs(fA00*fA11-fA01*fA01);    float fS   = fA01*fB1-fA11*fB0;    float fT   = fA01*fB0-fA00*fB1;    float fSqrDist;//-------------------------------------------------------------------// degenerate triangle//-------------------------------------------------------------------if (fabs(fDet) < 0.000000001f)return -1.0f;    if ( fS + fT <= fDet )    {   if ( fS < (float)0.0 )   {  if ( fT < (float)0.0 )  // region 4  { if ( fB0 < (float)0.0 ) {fT = (float)0.0;if ( -fB0 >= fA00 ){    fS = (float)1.0;    fSqrDist = fA00+((float)2.0)*fB0+fC;}else{    fS = -fB0/fA00;    fSqrDist = fB0*fS+fC;} } else {fS = (float)0.0;if ( fB1 >= (float)0.0 ){    fT = (float)0.0;    fSqrDist = fC;}else if ( -fB1 >= fA11 ){    fT = (float)1.0;    fSqrDist = fA11+((float)2.0)*fB1+fC;}else{    fT = -fB1/fA11;    fSqrDist = fB1*fT+fC;} }  }  else  // region 3  { fS = (float)0.0; if ( fB1 >= (float)0.0 ) {fT = (float)0.0;fSqrDist = fC; } else if ( -fB1 >= fA11 ) {fT = (float)1.0;fSqrDist = fA11+((float)2.0)*fB1+fC; } else {fT = -fB1/fA11;fSqrDist = fB1*fT+fC; }  }   }   else if ( fT < (float)0.0 )  // region 5   {  fT = (float)0.0;  if ( fB0 >= (float)0.0 )  { fS = (float)0.0; fSqrDist = fC;  }  else if ( -fB0 >= fA00 )  { fS = (float)1.0; fSqrDist = fA00+((float)2.0)*fB0+fC;  }  else  { fS = -fB0/fA00; fSqrDist = fB0*fS+fC;  }   }   else  // region 0   {  // minimum at interior point  float fInvDet = ((float)1.0)/fDet;  fS *= fInvDet;  fT *= fInvDet;  fSqrDist = fS*(fA00*fS+fA01*fT+((float)2.0)*fB0) + fT*(fA01*fS+fA11*fT+((float)2.0)*fB1)+fC;   }    }    else    {   float fTmp0, fTmp1, fNumer, fDenom;   if ( fS < (float)0.0 )  // region 2   {  fTmp0 = fA01 + fB0;  fTmp1 = fA11 + fB1;  if ( fTmp1 > fTmp0 )  { fNumer = fTmp1 - fTmp0; fDenom = fA00-2.0f*fA01+fA11; if ( fNumer >= fDenom ) {fS = (float)1.0;fT = (float)0.0;fSqrDist = fA00+((float)2.0)*fB0+fC; } else {fS = fNumer/fDenom;fT = (float)1.0 - fS;fSqrDist = fS*(fA00*fS+fA01*fT+2.0f*fB0) +    fT*(fA01*fS+fA11*fT+((float)2.0)*fB1)+fC; }  }  else  { fS = (float)0.0; if ( fTmp1 <= (float)0.0 ) {fT = (float)1.0;fSqrDist = fA11+((float)2.0)*fB1+fC; } else if ( fB1 >= (float)0.0 ) {fT = (float)0.0;fSqrDist = fC; } else {fT = -fB1/fA11;fSqrDist = fB1*fT+fC; }  }   }   else if ( fT < (float)0.0 )  // region 6   {  fTmp0 = fA01 + fB1;  fTmp1 = fA00 + fB0;  if ( fTmp1 > fTmp0 )  { fNumer = fTmp1 - fTmp0; fDenom = fA00-((float)2.0)*fA01+fA11; if ( fNumer >= fDenom ) {fT = (float)1.0;fS = (float)0.0;fSqrDist = fA11+((float)2.0)*fB1+fC; } else {fT = fNumer/fDenom;fS = (float)1.0 - fT;fSqrDist = fS*(fA00*fS+fA01*fT+((float)2.0)*fB0) +    fT*(fA01*fS+fA11*fT+((float)2.0)*fB1)+fC; }  }  else  { fT = (float)0.0; if ( fTmp1 <= (float)0.0 ) {fS = (float)1.0;fSqrDist = fA00+((float)2.0)*fB0+fC; } else if ( fB0 >= (float)0.0 ) {fS = (float)0.0;fSqrDist = fC; } else {fS = -fB0/fA00;fSqrDist = fB0*fS+fC; }  }   }   else  // region 1   {  fNumer = fA11 + fB1 - fA01 - fB0;  if ( fNumer <= (float)0.0 )  { fS = (float)0.0; fT = (float)1.0; fSqrDist = fA11+((float)2.0)*fB1+fC;  }  else  { fDenom = fA00-2.0f*fA01+fA11; if ( fNumer >= fDenom ) {fS = (float)1.0;fT = (float)0.0;fSqrDist = fA00+((float)2.0)*fB0+fC; } else {fS = fNumer/fDenom;fT = (float)1.0 - fS;fSqrDist = fS*(fA00*fS+fA01*fT+((float)2.0)*fB0) +    fT*(fA01*fS+fA11*fT+((float)2.0)*fB1)+fC; }  }   }    }    if ( s )   *s = fS;    if ( t )   *t = fT;    if ( pClosestPoint )   *pClosestPoint = V0 + (fS * E0) + (fT * E1);return (float) fabs(fSqrDist);}it's in action here.   