bool Plane::isIntersect(const Line & line, Vector3 * cross) const
{
float distS = distToPoint(line.start);
float distE = distToPoint(line.end);
if(distS * distE > 0)
{
return false;
}
if(cross)
{
*cross = line.interpolation(fabs(distS), fabs(distE));
}
return true;
}
bool Plane::isIntersect(const Vector3 & start, const Vector3 & end, float * pPos) const
{
float distS = distToPoint(start);
float distE = distToPoint(end);
if(distS * distE > 0)
{
return false;
}
if(pPos)
{
*pPos = fabs(distS)/(fabs(distS) + fabs(distE));
}
return true;
}
bool Plane::isSphereIntersect(const Vector3 & center, float radius, Vector3 * cross/*=NULL*/)
{
float ds = distToPoint(center);
if (fabs(ds) > radius)
{
return false;
}
if (cross)
{
*cross = center + normal * ds;
}
return true;
}