00001 #ifndef OPENTISSUE_DYNAMICS_MBD_UTIL_MBD_UPDATE_INERTIA_TENSOR_H
00002 #define OPENTISSUE_DYNAMICS_MBD_UTIL_MBD_UPDATE_INERTIA_TENSOR_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 namespace OpenTissue
00013 {
00014 namespace mbd
00015 {
00028 template<typename matrix3x3_type>
00029 void update_inertia_tensor(matrix3x3_type const & R,matrix3x3_type const & B,matrix3x3_type & W)
00030 {
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 W(0,0) = R(0,0)*R(0,0)*B(0,0) + 2*R(0,0)*R(0,1)*B(0,1)+2*R(0,0)*R(0,2)*B(0,2)+R(0,1)*R(0,1)*B(1,1)+2*R(0,1)*R(0,2)*B(1,2)+R(0,2)*R(0,2)*B(2,2);
00041 W(1,1) = R(1,0)*R(1,0)*B(0,0)+2*R(1,0)*R(1,1)*B(0,1)+2*R(1,0)*R(1,2)*B(0,2)+R(1,1)*R(1,1)*B(1,1)+2*R(1,1)*R(1,2)*B(1,2)+R(1,2)*R(1,2)*B(2,2);
00042 W(2,2) = R(2,0)*R(2,0)*B(0,0)+2*R(2,0)*R(2,1)*B(0,1)+2*R(2,0)*R(2,2)*B(0,2)+R(2,1)*R(2,1)*B(1,1)+2*R(2,1)*R(2,2)*B(1,2)+R(2,2)*R(2,2)*B(2,2);
00043 W(1,0) = W(0,1) = R(1,0)*R(0,0)*B(0,0)+R(1,0)*R(0,1)*B(0,1)+R(1,0)*R(0,2)*B(0,2)+R(1,1)*R(0,0)*B(0,1)+R(1,1)*R(0,1)*B(1,1)+R(1,1)*R(0,2)*B(1,2)+R(1,2)*R(0,0)*B(0,2)+R(1,2)*R(0,1)*B(1,2)+R(1,2)*R(0,2)*B(2,2);
00044 W(2,0) = W(0,2) = R(2,0)*R(0,0)*B(0,0)+R(2,0)*R(0,1)*B(0,1)+R(2,0)*R(0,2)*B(0,2)+R(2,1)*R(0,0)*B(0,1)+R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