303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
|
// this captures the case that the point is not (almost) in the direction of the element.:
// first, project the problem onto the unit sphere:
Point p_o(p - my_origin);
pt0_o /= pt0_o.norm();
pt1_o /= pt1_o.norm();
pt2_o /= pt2_o.norm();
p_o /= p_o.norm();
// now, check if it is in the projected face; by comparing the distance of
// any point in the element to \p p with the largest distance between this point
// to any other point in the element.
if ((p_o - pt0_o).norm_sq() > std::max((pt0_o - pt1_o).norm_sq(), (pt0_o - pt2_o).norm_sq()) ||
(p_o - pt1_o).norm_sq() > std::max((pt1_o - pt2_o).norm_sq(), (pt1_o - pt0_o).norm_sq()) ||
(p_o - pt2_o).norm_sq() > std::max((pt2_o - pt0_o).norm_sq(), (pt2_o - pt1_o).norm_sq()) )
{
// the physical point is definitely not contained in the element
return false;
}
|