Go to the documentation of this file.00001 #ifndef OPENTISSUE_DYNAMICS_MBD_UTIL_MBD_GET_VELOCITY_VECTOR_H
00002 #define OPENTISSUE_DYNAMICS_MBD_UTIL_MBD_GET_VELOCITY_VECTOR_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <OpenTissue/core/math/math_is_number.h>
00013
00014 namespace OpenTissue
00015 {
00016 namespace mbd
00017 {
00026 template<typename indirect_body_iterator,typename vector_type>
00027 void get_velocity_vector(indirect_body_iterator begin, indirect_body_iterator end, vector_type & u)
00028 {
00029 typedef typename indirect_body_iterator::value_type body_type;
00030 typedef typename body_type::math_policy math_policy;
00031 typedef typename body_type::vector3_type vector3_type;
00032 typedef typename vector_type::size_type size_type;
00033
00034 vector3_type V,W;
00035 size_type n = std::distance(begin,end);
00036
00037 math_policy::resize( u, 6*n);
00038
00039 typename vector_type::iterator uval = u.begin();
00040 for(indirect_body_iterator body = begin;body!=end;++body)
00041 {
00042 assert(body->is_active() || !"get_velocity_vector(): body was not active");
00043
00044 body->get_velocity(V);
00045 body->get_spin(W);
00046
00047 assert(is_number(V(0)) || !"get_velocity_vector(): non number encountered");
00048 assert(is_number(V(1)) || !"get_velocity_vector(): non number encountered");
00049 assert(is_number(V(2)) || !"get_velocity_vector(): non number encountered");
00050 assert(is_number(W(0)) || !"get_velocity_vector(): non number encountered");
00051 assert(is_number(W(1)) || !"get_velocity_vector(): non number encountered");
00052 assert(is_number(W(2)) || !"get_velocity_vector(): non number encountered");
00053
00054 *uval++ = V(0);
00055 *uval++ = V(1);
00056 *uval++ = V(2);
00057 *uval++ = W(0);
00058 *uval++ = W(1);
00059 *uval++ = W(2);
00060 }
00061 }
00062
00063 template<typename group_type,typename vector_type>
00064 void get_velocity_vector(group_type const & group, vector_type & u)
00065 {
00066 get_velocity_vector(group.body_begin(),group.body_end(),u);
00067 }
00068
00069 }
00070 }
00071
00072 #endif