Go to the documentation of this file.00001 #ifndef OPENTISSUE_KINEMATICS_INVERSE_INVERSE_GET_JOINT_LIMITS_H
00002 #define OPENTISSUE_KINEMATICS_INVERSE_INVERSE_GET_JOINT_LIMITS_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <OpenTissue/core/math/big/big_types.h>
00013
00014 namespace OpenTissue
00015 {
00016 namespace kinematics
00017 {
00018 namespace inverse
00019 {
00020
00031 template< typename skeleton_type>
00032 inline void get_joint_limits(
00033 skeleton_type const & skeleton
00034 , ublas::vector<typename skeleton_type::bone_traits::real_type> & min_theta
00035 , ublas::vector<typename skeleton_type::bone_traits::real_type> & max_theta
00036 )
00037 {
00038 using ublas::subrange;
00039
00040 typedef typename skeleton_type::bone_traits bone_traits;
00041 typedef typename bone_traits::real_type real_type;
00042 typedef ublas::vector<real_type> vector_type;
00043 typedef ublas::vector_range<vector_type> vector_range;
00044
00045
00046 size_t dofs = 0u;
00047
00048 typename skeleton_type::const_bone_iterator bone = skeleton.begin();
00049 typename skeleton_type::const_bone_iterator end = skeleton.end();
00050
00051 for(;bone!=end;++bone)
00052 {
00053 dofs += bone->active_dofs();
00054 }
00055
00056
00057 if(min_theta.size() != dofs)
00058 min_theta.resize( dofs );
00059 if(max_theta.size() != dofs)
00060 max_theta.resize( dofs );
00061
00062
00063 size_t i = 0u;
00064 size_t dof = 0u;
00065
00066 bone = skeleton.begin();
00067 for(;bone!=end;++bone)
00068 {
00069 dof = bone->active_dofs();
00070
00071 vector_range sub_min = subrange(min_theta,i,i+dof);
00072 vector_range sub_max = subrange(max_theta,i,i+dof);
00073 bone_traits::get_joint_limits( *bone , sub_min, sub_max);
00074
00075 i += dof;
00076 }
00077 }
00078
00079 }
00080 }
00081 }
00082
00083
00084 #endif