Biomechanical Joint Model
 Author: Anderson Maciel

comejoint.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2000 by Anderson Maciel                                 *
00003  *   andi.maciel@gmail.com                                                 *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  **************************************************************************/
00020 
00021 #include        <stdio.h>
00022 
00023 #include        <algebra/comematrix.h>
00024 #include        <kinematics/comejoint.h>
00025 #include        <kinematics/comedof.h>
00026 
00027 COME_Joint::COME_Joint(){
00028 
00029         //position = COME_Point3D();
00030         vpRefreshInvLim();
00031         //shapeList = NULL;
00032         parentJoint = NULL;
00033         //childList = NULL;
00034         numDofs = 0;
00035         dofList = new COME_Dof*[MAXDOF];
00036                                 for( int i = 0; i < MAXDOF; dofList[i++] = NULL );
00037 }
00038 
00039 //COME_Joint::~COME_Joint(){
00040 
00041 //}
00042 
00043 void
00044 COME_Joint::setDescription( char* szDesc ){
00045         description = szDesc;
00046 }
00047 
00048 void
00049 COME_Joint::setDescription( string sDesc ){
00050         description = sDesc;
00051 }
00052 
00053 string
00054 COME_Joint::getDescription(){
00055         return description;
00056 }
00057 
00058 unsigned short int
00059 COME_Joint::getNumDofs(){
00060         return numDofs;
00061 }
00062 
00063 void
00064 COME_Joint::setChanged( bool yesno ){
00065         changed = yesno;
00066 }
00067 
00068 bool
00069 COME_Joint::vpIsChanged( void ){
00070         return changed;
00071 }
00072                 
00073 
00074 COME_Vector3D
00075 COME_Joint::getVectorX(){
00076 
00077         COME_Vector3D *v = new COME_Vector3D( lim.getValueAt(0,0),
00078                                                                                                                                         lim.getValueAt(1,0),
00079                                                                                                                                         lim.getValueAt(2,0) );
00080         return *v;
00081 }
00082 
00083 COME_Vector3D
00084 COME_Joint::getVectorY(){
00085 
00086         COME_Vector3D *v = new COME_Vector3D( lim.getValueAt(0,1),
00087                                                                                                                                         lim.getValueAt(1,1),
00088                                                                                                                                         lim.getValueAt(2,1) );
00089         return *v;
00090 }
00091 
00092 COME_Vector3D
00093 COME_Joint::getVectorZ(){
00094 
00095         COME_Vector3D *v = new COME_Vector3D( lim.getValueAt(0,2),
00096                                                                                                                                         lim.getValueAt(1,2),
00097                                                                                                                                         lim.getValueAt(2,2) );
00098         return *v;
00099 }
00100 
00101 COME_Joint*
00102 COME_Joint::getParent(){
00103 
00104         return parentJoint;
00105 }
00106 
00107 list<COME_Joint*>
00108 COME_Joint::getChildList(){
00109 
00110         return childList;
00111 }
00112 
00113 list<COME_Joint*>*
00114 COME_Joint::getChildListPt(){
00115 
00116         return &childList;
00117 }
00118 
00119 list<COME_BioStructure*>
00120 COME_Joint::getShapeList(){
00121 
00122         return shapeList;
00123 }
00124 
00125 list<COME_BioStructure*>*
00126 COME_Joint::getShapeListPt(){
00127 
00128         return &shapeList;
00129 }
00130 
00131 COME_Dof**
00132 COME_Joint::getDofList(){
00133 
00134         return dofList;
00135 }
00136 
00137 COME_Matrix
00138 COME_Joint::getLim(){
00139 
00140         return lim;
00141 }
00142 
00143 COME_Matrix
00144 COME_Joint::getInvLim(){
00145 
00146         return invLim;
00147 }
00148 
00149 void
00150 COME_Joint::setNumDofs( unsigned short int n ){
00151         numDofs = n;
00152 }
00153 
00154 
00155 void
00156 COME_Joint::setParent( COME_Joint* j ){
00157 
00158         parentJoint = j;
00159 }
00160 
00161 void
00162 COME_Joint::setChildList( list<COME_Joint*> j ){
00163 
00164         childList = j;
00165 }
00166 
00167 void
00168 COME_Joint::setLim( COME_Matrix m ){
00169 
00170         lim = m;
00171 }
00172 
00173 void
00174 COME_Joint::setInvLim( COME_Matrix m ){
00175 
00176         invLim = m;
00177 }
00178 
00179 
00180 void
00181 COME_Joint::vpRefreshInvLim( void ){
00182 
00183 
00184         setInvLim( getLim().getInverse() );
00185 }
00186 
00187 void
00188 COME_Joint::vpAddShape( COME_BioStructure *shape ){
00189 
00190         shapeList.push_back( shape );
00191 }
00192 
00193 void
00194 COME_Joint::vpAddChild( COME_Joint *child ){
00195 
00196         //childList.push_back( child );
00197         childList.push_front( child );
00198 }
00199 
00200 void
00201 COME_Joint::vpAddDof( COME_Dof *dof ){
00202 
00203         if( !dofList ) dofList = new COME_Dof*[MAXDOF];
00204         int ind = -1;
00205         while( dofList[++ind] );
00206         if( ind <= MAXDOF ){
00207                 dofList[ind] = dof;
00208                 numDofs++;
00209         }
00210 }
00211 
00212 void
00213 COME_Joint::vpMakeLim( void ){
00214         
00216         COME_Matrix newLim;
00217                 
00219         for( int        curDof = 0; curDof < getNumDofs(); curDof++ ){
00220                 newLim = newLim * dofList[curDof]->getLim();// * newLim;
00221         }
00222                 
00223         setLim( newLim );
00224         vpRefreshInvLim();
00225         
00226         // Set joint as changed
00227         setChanged( true );
00228 }
00229 
00230 void
00231 COME_Joint::vpMakeGims( COME_Matrix composite ){
00232         
00234         COME_Matrix     newMatrix = getLim() * composite;
00235         
00237         list<COME_BioStructure*>::iterator shapeIter;
00238         for( shapeIter = shapeList.begin(); shapeIter != shapeList.end(); shapeIter++ ){
00239                 COME_Matrix localLIM = (*shapeIter)->getLIM();
00240                 (*shapeIter)->setGIM( localLIM * newMatrix );
00241         }
00242         
00244         list<COME_Joint*>::iterator jointIter;
00245         for( jointIter = childList.begin(); jointIter != childList.end(); jointIter++ ){
00246                 (*jointIter)->vpMakeGims( newMatrix );
00247         }
00248 }
00249 
00250 void
00251 COME_Joint::vpPrintLim( void ){
00252         printf( "%f %f %f %f \n",getLim().getValueAt(0,0), getLim().getValueAt(0,1),
00253                                                                                                 getLim().getValueAt(0,2), getLim().getValueAt(0,3) );
00254   printf( "%f %f %f %f \n",getLim().getValueAt(1,0), getLim().getValueAt(1,1),
00255                                                                                                 getLim().getValueAt(1,2), getLim().getValueAt(1,3) );
00256         printf( "%f %f %f %f \n",getLim().getValueAt(2,0), getLim().getValueAt(2,1),
00257                                                                                                 getLim().getValueAt(2,2), getLim().getValueAt(2,3) );
00258         printf( "%f %f %f %f \n\n",getLim().getValueAt(3,0), getLim().getValueAt(3,1),
00259                                                                                                 getLim().getValueAt(3,2), getLim().getValueAt(3,3) );
00260 }

Generated on Thu Dec 1 10:13:33 2005 for COME - Biomechanical Joint Model by  doxygen 1.4.5