Added Circumcenter function.

This commit is contained in:
Federico Ponchio 2007-10-10 15:11:30 +00:00
parent 1e6b800880
commit 6c762759ab
1 changed files with 16 additions and 0 deletions

View File

@ -24,6 +24,9 @@
History
$Log: not supported by cvs2svn $
Revision 1.15 2007/05/10 09:31:15 cignoni
Corrected InterpolationParameters invocation
Revision 1.14 2007/05/04 16:33:27 ganovelli
moved InterpolationParamaters out the class Triangle
@ -314,6 +317,19 @@ typename TriangleType::ScalarType Perimeter(const TriangleType &t)
Distance(t.P(2),t.P(0));
}
template<class TriangleType>
Point3<typename TriangleType::ScalarType> Circumcenter(const TriangleType &t)
{
typename TriangleType::ScalarType a2 = (t.P(1) - t.P(2)).SquaredNorm();
typename TriangleType::ScalarType b2 = (t.P(2) - t.P(0)).SquaredNorm();
typename TriangleType::ScalarType c2 = (t.P(0) - t.P(1)).SquaredNorm();
Point3<typename TriangleType::ScalarType>c = t.P(0)*a2*(-a2 + b2 + c2) +
t.P(1)*b2*( a2 - b2 + c2) +
t.P(2)*c2*( a2 + b2 - c2);
c /= 2*(a2*b2 + a2*c2 + b2*c2) - a2*a2 - b2*b2 - c2*c2;
return c;
}
template<class TriangleType>
void TrianglePointDistance(const TriangleType &t,
const typename TriangleType::CoordType & q,