Хабр Курсы для всех
РЕКЛАМА
Большая витрина: от крупнейших школ до частных авторов. Сравнивайте по цене, длительности, формату и выбирайте самый подходящий курс!
// returns true if projected point on triangle plane is inside triangle
inline bool isInsideTriangle(const Math::Vec3f& pt,const Math::Vec3f& v0,const Math::Vec3f& v1,const Math::Vec3f& v2,const Math::Vec3f& normal)
{
if( CrossProduct(v1-v0,pt-v0).dot(normal)<TRIANGLE_EPSILON )
return false;
if( CrossProduct(pt-v0,v2-v0).dot(normal)<TRIANGLE_EPSILON )
return false;
if( CrossProduct(v1-pt,v2-pt).dot(normal)<TRIANGLE_EPSILON )
return false;
return true;
}
[Неочевидные алгоритмы очевидных вещей] Алгоритм 2. Принадлежность точки треугольнику в пространстве