int CheckCircleLineCollision(Circle2D C, Line2D L) { double a = DistancePointToLine(C.Center,L); if(a <= C.Radius) return 1; else return 0; }
/** * Find the closest distance from a given point to the interior of a * building's lowest footprint. If the point is inside the footprint, * the value 0.0 is returned. */ double vtBuilding::GetDistanceToInterior(const DPoint2 &point) const { vtLevel *lev = m_Levels[0]; // Ignore holes - a small shortcut, coulbe be addressed later const DLine2 &foot = lev->GetOuterFootprint(); if (foot.ContainsPoint(point)) return 0.0; int i, edges = foot.GetSize(); double dist, closest = 1E8; for (i = 0; i < edges; i++) { DPoint2 p0 = foot[i]; DPoint2 p1 = foot[(i+1)%edges]; dist = DistancePointToLine(p0, p1, point); if (dist < closest) closest = dist; } return closest; }
double iABlobImplicitFunction::JustEvaluateFunction (double x[3]) { LineInfo* line; double value = 0; double pValue, pDist; if (this->mbCount == 0) return 0; line = this->mb; for (unsigned int i = 0; i < this->mbCount; i++, line++) { pValue = line->strength; pDist = DistancePointToLine (line->point1, line->point2, x); if(0 == i) value = pDist; else if(pDist <= value) value = pDist; //value += (pValue / pDist); } //printf("EvalFun: %lf, %lf, %lf = %lf\n", x[0], x[1], x[2], value); return value; }
//カプセルと球の衝突判定 bool CCollision::CollisionCapsuleShpere(const CVector3D &c_top,const CVector3D &c_bottom,float c_radius,const CVector3D &s_center , float s_radius){ float l = DistancePointToLine(c_top,c_bottom,s_center); if(l<=c_radius+s_radius) return true; return false; }