Go to the documentation of this file.00001 #ifndef OPENTISSUE_DYNAMICS_FEM_FEM_COMPUTE_VOLUME_H
00002 #define OPENTISSUE_DYNAMICS_FEM_FEM_COMPUTE_VOLUME_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 namespace OpenTissue
00013 {
00014 namespace fem
00015 {
00016 namespace detail
00017 {
00027 template<typename vector3_type>
00028 inline typename vector3_type::value_type compute_volume(vector3_type const& e10, vector3_type const& e20, vector3_type const& e30)
00029 {
00030 typedef typename vector3_type::value_type real_type;
00031
00032
00033
00034
00035
00036
00037 real_type sixV = e10*(e20 % e30);
00038 return sixV / 6.0;
00039 }
00040
00051 template<typename vector3_type>
00052 inline typename vector3_type::value_type compute_volume(vector3_type const & p0,vector3_type const & p1,vector3_type const & p2,vector3_type const & p3)
00053 {
00054 typedef typename vector3_type::value_type real_type;
00055
00056 real_type d = p0(0);
00057 real_type d4 = p0(1);
00058 real_type d8 = p0(2);
00059 real_type d1 = p1(0) - d;
00060 real_type d5 = p1(1) - d4;
00061 real_type d9 = p1(2) - d8;
00062 real_type d2 = p2(0) - d;
00063 real_type d6 = p2(1) - d4;
00064 real_type d10 = p2(2) - d8;
00065 real_type d3 = p3(0) - d;
00066 real_type d7 = p3(1) - d4;
00067 real_type d11 = p3(2) - d8;
00068 real_type d12 = (d1 * d6 * d11 + d2 * d7 * d9 + d3 * d5 * d10) - d1 * d7 * d10 - d2 * d5 * d11 - d3 * d6 * d9;
00069 return d12 / 6.0;
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086 }
00087
00088 }
00089 }
00090 }
00091
00092
00093 #endif