Go to the documentation of this file.00001 #ifndef OPENTISSUE_CORE_GEOMETRY_GEOMETRY_COMPUTE_BOX_MASS_PROPERTIES_H
00002 #define OPENTISSUE_CORE_GEOMETRY_GEOMETRY_COMPUTE_BOX_MASS_PROPERTIES_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 namespace OpenTissue
00013 {
00014 namespace geometry
00015 {
00016
00060 template<typename real_type,typename vector3_type>
00061 void compute_box_mass_properties(
00062 vector3_type const & half_size,
00063 real_type const & density,
00064 real_type & mass,
00065 vector3_type & inertia
00066 )
00067 {
00068 real_type V = 8.*half_size(0)*half_size(1)*half_size(2);
00069 mass = density*V;
00070 inertia(0) = ((half_size(1)*half_size(1)+half_size(2)*half_size(2))*mass) / 3. ;
00071 inertia(1) = ((half_size(0)*half_size(0)+half_size(2)*half_size(2))*mass) / 3. ;
00072 inertia(2) = ((half_size(0)*half_size(0)+half_size(1)*half_size(1))*mass) / 3. ;
00073 }
00074
00075 }
00076 }
00077
00078
00079 #endif