Go to the documentation of this file.00001 #ifndef OPENTISSUE_CORE_GEOMETRY_GEOMETRY_COMPUTE_AREA_MIXED_H
00002 #define OPENTISSUE_CORE_GEOMETRY_GEOMETRY_COMPUTE_AREA_MIXED_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <OpenTissue/core/geometry/geometry_is_angle_obtuse.h>
00013 #include <OpenTissue/core/geometry/geometry_is_triangle_obtuse.h>
00014 #include <OpenTissue/core/geometry/geometry_compute_triangle_area.h>
00015 #include <OpenTissue/core/geometry/geometry_cot.h>
00016 #include <OpenTissue/core/math/math_precision.h>
00017
00018 namespace OpenTissue
00019 {
00020 namespace geometry
00021 {
00022
00036 template<typename vector_type>
00037 typename vector_type::value_type compute_area_mixed(vector_type const & p, vector_type const & pi, vector_type const & pj)
00038 {
00039 typedef typename vector_type::value_type real_type;
00040
00041 static const real_type epsilon = math::machine_precision<real_type>();
00042 static const real_type zero = real_type();
00043
00044 real_type area = compute_triangle_area(p,pi,pj);
00045
00046
00047 if(area<epsilon)
00048 return zero;
00049
00050 if (is_triangle_obtuse (p,pi,pj))
00051 {
00052 if (is_angle_obtuse (p,pi,pj))
00053 {
00054 return area/2.0;
00055 }
00056 return area/4.0;
00057 }
00058
00059
00060 return ((cot (pi, p, pj) * sqr_length(p - pj) + cot ( pj, p, pi)* sqr_length(p - pi)) / 8.0);
00061 }
00062
00063 }
00064 }
00065
00066
00067 #endif