00001 #ifndef OPENTISSUE_KINEMATICS_SKELETON_DEFAULT_BONE_TRAITS_H 00002 #define OPENTISSUE_KINEMATICS_SKELETON_DEFAULT_BONE_TRAITS_H 00003 // 00004 // OpenTissue Template Library 00005 // - A generic toolbox for physics-based modeling and simulation. 00006 // Copyright (C) 2008 Department of Computer Science, University of Copenhagen. 00007 // 00008 // OTTL is licensed under zlib: http://opensource.org/licenses/zlib-license.php 00009 // 00010 #include <OpenTissue/configuration.h> 00011 00012 namespace OpenTissue 00013 { 00014 namespace skeleton 00015 { 00016 00027 template<typename math_types_> 00028 class DefaultBoneTraits 00029 { 00030 public: 00031 00032 typedef math_types_ math_types; 00033 typedef typename math_types::coordsys_type transform_type; 00034 typedef typename math_types::coordsys_type coordsys_type; 00035 typedef typename math_types::vector3_type vector3_type; 00036 00050 static coordsys_type convert(coordsys_type const & T) 00051 { 00052 return T; 00053 } 00054 00060 static transform_type get_identity_transform() 00061 { 00062 static transform_type T;// default constructed coordsys is set to identity transformation. 00063 return T; 00064 } 00065 00074 static transform_type compute_absolute_pose_transform( transform_type const & parent, transform_type const & relative) 00075 { 00076 transform_type absolute; 00077 absolute.T() = parent.Q().rotate( relative.T() ) + parent.T(); 00078 absolute.Q() = prod( parent.Q() , relative.Q() ); 00079 return absolute; 00080 } 00081 00090 static transform_type compute_bone_space_transform( transform_type const & absolute, transform_type const & bone_space) 00091 { 00092 transform_type bone_space_transform; 00093 bone_space_transform.T() = absolute.Q().rotate( bone_space.T() ) + absolute.T(); 00094 bone_space_transform.Q() = prod( absolute.Q() , bone_space.Q() ); 00095 return bone_space_transform; 00096 } 00097 00106 static vector3_type transform_point(transform_type const & T, vector3_type const & x) 00107 { 00108 vector3_type tmp(x); 00109 T.xform_point(tmp); 00110 return tmp; 00111 } 00112 00121 static vector3_type transform_vector(transform_type const & T, vector3_type const & v) 00122 { 00123 vector3_type tmp(v); 00124 T.xform_vector(tmp); 00125 return tmp; 00126 } 00127 00128 }; 00129 00130 } // namespace skeleton 00131 } // namespace OpenTissue 00132 00133 //OPENTISSUE_KINEMATICS_SKELETON_DEFAULT_BONE_TRAITS_H 00134 #endif