Go to the documentation of this file.00001 #ifndef OPENTISSUE_CORE_GEOMETRY_GEOMETRY_COMPUTE_TRIANGLE_AREA_H
00002 #define OPENTISSUE_CORE_GEOMETRY_GEOMETRY_COMPUTE_TRIANGLE_AREA_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <cmath>
00013
00014 namespace OpenTissue
00015 {
00016 namespace geometry
00017 {
00018
00028 template<typename vector_type>
00029 typename vector_type::value_type compute_triangle_area(vector_type const & p,vector_type const & pi,vector_type const & pj)
00030 {
00031 using std::sqrt;
00032
00033 typedef typename vector_type::value_type real_type;
00034
00035 vector_type u = pi-p;
00036 vector_type v = pj-p;
00037
00038
00039 vector_type n = u%v;
00040 real_type area = sqrt(n*n)*.5;
00041
00042
00043
00044
00045
00046 return area;
00047 }
00048
00049 }
00050 }
00051
00052
00053 #endif