SIA20D_Mesh_manipulator_ikfast_output.cpp
Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 #include <cmath>
00021 #include <vector>
00022 #include <limits>
00023 #include <algorithm>
00024 #include <complex>
00025 
00026 #ifdef IKFAST_HEADER
00027 #include IKFAST_HEADER
00028 #endif
00029 
00030 #ifndef IKFAST_ASSERT
00031 #include <stdexcept>
00032 #include <sstream>
00033 #include <iostream>
00034 
00035 #ifdef _MSC_VER
00036 #ifndef __PRETTY_FUNCTION__
00037 #define __PRETTY_FUNCTION__ __FUNCDNAME__
00038 #endif
00039 #endif
00040 
00041 #ifndef __PRETTY_FUNCTION__
00042 #define __PRETTY_FUNCTION__ __func__
00043 #endif
00044 
00045 #define IKFAST_ASSERT(b) { if( !(b) ) { std::stringstream ss; ss << "ikfast exception: " << __FILE__ << ":" << __LINE__ << ": " <<__PRETTY_FUNCTION__ << ": Assertion '" << #b << "' failed"; throw std::runtime_error(ss.str()); } }
00046 
00047 #endif
00048 
00049 #if defined(_MSC_VER)
00050 #define IKFAST_ALIGNED16(x) __declspec(align(16)) x
00051 #else
00052 #define IKFAST_ALIGNED16(x) x __attribute((aligned(16)))
00053 #endif
00054 
00055 #define IK2PI  ((IKReal)6.28318530717959)
00056 #define IKPI  ((IKReal)3.14159265358979)
00057 #define IKPI_2  ((IKReal)1.57079632679490)
00058 
00059 #ifdef _MSC_VER
00060 #ifndef isnan
00061 #define isnan _isnan
00062 #endif
00063 #endif // _MSC_VER
00064 
00065 // defined when creating a shared object/dll
00066 #ifdef IKFAST_CLIBRARY
00067 #ifdef _MSC_VER
00068 #define IKFAST_API extern "C" __declspec(dllexport)
00069 #else
00070 #define IKFAST_API extern "C"
00071 #endif
00072 #else
00073 #define IKFAST_API
00074 #endif
00075 
00076 // lapack routines
00077 extern "C" {
00078   void dgetrf_ (const int* m, const int* n, double* a, const int* lda, int* ipiv, int* info);
00079   void zgetrf_ (const int* m, const int* n, std::complex<double>* a, const int* lda, int* ipiv, int* info);
00080   void dgetri_(const int* n, const double* a, const int* lda, int* ipiv, double* work, const int* lwork, int* info);
00081   void dgesv_ (const int* n, const int* nrhs, double* a, const int* lda, int* ipiv, double* b, const int* ldb, int* info);
00082   void dgetrs_(const char *trans, const int *n, const int *nrhs, double *a, const int *lda, int *ipiv, double *b, const int *ldb, int *info);
00083   void dgeev_(const char *jobvl, const char *jobvr, const int *n, double *a, const int *lda, double *wr, double *wi,double *vl, const int *ldvl, double *vr, const int *ldvr, double *work, const int *lwork, int *info);
00084 }
00085 
00086 using namespace std; // necessary to get std math routines
00087 
00088 #ifdef IKFAST_NAMESPACE
00089 namespace IKFAST_NAMESPACE {
00090 #endif
00091 
00092 #ifdef IKFAST_REAL
00093 typedef IKFAST_REAL IKReal;
00094 #else
00095 typedef double IKReal;
00096 #endif
00097 
00098 class IKSolution
00099 {
00100 public:
00103     void GetSolution(IKReal* psolution, const IKReal* pfree) const {
00104         for(std::size_t i = 0; i < basesol.size(); ++i) {
00105             if( basesol[i].freeind < 0 )
00106                 psolution[i] = basesol[i].foffset;
00107             else {
00108                 IKFAST_ASSERT(pfree != NULL);
00109                 psolution[i] = pfree[basesol[i].freeind]*basesol[i].fmul + basesol[i].foffset;
00110                 if( psolution[i] > IKPI ) {
00111                     psolution[i] -= IK2PI;
00112                 }
00113                 else if( psolution[i] < -IKPI ) {
00114                     psolution[i] += IK2PI;
00115                 }
00116             }
00117         }
00118     }
00119 
00122     const std::vector<int>& GetFree() const { return vfree; }
00123 
00124     struct VARIABLE
00125     {
00126         VARIABLE() : fmul(0), foffset(0), freeind(-1), maxsolutions(1) {
00127             indices[0] = indices[1] = -1;
00128         }
00129         IKReal fmul, foffset; 
00130         signed char freeind; 
00131         unsigned char maxsolutions; 
00132         unsigned char indices[2]; 
00133     };
00134 
00135     std::vector<VARIABLE> basesol;       
00136     std::vector<int> vfree;
00137 
00138     bool Validate() const {
00139         for(size_t i = 0; i < basesol.size(); ++i) {
00140             if( basesol[i].maxsolutions == (unsigned char)-1) {
00141                 return false;
00142             }
00143             if( basesol[i].maxsolutions > 0 ) {
00144                 if( basesol[i].indices[0] >= basesol[i].maxsolutions ) {
00145                     return false;
00146                 }
00147                 if( basesol[i].indices[1] != (unsigned char)-1 && basesol[i].indices[1] >= basesol[i].maxsolutions ) {
00148                     return false;
00149                 }
00150             }
00151         }
00152         return true;
00153     }
00154 
00155     void GetSolutionIndices(std::vector<unsigned int>& v) const {
00156         v.resize(0);
00157         v.push_back(0);
00158         for(int i = (int)basesol.size()-1; i >= 0; --i) {
00159             if( basesol[i].maxsolutions != (unsigned char)-1 && basesol[i].maxsolutions > 1 ) {
00160                 for(size_t j = 0; j < v.size(); ++j) {
00161                     v[j] *= basesol[i].maxsolutions;
00162                 }
00163                 size_t orgsize=v.size();
00164                 if( basesol[i].indices[1] != (unsigned char)-1 ) {
00165                     for(size_t j = 0; j < orgsize; ++j) {
00166                         v.push_back(v[j]+basesol[i].indices[1]);
00167                     }
00168                 }
00169                 if( basesol[i].indices[0] != (unsigned char)-1 ) {
00170                     for(size_t j = 0; j < orgsize; ++j) {
00171                         v[j] += basesol[i].indices[0];
00172                     }
00173                 }
00174             }
00175         }
00176     }
00177 };
00178 
00179 inline float IKabs(float f) { return fabsf(f); }
00180 inline double IKabs(double f) { return fabs(f); }
00181 
00182 inline float IKsqr(float f) { return f*f; }
00183 inline double IKsqr(double f) { return f*f; }
00184 
00185 inline float IKlog(float f) { return logf(f); }
00186 inline double IKlog(double f) { return log(f); }
00187 
00188 // allows asin and acos to exceed 1
00189 #ifndef IKFAST_SINCOS_THRESH
00190 #define IKFAST_SINCOS_THRESH ((IKReal)0.000001)
00191 #endif
00192 
00193 // used to check input to atan2 for degenerate cases
00194 #ifndef IKFAST_ATAN2_MAGTHRESH
00195 #define IKFAST_ATAN2_MAGTHRESH ((IKReal)2e-6)
00196 #endif
00197 
00198 // minimum distance of separate solutions
00199 #ifndef IKFAST_SOLUTION_THRESH
00200 #define IKFAST_SOLUTION_THRESH ((IKReal)1e-6)
00201 #endif
00202 
00203 inline float IKasin(float f)
00204 {
00205 IKFAST_ASSERT( f > -1-IKFAST_SINCOS_THRESH && f < 1+IKFAST_SINCOS_THRESH ); // any more error implies something is wrong with the solver
00206 if( f <= -1 ) return -IKPI_2;
00207 else if( f >= 1 ) return IKPI_2;
00208 return asinf(f);
00209 }
00210 inline double IKasin(double f)
00211 {
00212 IKFAST_ASSERT( f > -1-IKFAST_SINCOS_THRESH && f < 1+IKFAST_SINCOS_THRESH ); // any more error implies something is wrong with the solver
00213 if( f <= -1 ) return -IKPI_2;
00214 else if( f >= 1 ) return IKPI_2;
00215 return asin(f);
00216 }
00217 
00218 // return positive value in [0,y)
00219 inline float IKfmod(float x, float y)
00220 {
00221     while(x < 0) {
00222         x += y;
00223     }
00224     return fmodf(x,y);
00225 }
00226 
00227 // return positive value in [0,y)
00228 inline float IKfmod(double x, double y)
00229 {
00230     while(x < 0) {
00231         x += y;
00232     }
00233     return fmod(x,y);
00234 }
00235 
00236 inline float IKacos(float f)
00237 {
00238 IKFAST_ASSERT( f > -1-IKFAST_SINCOS_THRESH && f < 1+IKFAST_SINCOS_THRESH ); // any more error implies something is wrong with the solver
00239 if( f <= -1 ) return IKPI;
00240 else if( f >= 1 ) return 0;
00241 return acosf(f);
00242 }
00243 inline double IKacos(double f)
00244 {
00245 IKFAST_ASSERT( f > -1-IKFAST_SINCOS_THRESH && f < 1+IKFAST_SINCOS_THRESH ); // any more error implies something is wrong with the solver
00246 if( f <= -1 ) return IKPI;
00247 else if( f >= 1 ) return 0;
00248 return acos(f);
00249 }
00250 inline float IKsin(float f) { return sinf(f); }
00251 inline double IKsin(double f) { return sin(f); }
00252 inline float IKcos(float f) { return cosf(f); }
00253 inline double IKcos(double f) { return cos(f); }
00254 inline float IKtan(float f) { return tanf(f); }
00255 inline double IKtan(double f) { return tan(f); }
00256 inline float IKsqrt(float f) { if( f <= 0.0f ) return 0.0f; return sqrtf(f); }
00257 inline double IKsqrt(double f) { if( f <= 0.0 ) return 0.0; return sqrt(f); }
00258 inline float IKatan2(float fy, float fx) {
00259     if( isnan(fy) ) {
00260         IKFAST_ASSERT(!isnan(fx)); // if both are nan, probably wrong value will be returned
00261         return IKPI_2;
00262     }
00263     else if( isnan(fx) ) {
00264         return 0;
00265     }
00266     return atan2f(fy,fx);
00267 }
00268 inline double IKatan2(double fy, double fx) {
00269     if( isnan(fy) ) {
00270         IKFAST_ASSERT(!isnan(fx)); // if both are nan, probably wrong value will be returned
00271         return IKPI_2;
00272     }
00273     else if( isnan(fx) ) {
00274         return 0;
00275     }
00276     return atan2(fy,fx);
00277 }
00278 
00279 inline float IKsign(float f) {
00280     if( f > 0 ) {
00281         return 1.0f;
00282     }
00283     else if( f < 0 ) {
00284         return -1.0f;
00285     }
00286     return 0;
00287 }
00288 
00289 inline double IKsign(double f) {
00290     if( f > 0 ) {
00291         return 1.0;
00292     }
00293     else if( f < 0 ) {
00294         return -1.0;
00295     }
00296     return 0;
00297 }
00298 
00301 IKFAST_API void fk(const IKReal* j, IKReal* eetrans, IKReal* eerot) {
00302 IKReal x0,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,x16,x17,x18,x19,x20,x21,x22,x23,x24,x25,x26,x27,x28,x29,x30,x31,x32,x33,x34,x35,x36,x37,x38,x39,x40,x41,x42,x43,x44,x45,x46,x47,x48,x49,x50,x51,x52,x53,x54,x55,x56,x57,x58,x59,x60,x61,x62,x63,x64,x65,x66,x67,x68,x69,x70,x71,x72,x73,x74;
00303 x0=IKcos(j[0]);
00304 x1=IKcos(j[1]);
00305 x2=IKcos(j[2]);
00306 x3=IKsin(j[0]);
00307 x4=IKsin(j[2]);
00308 x5=IKsin(j[3]);
00309 x6=((x3)*(x4));
00310 x7=((x0)*(x1)*(x2));
00311 x8=IKcos(j[3]);
00312 x9=IKsin(j[1]);
00313 x10=IKcos(j[4]);
00314 x11=((x7)+(((-1.00000000000000)*(x6))));
00315 x12=((x11)*(x8));
00316 x13=((x0)*(x5)*(x9));
00317 x14=((x13)+(x12));
00318 x15=((x2)*(x3));
00319 x16=((x0)*(x1)*(x4));
00320 x17=((x15)+(x16));
00321 x18=IKsin(j[4]);
00322 x19=IKsin(j[6]);
00323 x20=IKsin(j[5]);
00324 x21=((x6)+(((-1.00000000000000)*(x7))));
00325 x22=((x21)*(x5));
00326 x23=((x0)*(x8)*(x9));
00327 x24=((x22)+(x23));
00328 x25=((x20)*(x24));
00329 x26=IKcos(j[5]);
00330 x27=((x10)*(x14));
00331 x28=((x17)*(x18));
00332 x29=((x27)+(x28));
00333 x30=((x26)*(x29));
00334 x31=((x30)+(x25));
00335 x32=IKcos(j[6]);
00336 x33=((x10)*(x17));
00337 x34=((-1.00000000000000)*(x14));
00338 x35=((x18)*(x34));
00339 x36=((x33)+(x35));
00340 x37=((x0)*(x4));
00341 x38=((x1)*(x15));
00342 x39=((x38)+(x37));
00343 x40=((x1)*(x6));
00344 x41=((x0)*(x2));
00345 x42=((((-1.00000000000000)*(x41)))+(x40));
00346 x43=((x39)*(x8));
00347 x44=((x3)*(x5)*(x9));
00348 x45=((x44)+(x43));
00349 x46=((-1.00000000000000)*(x39));
00350 x47=((x46)*(x5));
00351 x48=((x3)*(x8)*(x9));
00352 x49=((x48)+(x47));
00353 x50=((x20)*(x49));
00354 x51=((x18)*(x42));
00355 x52=((x10)*(x45));
00356 x53=((x51)+(x52));
00357 x54=((x26)*(x53));
00358 x55=((x54)+(x50));
00359 x56=((x10)*(x42));
00360 x57=((-1.00000000000000)*(x45));
00361 x58=((x18)*(x57));
00362 x59=((x58)+(x56));
00363 x60=((x1)*(x5));
00364 x61=((x2)*(x8)*(x9));
00365 x62=((x10)*(x4)*(x9));
00366 x63=((x61)+(((-1.00000000000000)*(x60))));
00367 x64=((x18)*(x63));
00368 x65=((x60)+(((-1.00000000000000)*(x61))));
00369 x66=((x10)*(x65));
00370 x67=((x18)*(x4)*(x9));
00371 x68=((x66)+(((-1.00000000000000)*(x67))));
00372 x69=((x26)*(x68));
00373 x70=((x2)*(x5)*(x9));
00374 x71=((x1)*(x8));
00375 x72=((x71)+(x70));
00376 x73=((x20)*(x72));
00377 x74=((x73)+(x69));
00378 eerot[0]=((((x19)*(x36)))+(((x31)*(x32))));
00379 eerot[1]=((((x19)*(x31)))+(((-1.00000000000000)*(x32)*(x36))));
00380 eerot[2]=((((-1.00000000000000)*(x20)*(x29)))+(((x24)*(x26))));
00381 eetrans[0]=((((0.420000000000000)*(x23)))+(((x26)*(((((0.180000000000000)*(x23)))+(((0.180000000000000)*(x22)))))))+(((x20)*(((((-0.180000000000000)*(x27)))+(((-0.180000000000000)*(x28)))))))+(((x5)*(((((-0.420000000000000)*(x7)))+(((0.420000000000000)*(x6)))))))+(((0.490000000000000)*(x0)*(x9))));
00382 eerot[3]=((((x19)*(x59)))+(((x32)*(x55))));
00383 eerot[4]=((((-1.00000000000000)*(x32)*(x59)))+(((x19)*(x55))));
00384 eerot[5]=((((x26)*(x49)))+(((-1.00000000000000)*(x20)*(x53))));
00385 eetrans[1]=((((x26)*(((((0.180000000000000)*(x47)))+(((0.180000000000000)*(x48)))))))+(((0.490000000000000)*(x3)*(x9)))+(((x5)*(((((-0.420000000000000)*(x37)))+(((-0.420000000000000)*(x38)))))))+(((x20)*(((((-0.180000000000000)*(x52)))+(((-0.180000000000000)*(x51)))))))+(((0.420000000000000)*(x48))));
00386 eerot[6]=((((x32)*(x74)))+(((x19)*(((x64)+(((-1.00000000000000)*(x62))))))));
00387 eerot[7]=((((x32)*(((x62)+(((-1.00000000000000)*(x64)))))))+(((x19)*(x74))));
00388 eerot[8]=((((x26)*(x72)))+(((x20)*(((x67)+(((-1.00000000000000)*(x66))))))));
00389 eetrans[2]=((0.410000000000000)+(((x26)*(((((0.180000000000000)*(x71)))+(((0.180000000000000)*(x70)))))))+(((x20)*(((((-0.180000000000000)*(x66)))+(((0.180000000000000)*(x67)))))))+(((0.420000000000000)*(x70)))+(((0.420000000000000)*(x71)))+(((0.490000000000000)*(x1))));
00390 }
00391 
00392 IKFAST_API int getNumFreeParameters() { return 1; }
00393 IKFAST_API int* getFreeParameters() { static int freeparams[] = {2}; return freeparams; }
00394 IKFAST_API int getNumJoints() { return 7; }
00395 
00396 IKFAST_API int getIKRealSize() { return sizeof(IKReal); }
00397 
00398 IKFAST_API int getIKType() { return 0x67000001; }
00399 
00400 class IKSolver {
00401 public:
00402 IKReal j0,cj0,sj0,htj0,j1,cj1,sj1,htj1,j3,cj3,sj3,htj3,j4,cj4,sj4,htj4,j5,cj5,sj5,htj5,j6,cj6,sj6,htj6,j2,cj2,sj2,htj2,new_r00,r00,rxp0_0,new_r01,r01,rxp0_1,new_r02,r02,rxp0_2,new_r10,r10,rxp1_0,new_r11,r11,rxp1_1,new_r12,r12,rxp1_2,new_r20,r20,rxp2_0,new_r21,r21,rxp2_1,new_r22,r22,rxp2_2,new_px,px,npx,new_py,py,npy,new_pz,pz,npz,pp;
00403 unsigned char _ij0[2], _nj0,_ij1[2], _nj1,_ij3[2], _nj3,_ij4[2], _nj4,_ij5[2], _nj5,_ij6[2], _nj6,_ij2[2], _nj2;
00404 
00405 bool ik(const IKReal* eetrans, const IKReal* eerot, const IKReal* pfree, std::vector<IKSolution>& vsolutions) {
00406 j0=numeric_limits<IKReal>::quiet_NaN(); _ij0[0] = -1; _ij0[1] = -1; _nj0 = -1; j1=numeric_limits<IKReal>::quiet_NaN(); _ij1[0] = -1; _ij1[1] = -1; _nj1 = -1; j3=numeric_limits<IKReal>::quiet_NaN(); _ij3[0] = -1; _ij3[1] = -1; _nj3 = -1; j4=numeric_limits<IKReal>::quiet_NaN(); _ij4[0] = -1; _ij4[1] = -1; _nj4 = -1; j5=numeric_limits<IKReal>::quiet_NaN(); _ij5[0] = -1; _ij5[1] = -1; _nj5 = -1; j6=numeric_limits<IKReal>::quiet_NaN(); _ij6[0] = -1; _ij6[1] = -1; _nj6 = -1;  _ij2[0] = -1; _ij2[1] = -1; _nj2 = 0; 
00407 for(int dummyiter = 0; dummyiter < 1; ++dummyiter) {
00408     vsolutions.resize(0); vsolutions.reserve(8);
00409 j2=pfree[0]; cj2=cos(pfree[0]); sj2=sin(pfree[0]);
00410 r00 = eerot[0*3+0];
00411 r01 = eerot[0*3+1];
00412 r02 = eerot[0*3+2];
00413 r10 = eerot[1*3+0];
00414 r11 = eerot[1*3+1];
00415 r12 = eerot[1*3+2];
00416 r20 = eerot[2*3+0];
00417 r21 = eerot[2*3+1];
00418 r22 = eerot[2*3+2];
00419 px = eetrans[0]; py = eetrans[1]; pz = eetrans[2];
00420 
00421 new_r00=r00;
00422 new_r01=((-1.00000000000000)*(r01));
00423 new_r02=((-1.00000000000000)*(r02));
00424 new_px=((((-0.180000000000000)*(r02)))+(px));
00425 new_r10=r10;
00426 new_r11=((-1.00000000000000)*(r11));
00427 new_r12=((-1.00000000000000)*(r12));
00428 new_py=((py)+(((-0.180000000000000)*(r12))));
00429 new_r20=r20;
00430 new_r21=((-1.00000000000000)*(r21));
00431 new_r22=((-1.00000000000000)*(r22));
00432 new_pz=((-0.410000000000000)+(((-0.180000000000000)*(r22)))+(pz));
00433 r00 = new_r00; r01 = new_r01; r02 = new_r02; r10 = new_r10; r11 = new_r11; r12 = new_r12; r20 = new_r20; r21 = new_r21; r22 = new_r22; px = new_px; py = new_py; pz = new_pz;
00434 pp=(((px)*(px))+((py)*(py))+((pz)*(pz)));
00435 npx=((((px)*(r00)))+(((py)*(r10)))+(((pz)*(r20))));
00436 npy=((((px)*(r01)))+(((py)*(r11)))+(((pz)*(r21))));
00437 npz=((((px)*(r02)))+(((py)*(r12)))+(((pz)*(r22))));
00438 rxp0_0=((((-1.00000000000000)*(py)*(r20)))+(((pz)*(r10))));
00439 rxp0_1=((((px)*(r20)))+(((-1.00000000000000)*(pz)*(r00))));
00440 rxp0_2=((((-1.00000000000000)*(px)*(r10)))+(((py)*(r00))));
00441 rxp1_0=((((-1.00000000000000)*(py)*(r21)))+(((pz)*(r11))));
00442 rxp1_1=((((px)*(r21)))+(((-1.00000000000000)*(pz)*(r01))));
00443 rxp1_2=((((-1.00000000000000)*(px)*(r11)))+(((py)*(r01))));
00444 rxp2_0=((((-1.00000000000000)*(py)*(r22)))+(((pz)*(r12))));
00445 rxp2_1=((((px)*(r22)))+(((-1.00000000000000)*(pz)*(r02))));
00446 rxp2_2=((((-1.00000000000000)*(px)*(r12)))+(((py)*(r02))));
00447 {
00448 IKReal j3array[2], cj3array[2], sj3array[2];
00449 bool j3valid[2]={false};
00450 _nj3 = 2;
00451 cj3array[0]=((-1.01190476190476)+(((2.42954324586978)*(pp))));
00452 if( cj3array[0] >= -1-IKFAST_SINCOS_THRESH && cj3array[0] <= 1+IKFAST_SINCOS_THRESH )
00453 {
00454     j3valid[0] = j3valid[1] = true;
00455     j3array[0] = IKacos(cj3array[0]);
00456     sj3array[0] = IKsin(j3array[0]);
00457     cj3array[1] = cj3array[0];
00458     j3array[1] = -j3array[0];
00459     sj3array[1] = -sj3array[0];
00460 }
00461 else if( isnan(cj3array[0]) )
00462 {
00463     // probably any value will work
00464     j3valid[0] = true;
00465     cj3array[0] = 1; sj3array[0] = 0; j3array[0] = 0;
00466 }
00467 for(int ij3 = 0; ij3 < 2; ++ij3)
00468 {
00469 if( !j3valid[ij3] )
00470 {
00471     continue;
00472 }
00473 _ij3[0] = ij3; _ij3[1] = -1;
00474 for(int iij3 = ij3+1; iij3 < 2; ++iij3)
00475 {
00476 if( j3valid[iij3] && IKabs(cj3array[ij3]-cj3array[iij3]) < IKFAST_SOLUTION_THRESH && IKabs(sj3array[ij3]-sj3array[iij3]) < IKFAST_SOLUTION_THRESH )
00477 {
00478     j3valid[iij3]=false; _ij3[1] = iij3; break; 
00479 }
00480 }
00481 j3 = j3array[ij3]; cj3 = cj3array[ij3]; sj3 = sj3array[ij3];
00482 
00483 {
00484 IKReal dummyeval[1];
00485 dummyeval[0]=(((px)*(px))+((py)*(py)));
00486 if( IKabs(dummyeval[0]) < 0.0000010000000000  )
00487 {
00488 {
00489 IKReal dummyeval[1];
00490 dummyeval[0]=(((px)*(px))+((py)*(py)));
00491 if( IKabs(dummyeval[0]) < 0.0000010000000000  )
00492 {
00493 {
00494 IKReal dummyeval[1];
00495 dummyeval[0]=((1.36111111111111)+((cj3)*(cj3))+((((cj2)*(cj2))*((sj3)*(sj3))))+(((2.33333333333333)*(cj3))));
00496 if( IKabs(dummyeval[0]) < 0.0000010000000000  )
00497 {
00498 continue;
00499 
00500 } else
00501 {
00502 {
00503 IKReal j1array[2], cj1array[2], sj1array[2];
00504 bool j1valid[2]={false};
00505 _nj1 = 2;
00506 IKReal x75=((0.420000000000000)*(cj3));
00507 IKReal x76=(cj2)*(cj2);
00508 IKReal x77=(sj3)*(sj3);
00509 IKReal x78=((0.176400000000000)*(x76)*(x77));
00510 IKReal x79=((0.490000000000000)+(x75));
00511 IKReal x80=(x79)*(x79);
00512 IKReal x81=((x78)+(x80));
00513 if( (x81) < (IKReal)-0.00001 )
00514     continue;
00515 IKReal x82=IKsqrt(x81);
00516 IKReal x83=IKabs(x82);
00517 IKReal x84=((IKabs(x83) != 0)?((IKReal)1/(x83)):(IKReal)1.0e30);
00518 IKReal x85=((pz)*(x84));
00519 if( (x85) < -1-IKFAST_SINCOS_THRESH || (x85) > 1+IKFAST_SINCOS_THRESH )
00520     continue;
00521 IKReal x86=IKasin(x85);
00522 IKReal x87=((-0.490000000000000)+(((-1.00000000000000)*(x75))));
00523 IKReal x88=((-0.420000000000000)*(cj2)*(sj3));
00524 if( IKabs(x87) < IKFAST_ATAN2_MAGTHRESH && IKabs(x88) < IKFAST_ATAN2_MAGTHRESH )
00525     continue;
00526 IKReal x89=IKatan2(x87, x88);
00527 j1array[0]=((((-1.00000000000000)*(x89)))+(((-1.00000000000000)*(x86))));
00528 sj1array[0]=IKsin(j1array[0]);
00529 cj1array[0]=IKcos(j1array[0]);
00530 j1array[1]=((3.14159265358979)+(x86)+(((-1.00000000000000)*(x89))));
00531 sj1array[1]=IKsin(j1array[1]);
00532 cj1array[1]=IKcos(j1array[1]);
00533 if( j1array[0] > IKPI )
00534 {
00535     j1array[0]-=IK2PI;
00536 }
00537 else if( j1array[0] < -IKPI )
00538 {    j1array[0]+=IK2PI;
00539 }
00540 j1valid[0] = true;
00541 if( j1array[1] > IKPI )
00542 {
00543     j1array[1]-=IK2PI;
00544 }
00545 else if( j1array[1] < -IKPI )
00546 {    j1array[1]+=IK2PI;
00547 }
00548 j1valid[1] = true;
00549 for(int ij1 = 0; ij1 < 2; ++ij1)
00550 {
00551 if( !j1valid[ij1] )
00552 {
00553     continue;
00554 }
00555 _ij1[0] = ij1; _ij1[1] = -1;
00556 for(int iij1 = ij1+1; iij1 < 2; ++iij1)
00557 {
00558 if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
00559 {
00560     j1valid[iij1]=false; _ij1[1] = iij1; break; 
00561 }
00562 }
00563 j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
00564 
00565 {
00566 IKReal dummyeval[1];
00567 IKReal gconst0;
00568 gconst0=IKsign(((((-2450.00000000000)*(sj1)*((px)*(px))))+(((-2450.00000000000)*(sj1)*((py)*(py))))));
00569 dummyeval[0]=((((-1.00000000000000)*(sj1)*((py)*(py))))+(((-1.00000000000000)*(sj1)*((px)*(px)))));
00570 if( IKabs(dummyeval[0]) < 0.0000010000000000  )
00571 {
00572 {
00573 IKReal evalcond[5];
00574 IKReal x90=((0.420000000000000)*(cj3));
00575 evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(j1)), 6.28318530717959)));
00576 evalcond[1]=((0.416500000000000)+(((0.411600000000000)*(cj3)))+(((-1.00000000000000)*(pp))));
00577 evalcond[2]=((-0.490000000000000)+(pz)+(((-1.00000000000000)*(x90))));
00578 evalcond[3]=((-0.0637000000000000)+(((0.980000000000000)*(pz)))+(((-1.00000000000000)*(pp))));
00579 evalcond[4]=((0.490000000000000)+(x90)+(((-1.00000000000000)*(pz))));
00580 if( IKabs(evalcond[0]) < 0.0000010000000000  && IKabs(evalcond[1]) < 0.0000010000000000  && IKabs(evalcond[2]) < 0.0000010000000000  && IKabs(evalcond[3]) < 0.0000010000000000  && IKabs(evalcond[4]) < 0.0000010000000000  )
00581 {
00582 {
00583 IKReal dummyeval[1];
00584 IKReal gconst1;
00585 gconst1=IKsign(((((-50.0000000000000)*((px)*(px))))+(((-50.0000000000000)*((py)*(py))))));
00586 dummyeval[0]=((((-1.00000000000000)*((px)*(px))))+(((-1.00000000000000)*((py)*(py)))));
00587 if( IKabs(dummyeval[0]) < 0.0000010000000000  )
00588 {
00589 continue;
00590 
00591 } else
00592 {
00593 {
00594 IKReal j0array[1], cj0array[1], sj0array[1];
00595 bool j0valid[1]={false};
00596 _nj0 = 1;
00597 if( IKabs(((gconst1)*(((((-21.0000000000000)*(px)*(sj2)*(sj3)))+(((21.0000000000000)*(cj2)*(py)*(sj3))))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((gconst1)*(((((21.0000000000000)*(cj2)*(px)*(sj3)))+(((21.0000000000000)*(py)*(sj2)*(sj3))))))) < IKFAST_ATAN2_MAGTHRESH )
00598     continue;
00599 j0array[0]=IKatan2(((gconst1)*(((((-21.0000000000000)*(px)*(sj2)*(sj3)))+(((21.0000000000000)*(cj2)*(py)*(sj3)))))), ((gconst1)*(((((21.0000000000000)*(cj2)*(px)*(sj3)))+(((21.0000000000000)*(py)*(sj2)*(sj3)))))));
00600 sj0array[0]=IKsin(j0array[0]);
00601 cj0array[0]=IKcos(j0array[0]);
00602 if( j0array[0] > IKPI )
00603 {
00604     j0array[0]-=IK2PI;
00605 }
00606 else if( j0array[0] < -IKPI )
00607 {    j0array[0]+=IK2PI;
00608 }
00609 j0valid[0] = true;
00610 for(int ij0 = 0; ij0 < 1; ++ij0)
00611 {
00612 if( !j0valid[ij0] )
00613 {
00614     continue;
00615 }
00616 _ij0[0] = ij0; _ij0[1] = -1;
00617 for(int iij0 = ij0+1; iij0 < 1; ++iij0)
00618 {
00619 if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
00620 {
00621     j0valid[iij0]=false; _ij0[1] = iij0; break; 
00622 }
00623 }
00624 j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
00625 {
00626 IKReal evalcond[4];
00627 IKReal x91=IKsin(j0);
00628 IKReal x92=IKcos(j0);
00629 evalcond[0]=((((-0.420000000000000)*(sj2)*(sj3)))+(((px)*(x91)))+(((-1.00000000000000)*(py)*(x92))));
00630 evalcond[1]=((((-0.420000000000000)*(cj2)*(sj3)))+(((-1.00000000000000)*(px)*(x92)))+(((-1.00000000000000)*(py)*(x91))));
00631 evalcond[2]=((((-1.00000000000000)*(px)*(sj2)*(x92)))+(((cj2)*(py)*(x92)))+(((-1.00000000000000)*(py)*(sj2)*(x91)))+(((-1.00000000000000)*(cj2)*(px)*(x91))));
00632 evalcond[3]=((((-0.420000000000000)*(sj3)))+(((-1.00000000000000)*(py)*(sj2)*(x92)))+(((-1.00000000000000)*(cj2)*(px)*(x92)))+(((-1.00000000000000)*(cj2)*(py)*(x91)))+(((px)*(sj2)*(x91))));
00633 if( IKabs(evalcond[0]) > 0.000001  || IKabs(evalcond[1]) > 0.000001  || IKabs(evalcond[2]) > 0.000001  || IKabs(evalcond[3]) > 0.000001  )
00634 {
00635 continue;
00636 }
00637 }
00638 
00639 rotationfunction0(vsolutions);
00640 }
00641 }
00642 
00643 }
00644 
00645 }
00646 
00647 } else
00648 {
00649 IKReal x154=((0.420000000000000)*(cj3));
00650 IKReal x155=((0.490000000000000)+(x154)+(pz));
00651 evalcond[0]=((-3.14159265358979)+(IKfmod(((1.11022302462516e-16)+(j1)), 6.28318530717959)));
00652 evalcond[1]=((0.416500000000000)+(((0.411600000000000)*(cj3)))+(((-1.00000000000000)*(pp))));
00653 evalcond[2]=x155;
00654 evalcond[3]=((-0.0637000000000000)+(((-0.980000000000000)*(pz)))+(((-1.00000000000000)*(pp))));
00655 evalcond[4]=x155;
00656 if( IKabs(evalcond[0]) < 0.0000010000000000  && IKabs(evalcond[1]) < 0.0000010000000000  && IKabs(evalcond[2]) < 0.0000010000000000  && IKabs(evalcond[3]) < 0.0000010000000000  && IKabs(evalcond[4]) < 0.0000010000000000  )
00657 {
00658 {
00659 IKReal dummyeval[1];
00660 IKReal gconst2;
00661 gconst2=IKsign(((((50.0000000000000)*((px)*(px))))+(((50.0000000000000)*((py)*(py))))));
00662 dummyeval[0]=(((px)*(px))+((py)*(py)));
00663 if( IKabs(dummyeval[0]) < 0.0000010000000000  )
00664 {
00665 continue;
00666 
00667 } else
00668 {
00669 {
00670 IKReal j0array[1], cj0array[1], sj0array[1];
00671 bool j0valid[1]={false};
00672 _nj0 = 1;
00673 if( IKabs(((gconst2)*(((((21.0000000000000)*(cj2)*(py)*(sj3)))+(((21.0000000000000)*(px)*(sj2)*(sj3))))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((gconst2)*(((((21.0000000000000)*(cj2)*(px)*(sj3)))+(((-21.0000000000000)*(py)*(sj2)*(sj3))))))) < IKFAST_ATAN2_MAGTHRESH )
00674     continue;
00675 j0array[0]=IKatan2(((gconst2)*(((((21.0000000000000)*(cj2)*(py)*(sj3)))+(((21.0000000000000)*(px)*(sj2)*(sj3)))))), ((gconst2)*(((((21.0000000000000)*(cj2)*(px)*(sj3)))+(((-21.0000000000000)*(py)*(sj2)*(sj3)))))));
00676 sj0array[0]=IKsin(j0array[0]);
00677 cj0array[0]=IKcos(j0array[0]);
00678 if( j0array[0] > IKPI )
00679 {
00680     j0array[0]-=IK2PI;
00681 }
00682 else if( j0array[0] < -IKPI )
00683 {    j0array[0]+=IK2PI;
00684 }
00685 j0valid[0] = true;
00686 for(int ij0 = 0; ij0 < 1; ++ij0)
00687 {
00688 if( !j0valid[ij0] )
00689 {
00690     continue;
00691 }
00692 _ij0[0] = ij0; _ij0[1] = -1;
00693 for(int iij0 = ij0+1; iij0 < 1; ++iij0)
00694 {
00695 if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
00696 {
00697     j0valid[iij0]=false; _ij0[1] = iij0; break; 
00698 }
00699 }
00700 j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
00701 {
00702 IKReal evalcond[4];
00703 IKReal x156=IKsin(j0);
00704 IKReal x157=IKcos(j0);
00705 evalcond[0]=((((-0.420000000000000)*(sj2)*(sj3)))+(((-1.00000000000000)*(py)*(x157)))+(((px)*(x156))));
00706 evalcond[1]=((((-1.00000000000000)*(py)*(x156)))+(((-1.00000000000000)*(px)*(x157)))+(((0.420000000000000)*(cj2)*(sj3))));
00707 evalcond[2]=((((cj2)*(py)*(x157)))+(((-1.00000000000000)*(cj2)*(px)*(x156)))+(((py)*(sj2)*(x156)))+(((px)*(sj2)*(x157))));
00708 evalcond[3]=((((-0.420000000000000)*(sj3)))+(((cj2)*(py)*(x156)))+(((-1.00000000000000)*(py)*(sj2)*(x157)))+(((px)*(sj2)*(x156)))+(((cj2)*(px)*(x157))));
00709 if( IKabs(evalcond[0]) > 0.000001  || IKabs(evalcond[1]) > 0.000001  || IKabs(evalcond[2]) > 0.000001  || IKabs(evalcond[3]) > 0.000001  )
00710 {
00711 continue;
00712 }
00713 }
00714 
00715 rotationfunction0(vsolutions);
00716 }
00717 }
00718 
00719 }
00720 
00721 }
00722 
00723 } else
00724 {
00725 if( 1 )
00726 {
00727 continue;
00728 
00729 } else
00730 {
00731 }
00732 }
00733 }
00734 }
00735 
00736 } else
00737 {
00738 {
00739 IKReal j0array[1], cj0array[1], sj0array[1];
00740 bool j0valid[1]={false};
00741 _nj0 = 1;
00742 if( IKabs(((gconst0)*(((((-2500.00000000000)*(pp)*(py)))+(((-1029.00000000000)*(px)*(sj1)*(sj2)*(sj3)))+(((2450.00000000000)*(cj1)*(py)*(pz)))+(((-159.250000000000)*(py))))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((gconst0)*(((((2450.00000000000)*(cj1)*(px)*(pz)))+(((1029.00000000000)*(py)*(sj1)*(sj2)*(sj3)))+(((-2500.00000000000)*(pp)*(px)))+(((-159.250000000000)*(px))))))) < IKFAST_ATAN2_MAGTHRESH )
00743     continue;
00744 j0array[0]=IKatan2(((gconst0)*(((((-2500.00000000000)*(pp)*(py)))+(((-1029.00000000000)*(px)*(sj1)*(sj2)*(sj3)))+(((2450.00000000000)*(cj1)*(py)*(pz)))+(((-159.250000000000)*(py)))))), ((gconst0)*(((((2450.00000000000)*(cj1)*(px)*(pz)))+(((1029.00000000000)*(py)*(sj1)*(sj2)*(sj3)))+(((-2500.00000000000)*(pp)*(px)))+(((-159.250000000000)*(px)))))));
00745 sj0array[0]=IKsin(j0array[0]);
00746 cj0array[0]=IKcos(j0array[0]);
00747 if( j0array[0] > IKPI )
00748 {
00749     j0array[0]-=IK2PI;
00750 }
00751 else if( j0array[0] < -IKPI )
00752 {    j0array[0]+=IK2PI;
00753 }
00754 j0valid[0] = true;
00755 for(int ij0 = 0; ij0 < 1; ++ij0)
00756 {
00757 if( !j0valid[ij0] )
00758 {
00759     continue;
00760 }
00761 _ij0[0] = ij0; _ij0[1] = -1;
00762 for(int iij0 = ij0+1; iij0 < 1; ++iij0)
00763 {
00764 if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
00765 {
00766     j0valid[iij0]=false; _ij0[1] = iij0; break; 
00767 }
00768 }
00769 j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
00770 {
00771 IKReal evalcond[6];
00772 IKReal x158=IKsin(j0);
00773 IKReal x159=IKcos(j0);
00774 evalcond[0]=((((-0.420000000000000)*(sj2)*(sj3)))+(((-1.00000000000000)*(py)*(x159)))+(((px)*(x158))));
00775 evalcond[1]=((-0.0637000000000000)+(((0.980000000000000)*(cj1)*(pz)))+(((0.980000000000000)*(py)*(sj1)*(x158)))+(((-1.00000000000000)*(pp)))+(((0.980000000000000)*(px)*(sj1)*(x159))));
00776 evalcond[2]=((0.490000000000000)+(((-1.00000000000000)*(cj1)*(pz)))+(((-1.00000000000000)*(px)*(sj1)*(x159)))+(((0.420000000000000)*(cj3)))+(((-1.00000000000000)*(py)*(sj1)*(x158))));
00777 evalcond[3]=((((-1.00000000000000)*(py)*(x158)))+(((-0.420000000000000)*(cj1)*(cj2)*(sj3)))+(((-1.00000000000000)*(px)*(x159)))+(((0.490000000000000)*(sj1)))+(((0.420000000000000)*(cj3)*(sj1))));
00778 evalcond[4]=((((cj2)*(py)*(x159)))+(((-1.00000000000000)*(cj2)*(px)*(x158)))+(((-1.00000000000000)*(cj1)*(py)*(sj2)*(x158)))+(((pz)*(sj1)*(sj2)))+(((-1.00000000000000)*(cj1)*(px)*(sj2)*(x159))));
00779 evalcond[5]=((((-0.420000000000000)*(sj3)))+(((-1.00000000000000)*(py)*(sj2)*(x159)))+(((-1.00000000000000)*(cj1)*(cj2)*(py)*(x158)))+(((px)*(sj2)*(x158)))+(((cj2)*(pz)*(sj1)))+(((-1.00000000000000)*(cj1)*(cj2)*(px)*(x159))));
00780 if( IKabs(evalcond[0]) > 0.000001  || IKabs(evalcond[1]) > 0.000001  || IKabs(evalcond[2]) > 0.000001  || IKabs(evalcond[3]) > 0.000001  || IKabs(evalcond[4]) > 0.000001  || IKabs(evalcond[5]) > 0.000001  )
00781 {
00782 continue;
00783 }
00784 }
00785 
00786 rotationfunction0(vsolutions);
00787 }
00788 }
00789 
00790 }
00791 
00792 }
00793 }
00794 }
00795 
00796 }
00797 
00798 }
00799 
00800 } else
00801 {
00802 {
00803 IKReal j0array[2], cj0array[2], sj0array[2];
00804 bool j0valid[2]={false};
00805 _nj0 = 2;
00806 IKReal x160=(px)*(px);
00807 IKReal x161=(py)*(py);
00808 IKReal x162=((x160)+(x161));
00809 if( (x162) < (IKReal)-0.00001 )
00810     continue;
00811 IKReal x163=IKsqrt(x162);
00812 IKReal x164=IKabs(x163);
00813 IKReal x165=((IKabs(x164) != 0)?((IKReal)1/(x164)):(IKReal)1.0e30);
00814 IKReal x166=((0.420000000000000)*(sj2)*(sj3)*(x165));
00815 if( (x166) < -1-IKFAST_SINCOS_THRESH || (x166) > 1+IKFAST_SINCOS_THRESH )
00816     continue;
00817 IKReal x167=IKasin(x166);
00818 IKReal x168=((-1.00000000000000)*(py));
00819 if( IKabs(x168) < IKFAST_ATAN2_MAGTHRESH && IKabs(px) < IKFAST_ATAN2_MAGTHRESH )
00820     continue;
00821 IKReal x169=IKatan2(x168, px);
00822 j0array[0]=((((-1.00000000000000)*(x169)))+(x167));
00823 sj0array[0]=IKsin(j0array[0]);
00824 cj0array[0]=IKcos(j0array[0]);
00825 j0array[1]=((3.14159265358979)+(((-1.00000000000000)*(x169)))+(((-1.00000000000000)*(x167))));
00826 sj0array[1]=IKsin(j0array[1]);
00827 cj0array[1]=IKcos(j0array[1]);
00828 if( j0array[0] > IKPI )
00829 {
00830     j0array[0]-=IK2PI;
00831 }
00832 else if( j0array[0] < -IKPI )
00833 {    j0array[0]+=IK2PI;
00834 }
00835 j0valid[0] = true;
00836 if( j0array[1] > IKPI )
00837 {
00838     j0array[1]-=IK2PI;
00839 }
00840 else if( j0array[1] < -IKPI )
00841 {    j0array[1]+=IK2PI;
00842 }
00843 j0valid[1] = true;
00844 for(int ij0 = 0; ij0 < 2; ++ij0)
00845 {
00846 if( !j0valid[ij0] )
00847 {
00848     continue;
00849 }
00850 _ij0[0] = ij0; _ij0[1] = -1;
00851 for(int iij0 = ij0+1; iij0 < 2; ++iij0)
00852 {
00853 if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
00854 {
00855     j0valid[iij0]=false; _ij0[1] = iij0; break; 
00856 }
00857 }
00858 j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
00859 {
00860 IKReal evalcond[2];
00861 IKReal x170=(cj2)*(cj2);
00862 IKReal x171=(py)*(py);
00863 IKReal x172=(sj2)*(sj2);
00864 IKReal x173=(px)*(px);
00865 IKReal x174=IKsin(j0);
00866 IKReal x175=IKcos(j0);
00867 IKReal x176=((px)*(py)*(x172));
00868 IKReal x177=((px)*(py)*(x170));
00869 IKReal x178=((x177)+(x176));
00870 evalcond[0]=((((x175)*(((((-1.00000000000000)*(x170)*(x171)))+(((-1.00000000000000)*(x171)*(x172)))))))+(((x174)*(x178)))+(((-0.420000000000000)*(py)*(sj2)*(sj3))));
00871 evalcond[1]=((((-1.00000000000000)*(x175)*(x178)))+(((x174)*(((((x172)*(x173)))+(((x170)*(x173)))))))+(((-0.420000000000000)*(px)*(sj2)*(sj3))));
00872 if( IKabs(evalcond[0]) > 0.000001  || IKabs(evalcond[1]) > 0.000001  )
00873 {
00874 continue;
00875 }
00876 }
00877 
00878 {
00879 IKReal dummyeval[1];
00880 IKReal gconst3;
00881 gconst3=IKsign(((((-1029.00000000000)*(cj2)*(pz)*(sj3)))+(((1200.50000000000)*(cj0)*(px)))+(((1029.00000000000)*(cj0)*(cj3)*(px)))+(((1200.50000000000)*(py)*(sj0)))+(((1029.00000000000)*(cj3)*(py)*(sj0)))));
00882 dummyeval[0]=((((1.16666666666667)*(cj0)*(px)))+(((1.16666666666667)*(py)*(sj0)))+(((-1.00000000000000)*(cj2)*(pz)*(sj3)))+(((cj3)*(py)*(sj0)))+(((cj0)*(cj3)*(px))));
00883 if( IKabs(dummyeval[0]) < 0.0000010000000000  )
00884 {
00885 continue;
00886 
00887 } else
00888 {
00889 {
00890 IKReal j1array[1], cj1array[1], sj1array[1];
00891 bool j1valid[1]={false};
00892 _nj1 = 1;
00893 if( IKabs(((gconst3)*(((78.0325000000000)+(((66.8850000000000)*(cj3)))+(((1050.00000000000)*(cj3)*(pp)))+(((-2450.00000000000)*((pz)*(pz))))+(((1225.00000000000)*(pp))))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((gconst3)*(((((2450.00000000000)*(cj0)*(px)*(pz)))+(((-1050.00000000000)*(cj2)*(pp)*(sj3)))+(((-66.8850000000000)*(cj2)*(sj3)))+(((2450.00000000000)*(py)*(pz)*(sj0))))))) < IKFAST_ATAN2_MAGTHRESH )
00894     continue;
00895 j1array[0]=IKatan2(((gconst3)*(((78.0325000000000)+(((66.8850000000000)*(cj3)))+(((1050.00000000000)*(cj3)*(pp)))+(((-2450.00000000000)*((pz)*(pz))))+(((1225.00000000000)*(pp)))))), ((gconst3)*(((((2450.00000000000)*(cj0)*(px)*(pz)))+(((-1050.00000000000)*(cj2)*(pp)*(sj3)))+(((-66.8850000000000)*(cj2)*(sj3)))+(((2450.00000000000)*(py)*(pz)*(sj0)))))));
00896 sj1array[0]=IKsin(j1array[0]);
00897 cj1array[0]=IKcos(j1array[0]);
00898 if( j1array[0] > IKPI )
00899 {
00900     j1array[0]-=IK2PI;
00901 }
00902 else if( j1array[0] < -IKPI )
00903 {    j1array[0]+=IK2PI;
00904 }
00905 j1valid[0] = true;
00906 for(int ij1 = 0; ij1 < 1; ++ij1)
00907 {
00908 if( !j1valid[ij1] )
00909 {
00910     continue;
00911 }
00912 _ij1[0] = ij1; _ij1[1] = -1;
00913 for(int iij1 = ij1+1; iij1 < 1; ++iij1)
00914 {
00915 if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
00916 {
00917     j1valid[iij1]=false; _ij1[1] = iij1; break; 
00918 }
00919 }
00920 j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
00921 {
00922 IKReal evalcond[6];
00923 IKReal x179=IKcos(j1);
00924 IKReal x180=IKsin(j1);
00925 evalcond[0]=((((-0.490000000000000)*(x179)))+(((-0.420000000000000)*(cj2)*(sj3)*(x180)))+(pz)+(((-0.420000000000000)*(cj3)*(x179))));
00926 evalcond[1]=((-0.0637000000000000)+(((0.980000000000000)*(pz)*(x179)))+(((0.980000000000000)*(cj0)*(px)*(x180)))+(((0.980000000000000)*(py)*(sj0)*(x180)))+(((-1.00000000000000)*(pp))));
00927 evalcond[2]=((0.490000000000000)+(((-1.00000000000000)*(pz)*(x179)))+(((-1.00000000000000)*(cj0)*(px)*(x180)))+(((0.420000000000000)*(cj3)))+(((-1.00000000000000)*(py)*(sj0)*(x180))));
00928 evalcond[3]=((((-0.420000000000000)*(cj2)*(sj3)*(x179)))+(((0.420000000000000)*(cj3)*(x180)))+(((-1.00000000000000)*(py)*(sj0)))+(((-1.00000000000000)*(cj0)*(px)))+(((0.490000000000000)*(x180))));
00929 evalcond[4]=((((-1.00000000000000)*(py)*(sj0)*(sj2)*(x179)))+(((-1.00000000000000)*(cj2)*(px)*(sj0)))+(((-1.00000000000000)*(cj0)*(px)*(sj2)*(x179)))+(((cj0)*(cj2)*(py)))+(((pz)*(sj2)*(x180))));
00930 evalcond[5]=((((-1.00000000000000)*(cj2)*(py)*(sj0)*(x179)))+(((px)*(sj0)*(sj2)))+(((-0.420000000000000)*(sj3)))+(((-1.00000000000000)*(cj0)*(py)*(sj2)))+(((cj2)*(pz)*(x180)))+(((-1.00000000000000)*(cj0)*(cj2)*(px)*(x179))));
00931 if( IKabs(evalcond[0]) > 0.000001  || IKabs(evalcond[1]) > 0.000001  || IKabs(evalcond[2]) > 0.000001  || IKabs(evalcond[3]) > 0.000001  || IKabs(evalcond[4]) > 0.000001  || IKabs(evalcond[5]) > 0.000001  )
00932 {
00933 continue;
00934 }
00935 }
00936 
00937 rotationfunction0(vsolutions);
00938 }
00939 }
00940 
00941 }
00942 
00943 }
00944 }
00945 }
00946 
00947 }
00948 
00949 }
00950 
00951 } else
00952 {
00953 {
00954 IKReal j0array[2], cj0array[2], sj0array[2];
00955 bool j0valid[2]={false};
00956 _nj0 = 2;
00957 IKReal x181=(px)*(px);
00958 IKReal x182=(py)*(py);
00959 IKReal x183=((x181)+(x182));
00960 if( (x183) < (IKReal)-0.00001 )
00961     continue;
00962 IKReal x184=IKsqrt(x183);
00963 IKReal x185=IKabs(x184);
00964 IKReal x186=((IKabs(x185) != 0)?((IKReal)1/(x185)):(IKReal)1.0e30);
00965 IKReal x187=((0.420000000000000)*(sj2)*(sj3)*(x186));
00966 if( (x187) < -1-IKFAST_SINCOS_THRESH || (x187) > 1+IKFAST_SINCOS_THRESH )
00967     continue;
00968 IKReal x188=IKasin(x187);
00969 IKReal x189=((-1.00000000000000)*(py));
00970 if( IKabs(x189) < IKFAST_ATAN2_MAGTHRESH && IKabs(px) < IKFAST_ATAN2_MAGTHRESH )
00971     continue;
00972 IKReal x190=IKatan2(x189, px);
00973 j0array[0]=((((-1.00000000000000)*(x190)))+(x188));
00974 sj0array[0]=IKsin(j0array[0]);
00975 cj0array[0]=IKcos(j0array[0]);
00976 j0array[1]=((3.14159265358979)+(((-1.00000000000000)*(x188)))+(((-1.00000000000000)*(x190))));
00977 sj0array[1]=IKsin(j0array[1]);
00978 cj0array[1]=IKcos(j0array[1]);
00979 if( j0array[0] > IKPI )
00980 {
00981     j0array[0]-=IK2PI;
00982 }
00983 else if( j0array[0] < -IKPI )
00984 {    j0array[0]+=IK2PI;
00985 }
00986 j0valid[0] = true;
00987 if( j0array[1] > IKPI )
00988 {
00989     j0array[1]-=IK2PI;
00990 }
00991 else if( j0array[1] < -IKPI )
00992 {    j0array[1]+=IK2PI;
00993 }
00994 j0valid[1] = true;
00995 for(int ij0 = 0; ij0 < 2; ++ij0)
00996 {
00997 if( !j0valid[ij0] )
00998 {
00999     continue;
01000 }
01001 _ij0[0] = ij0; _ij0[1] = -1;
01002 for(int iij0 = ij0+1; iij0 < 2; ++iij0)
01003 {
01004 if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
01005 {
01006     j0valid[iij0]=false; _ij0[1] = iij0; break; 
01007 }
01008 }
01009 j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
01010 
01011 {
01012 IKReal dummyeval[1];
01013 IKReal gconst3;
01014 gconst3=IKsign(((((-1029.00000000000)*(cj2)*(pz)*(sj3)))+(((1200.50000000000)*(cj0)*(px)))+(((1029.00000000000)*(cj0)*(cj3)*(px)))+(((1200.50000000000)*(py)*(sj0)))+(((1029.00000000000)*(cj3)*(py)*(sj0)))));
01015 dummyeval[0]=((((1.16666666666667)*(cj0)*(px)))+(((1.16666666666667)*(py)*(sj0)))+(((-1.00000000000000)*(cj2)*(pz)*(sj3)))+(((cj3)*(py)*(sj0)))+(((cj0)*(cj3)*(px))));
01016 if( IKabs(dummyeval[0]) < 0.0000010000000000  )
01017 {
01018 continue;
01019 
01020 } else
01021 {
01022 {
01023 IKReal j1array[1], cj1array[1], sj1array[1];
01024 bool j1valid[1]={false};
01025 _nj1 = 1;
01026 if( IKabs(((gconst3)*(((78.0325000000000)+(((66.8850000000000)*(cj3)))+(((1050.00000000000)*(cj3)*(pp)))+(((-2450.00000000000)*((pz)*(pz))))+(((1225.00000000000)*(pp))))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((gconst3)*(((((2450.00000000000)*(cj0)*(px)*(pz)))+(((-1050.00000000000)*(cj2)*(pp)*(sj3)))+(((-66.8850000000000)*(cj2)*(sj3)))+(((2450.00000000000)*(py)*(pz)*(sj0))))))) < IKFAST_ATAN2_MAGTHRESH )
01027     continue;
01028 j1array[0]=IKatan2(((gconst3)*(((78.0325000000000)+(((66.8850000000000)*(cj3)))+(((1050.00000000000)*(cj3)*(pp)))+(((-2450.00000000000)*((pz)*(pz))))+(((1225.00000000000)*(pp)))))), ((gconst3)*(((((2450.00000000000)*(cj0)*(px)*(pz)))+(((-1050.00000000000)*(cj2)*(pp)*(sj3)))+(((-66.8850000000000)*(cj2)*(sj3)))+(((2450.00000000000)*(py)*(pz)*(sj0)))))));
01029 sj1array[0]=IKsin(j1array[0]);
01030 cj1array[0]=IKcos(j1array[0]);
01031 if( j1array[0] > IKPI )
01032 {
01033     j1array[0]-=IK2PI;
01034 }
01035 else if( j1array[0] < -IKPI )
01036 {    j1array[0]+=IK2PI;
01037 }
01038 j1valid[0] = true;
01039 for(int ij1 = 0; ij1 < 1; ++ij1)
01040 {
01041 if( !j1valid[ij1] )
01042 {
01043     continue;
01044 }
01045 _ij1[0] = ij1; _ij1[1] = -1;
01046 for(int iij1 = ij1+1; iij1 < 1; ++iij1)
01047 {
01048 if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
01049 {
01050     j1valid[iij1]=false; _ij1[1] = iij1; break; 
01051 }
01052 }
01053 j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
01054 {
01055 IKReal evalcond[6];
01056 IKReal x191=IKcos(j1);
01057 IKReal x192=IKsin(j1);
01058 evalcond[0]=((((-0.490000000000000)*(x191)))+(((-0.420000000000000)*(cj2)*(sj3)*(x192)))+(pz)+(((-0.420000000000000)*(cj3)*(x191))));
01059 evalcond[1]=((-0.0637000000000000)+(((0.980000000000000)*(cj0)*(px)*(x192)))+(((0.980000000000000)*(pz)*(x191)))+(((0.980000000000000)*(py)*(sj0)*(x192)))+(((-1.00000000000000)*(pp))));
01060 evalcond[2]=((0.490000000000000)+(((-1.00000000000000)*(pz)*(x191)))+(((-1.00000000000000)*(cj0)*(px)*(x192)))+(((0.420000000000000)*(cj3)))+(((-1.00000000000000)*(py)*(sj0)*(x192))));
01061 evalcond[3]=((((-0.420000000000000)*(cj2)*(sj3)*(x191)))+(((0.420000000000000)*(cj3)*(x192)))+(((-1.00000000000000)*(py)*(sj0)))+(((0.490000000000000)*(x192)))+(((-1.00000000000000)*(cj0)*(px))));
01062 evalcond[4]=((((-1.00000000000000)*(py)*(sj0)*(sj2)*(x191)))+(((-1.00000000000000)*(cj0)*(px)*(sj2)*(x191)))+(((-1.00000000000000)*(cj2)*(px)*(sj0)))+(((cj0)*(cj2)*(py)))+(((pz)*(sj2)*(x192))));
01063 evalcond[5]=((((px)*(sj0)*(sj2)))+(((-0.420000000000000)*(sj3)))+(((-1.00000000000000)*(cj0)*(cj2)*(px)*(x191)))+(((-1.00000000000000)*(cj0)*(py)*(sj2)))+(((cj2)*(pz)*(x192)))+(((-1.00000000000000)*(cj2)*(py)*(sj0)*(x191))));
01064 if( IKabs(evalcond[0]) > 0.000001  || IKabs(evalcond[1]) > 0.000001  || IKabs(evalcond[2]) > 0.000001  || IKabs(evalcond[3]) > 0.000001  || IKabs(evalcond[4]) > 0.000001  || IKabs(evalcond[5]) > 0.000001  )
01065 {
01066 continue;
01067 }
01068 }
01069 
01070 rotationfunction0(vsolutions);
01071 }
01072 }
01073 
01074 }
01075 
01076 }
01077 }
01078 }
01079 
01080 }
01081 
01082 }
01083 }
01084 }
01085 }
01086 return vsolutions.size()>0;
01087 }
01088 inline void rotationfunction0(std::vector<IKSolution>& vsolutions) {
01089 for(int rotationiter = 0; rotationiter < 1; ++rotationiter) {
01090 IKReal x93=((sj1)*(sj3));
01091 IKReal x94=((cj1)*(cj2)*(cj3));
01092 IKReal x95=((x93)+(x94));
01093 IKReal x96=((cj0)*(cj3)*(sj2));
01094 IKReal x97=((sj0)*(x95));
01095 IKReal x98=((x97)+(x96));
01096 IKReal x99=((cj0)*(x95));
01097 IKReal x100=((cj3)*(sj0)*(sj2));
01098 IKReal x101=((((-1.00000000000000)*(x100)))+(x99));
01099 IKReal x102=((cj1)*(sj3));
01100 IKReal x103=((cj2)*(cj3)*(sj1));
01101 IKReal x104=((((-1.00000000000000)*(x103)))+(x102));
01102 IKReal x105=((cj2)*(sj0));
01103 IKReal x106=((cj0)*(cj1)*(sj2));
01104 IKReal x107=((x105)+(x106));
01105 IKReal x108=((cj1)*(sj0)*(sj2));
01106 IKReal x109=((cj0)*(cj2));
01107 IKReal x110=((((-1.00000000000000)*(x109)))+(x108));
01108 IKReal x111=((cj2)*(x102));
01109 IKReal x112=((cj3)*(sj1));
01110 IKReal x113=((((-1.00000000000000)*(x112)))+(x111));
01111 IKReal x114=((cj1)*(cj3));
01112 IKReal x115=((cj2)*(x93));
01113 IKReal x116=((x115)+(x114));
01114 IKReal x117=((-1.00000000000000)*(x116));
01115 IKReal x118=((sj0)*(x113));
01116 IKReal x119=((cj0)*(sj2)*(sj3));
01117 IKReal x120=((x119)+(x118));
01118 IKReal x121=((cj0)*(x113));
01119 IKReal x122=((-1.00000000000000)*(sj0)*(sj2)*(sj3));
01120 IKReal x123=((x122)+(x121));
01121 new_r00=((((r10)*(x98)))+(((r20)*(x104)))+(((r00)*(x101))));
01122 new_r01=((((r11)*(x98)))+(((r21)*(x104)))+(((r01)*(x101))));
01123 new_r02=((((r02)*(x101)))+(((r12)*(x98)))+(((r22)*(x104))));
01124 new_r10=((((r10)*(x110)))+(((-1.00000000000000)*(r20)*(sj1)*(sj2)))+(((r00)*(x107))));
01125 new_r11=((((-1.00000000000000)*(r21)*(sj1)*(sj2)))+(((r11)*(x110)))+(((r01)*(x107))));
01126 new_r12=((((r02)*(x107)))+(((-1.00000000000000)*(r22)*(sj1)*(sj2)))+(((r12)*(x110))));
01127 new_r20=((((r00)*(x123)))+(((r20)*(x117)))+(((r10)*(x120))));
01128 new_r21=((((r01)*(x123)))+(((r21)*(x117)))+(((r11)*(x120))));
01129 new_r22=((((r22)*(x117)))+(((r02)*(x123)))+(((r12)*(x120))));
01130 {
01131 IKReal j5array[2], cj5array[2], sj5array[2];
01132 bool j5valid[2]={false};
01133 _nj5 = 2;
01134 cj5array[0]=new_r22;
01135 if( cj5array[0] >= -1-IKFAST_SINCOS_THRESH && cj5array[0] <= 1+IKFAST_SINCOS_THRESH )
01136 {
01137     j5valid[0] = j5valid[1] = true;
01138     j5array[0] = IKacos(cj5array[0]);
01139     sj5array[0] = IKsin(j5array[0]);
01140     cj5array[1] = cj5array[0];
01141     j5array[1] = -j5array[0];
01142     sj5array[1] = -sj5array[0];
01143 }
01144 else if( isnan(cj5array[0]) )
01145 {
01146     // probably any value will work
01147     j5valid[0] = true;
01148     cj5array[0] = 1; sj5array[0] = 0; j5array[0] = 0;
01149 }
01150 for(int ij5 = 0; ij5 < 2; ++ij5)
01151 {
01152 if( !j5valid[ij5] )
01153 {
01154     continue;
01155 }
01156 _ij5[0] = ij5; _ij5[1] = -1;
01157 for(int iij5 = ij5+1; iij5 < 2; ++iij5)
01158 {
01159 if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
01160 {
01161     j5valid[iij5]=false; _ij5[1] = iij5; break; 
01162 }
01163 }
01164 j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
01165 
01166 {
01167 IKReal dummyeval[1];
01168 IKReal gconst5;
01169 gconst5=IKsign(sj5);
01170 dummyeval[0]=sj5;
01171 if( IKabs(dummyeval[0]) < 0.0000010000000000  )
01172 {
01173 {
01174 IKReal dummyeval[1];
01175 IKReal gconst4;
01176 gconst4=IKsign((((new_r12)*(new_r12))+((new_r02)*(new_r02))));
01177 dummyeval[0]=(((new_r12)*(new_r12))+((new_r02)*(new_r02)));
01178 if( IKabs(dummyeval[0]) < 0.0000010000000000  )
01179 {
01180 {
01181 IKReal evalcond[7];
01182 evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(j5)), 6.28318530717959)));
01183 evalcond[1]=((-1.00000000000000)+(new_r22));
01184 evalcond[2]=new_r20;
01185 evalcond[3]=new_r21;
01186 evalcond[4]=((-1.00000000000000)*(new_r20));
01187 evalcond[5]=((-1.00000000000000)*(new_r21));
01188 evalcond[6]=((1.00000000000000)+(((-1.00000000000000)*(new_r22))));
01189 if( IKabs(evalcond[0]) < 0.0000010000000000  && IKabs(evalcond[1]) < 0.0000010000000000  && IKabs(evalcond[2]) < 0.0000010000000000  && IKabs(evalcond[3]) < 0.0000010000000000  && IKabs(evalcond[4]) < 0.0000010000000000  && IKabs(evalcond[5]) < 0.0000010000000000  && IKabs(evalcond[6]) < 0.0000010000000000  )
01190 {
01191 {
01192 IKReal j4array[2], cj4array[2], sj4array[2];
01193 bool j4valid[2]={false};
01194 _nj4 = 2;
01195 if( IKabs(new_r02) < IKFAST_ATAN2_MAGTHRESH && IKabs(new_r12) < IKFAST_ATAN2_MAGTHRESH )
01196     continue;
01197 IKReal x124=IKatan2(new_r02, new_r12);
01198 j4array[0]=((-1.00000000000000)*(x124));
01199 sj4array[0]=IKsin(j4array[0]);
01200 cj4array[0]=IKcos(j4array[0]);
01201 j4array[1]=((3.14159265358979)+(((-1.00000000000000)*(x124))));
01202 sj4array[1]=IKsin(j4array[1]);
01203 cj4array[1]=IKcos(j4array[1]);
01204 if( j4array[0] > IKPI )
01205 {
01206     j4array[0]-=IK2PI;
01207 }
01208 else if( j4array[0] < -IKPI )
01209 {    j4array[0]+=IK2PI;
01210 }
01211 j4valid[0] = true;
01212 if( j4array[1] > IKPI )
01213 {
01214     j4array[1]-=IK2PI;
01215 }
01216 else if( j4array[1] < -IKPI )
01217 {    j4array[1]+=IK2PI;
01218 }
01219 j4valid[1] = true;
01220 for(int ij4 = 0; ij4 < 2; ++ij4)
01221 {
01222 if( !j4valid[ij4] )
01223 {
01224     continue;
01225 }
01226 _ij4[0] = ij4; _ij4[1] = -1;
01227 for(int iij4 = ij4+1; iij4 < 2; ++iij4)
01228 {
01229 if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
01230 {
01231     j4valid[iij4]=false; _ij4[1] = iij4; break; 
01232 }
01233 }
01234 j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
01235 {
01236 IKReal evalcond[1];
01237 evalcond[0]=((((new_r12)*(IKcos(j4))))+(((-1.00000000000000)*(new_r02)*(IKsin(j4)))));
01238 if( IKabs(evalcond[0]) > 0.000001  )
01239 {
01240 continue;
01241 }
01242 }
01243 
01244 {
01245 IKReal j6array[1], cj6array[1], sj6array[1];
01246 bool j6valid[1]={false};
01247 _nj6 = 1;
01248 if( IKabs(((((-1.00000000000000)*(cj4)*(new_r01)))+(((-1.00000000000000)*(new_r11)*(sj4))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((((cj4)*(new_r00)))+(((new_r10)*(sj4))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((((-1.00000000000000)*(cj4)*(new_r01)))+(((-1.00000000000000)*(new_r11)*(sj4)))))+IKsqr(((((cj4)*(new_r00)))+(((new_r10)*(sj4)))))-1) <= IKFAST_SINCOS_THRESH )
01249     continue;
01250 j6array[0]=IKatan2(((((-1.00000000000000)*(cj4)*(new_r01)))+(((-1.00000000000000)*(new_r11)*(sj4)))), ((((cj4)*(new_r00)))+(((new_r10)*(sj4)))));
01251 sj6array[0]=IKsin(j6array[0]);
01252 cj6array[0]=IKcos(j6array[0]);
01253 if( j6array[0] > IKPI )
01254 {
01255     j6array[0]-=IK2PI;
01256 }
01257 else if( j6array[0] < -IKPI )
01258 {    j6array[0]+=IK2PI;
01259 }
01260 j6valid[0] = true;
01261 for(int ij6 = 0; ij6 < 1; ++ij6)
01262 {
01263 if( !j6valid[ij6] )
01264 {
01265     continue;
01266 }
01267 _ij6[0] = ij6; _ij6[1] = -1;
01268 for(int iij6 = ij6+1; iij6 < 1; ++iij6)
01269 {
01270 if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
01271 {
01272     j6valid[iij6]=false; _ij6[1] = iij6; break; 
01273 }
01274 }
01275 j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
01276 {
01277 IKReal evalcond[4];
01278 IKReal x125=IKsin(j6);
01279 IKReal x126=IKcos(j6);
01280 evalcond[0]=((((cj4)*(new_r10)))+(((-1.00000000000000)*(x125)))+(((-1.00000000000000)*(new_r00)*(sj4))));
01281 evalcond[1]=((((cj4)*(new_r11)))+(((-1.00000000000000)*(x126)))+(((-1.00000000000000)*(new_r01)*(sj4))));
01282 evalcond[2]=((((cj4)*(new_r01)))+(((new_r11)*(sj4)))+(x125));
01283 evalcond[3]=((((cj4)*(new_r00)))+(((new_r10)*(sj4)))+(((-1.00000000000000)*(x126))));
01284 if( IKabs(evalcond[0]) > 0.000001  || IKabs(evalcond[1]) > 0.000001  || IKabs(evalcond[2]) > 0.000001  || IKabs(evalcond[3]) > 0.000001  )
01285 {
01286 continue;
01287 }
01288 }
01289 
01290 {
01291 vsolutions.push_back(IKSolution()); IKSolution& solution = vsolutions.back();
01292 solution.basesol.resize(7);
01293 solution.basesol[0].foffset = j0;
01294 solution.basesol[0].indices[0] = _ij0[0];
01295 solution.basesol[0].indices[1] = _ij0[1];
01296 solution.basesol[0].maxsolutions = _nj0;
01297 solution.basesol[1].foffset = j1;
01298 solution.basesol[1].indices[0] = _ij1[0];
01299 solution.basesol[1].indices[1] = _ij1[1];
01300 solution.basesol[1].maxsolutions = _nj1;
01301 solution.basesol[2].foffset = j2;
01302 solution.basesol[2].indices[0] = _ij2[0];
01303 solution.basesol[2].indices[1] = _ij2[1];
01304 solution.basesol[2].maxsolutions = _nj2;
01305 solution.basesol[3].foffset = j3;
01306 solution.basesol[3].indices[0] = _ij3[0];
01307 solution.basesol[3].indices[1] = _ij3[1];
01308 solution.basesol[3].maxsolutions = _nj3;
01309 solution.basesol[4].foffset = j4;
01310 solution.basesol[4].indices[0] = _ij4[0];
01311 solution.basesol[4].indices[1] = _ij4[1];
01312 solution.basesol[4].maxsolutions = _nj4;
01313 solution.basesol[5].foffset = j5;
01314 solution.basesol[5].indices[0] = _ij5[0];
01315 solution.basesol[5].indices[1] = _ij5[1];
01316 solution.basesol[5].maxsolutions = _nj5;
01317 solution.basesol[6].foffset = j6;
01318 solution.basesol[6].indices[0] = _ij6[0];
01319 solution.basesol[6].indices[1] = _ij6[1];
01320 solution.basesol[6].maxsolutions = _nj6;
01321 solution.vfree.resize(0);
01322 }
01323 }
01324 }
01325 }
01326 }
01327 
01328 } else
01329 {
01330 IKReal x127=((1.00000000000000)+(new_r22));
01331 evalcond[0]=((-3.14159265358979)+(IKfmod(((1.11022302462516e-16)+(j5)), 6.28318530717959)));
01332 evalcond[1]=x127;
01333 evalcond[2]=new_r20;
01334 evalcond[3]=new_r21;
01335 evalcond[4]=new_r20;
01336 evalcond[5]=new_r21;
01337 evalcond[6]=x127;
01338 if( IKabs(evalcond[0]) < 0.0000010000000000  && IKabs(evalcond[1]) < 0.0000010000000000  && IKabs(evalcond[2]) < 0.0000010000000000  && IKabs(evalcond[3]) < 0.0000010000000000  && IKabs(evalcond[4]) < 0.0000010000000000  && IKabs(evalcond[5]) < 0.0000010000000000  && IKabs(evalcond[6]) < 0.0000010000000000  )
01339 {
01340 {
01341 IKReal j4array[2], cj4array[2], sj4array[2];
01342 bool j4valid[2]={false};
01343 _nj4 = 2;
01344 if( IKabs(new_r02) < IKFAST_ATAN2_MAGTHRESH && IKabs(new_r12) < IKFAST_ATAN2_MAGTHRESH )
01345     continue;
01346 IKReal x128=IKatan2(new_r02, new_r12);
01347 j4array[0]=((-1.00000000000000)*(x128));
01348 sj4array[0]=IKsin(j4array[0]);
01349 cj4array[0]=IKcos(j4array[0]);
01350 j4array[1]=((3.14159265358979)+(((-1.00000000000000)*(x128))));
01351 sj4array[1]=IKsin(j4array[1]);
01352 cj4array[1]=IKcos(j4array[1]);
01353 if( j4array[0] > IKPI )
01354 {
01355     j4array[0]-=IK2PI;
01356 }
01357 else if( j4array[0] < -IKPI )
01358 {    j4array[0]+=IK2PI;
01359 }
01360 j4valid[0] = true;
01361 if( j4array[1] > IKPI )
01362 {
01363     j4array[1]-=IK2PI;
01364 }
01365 else if( j4array[1] < -IKPI )
01366 {    j4array[1]+=IK2PI;
01367 }
01368 j4valid[1] = true;
01369 for(int ij4 = 0; ij4 < 2; ++ij4)
01370 {
01371 if( !j4valid[ij4] )
01372 {
01373     continue;
01374 }
01375 _ij4[0] = ij4; _ij4[1] = -1;
01376 for(int iij4 = ij4+1; iij4 < 2; ++iij4)
01377 {
01378 if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
01379 {
01380     j4valid[iij4]=false; _ij4[1] = iij4; break; 
01381 }
01382 }
01383 j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
01384 {
01385 IKReal evalcond[1];
01386 evalcond[0]=((((new_r12)*(IKcos(j4))))+(((-1.00000000000000)*(new_r02)*(IKsin(j4)))));
01387 if( IKabs(evalcond[0]) > 0.000001  )
01388 {
01389 continue;
01390 }
01391 }
01392 
01393 {
01394 IKReal j6array[1], cj6array[1], sj6array[1];
01395 bool j6valid[1]={false};
01396 _nj6 = 1;
01397 if( IKabs(((((cj4)*(new_r01)))+(((new_r11)*(sj4))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((((-1.00000000000000)*(new_r10)*(sj4)))+(((-1.00000000000000)*(cj4)*(new_r00))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((((cj4)*(new_r01)))+(((new_r11)*(sj4)))))+IKsqr(((((-1.00000000000000)*(new_r10)*(sj4)))+(((-1.00000000000000)*(cj4)*(new_r00)))))-1) <= IKFAST_SINCOS_THRESH )
01398     continue;
01399 j6array[0]=IKatan2(((((cj4)*(new_r01)))+(((new_r11)*(sj4)))), ((((-1.00000000000000)*(new_r10)*(sj4)))+(((-1.00000000000000)*(cj4)*(new_r00)))));
01400 sj6array[0]=IKsin(j6array[0]);
01401 cj6array[0]=IKcos(j6array[0]);
01402 if( j6array[0] > IKPI )
01403 {
01404     j6array[0]-=IK2PI;
01405 }
01406 else if( j6array[0] < -IKPI )
01407 {    j6array[0]+=IK2PI;
01408 }
01409 j6valid[0] = true;
01410 for(int ij6 = 0; ij6 < 1; ++ij6)
01411 {
01412 if( !j6valid[ij6] )
01413 {
01414     continue;
01415 }
01416 _ij6[0] = ij6; _ij6[1] = -1;
01417 for(int iij6 = ij6+1; iij6 < 1; ++iij6)
01418 {
01419 if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
01420 {
01421     j6valid[iij6]=false; _ij6[1] = iij6; break; 
01422 }
01423 }
01424 j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
01425 {
01426 IKReal evalcond[4];
01427 IKReal x129=IKsin(j6);
01428 IKReal x130=IKcos(j6);
01429 evalcond[0]=((((cj4)*(new_r10)))+(((-1.00000000000000)*(x129)))+(((-1.00000000000000)*(new_r00)*(sj4))));
01430 evalcond[1]=((((cj4)*(new_r11)))+(((-1.00000000000000)*(x130)))+(((-1.00000000000000)*(new_r01)*(sj4))));
01431 evalcond[2]=((((cj4)*(new_r01)))+(((new_r11)*(sj4)))+(((-1.00000000000000)*(x129))));
01432 evalcond[3]=((((cj4)*(new_r00)))+(((new_r10)*(sj4)))+(x130));
01433 if( IKabs(evalcond[0]) > 0.000001  || IKabs(evalcond[1]) > 0.000001  || IKabs(evalcond[2]) > 0.000001  || IKabs(evalcond[3]) > 0.000001  )
01434 {
01435 continue;
01436 }
01437 }
01438 
01439 {
01440 vsolutions.push_back(IKSolution()); IKSolution& solution = vsolutions.back();
01441 solution.basesol.resize(7);
01442 solution.basesol[0].foffset = j0;
01443 solution.basesol[0].indices[0] = _ij0[0];
01444 solution.basesol[0].indices[1] = _ij0[1];
01445 solution.basesol[0].maxsolutions = _nj0;
01446 solution.basesol[1].foffset = j1;
01447 solution.basesol[1].indices[0] = _ij1[0];
01448 solution.basesol[1].indices[1] = _ij1[1];
01449 solution.basesol[1].maxsolutions = _nj1;
01450 solution.basesol[2].foffset = j2;
01451 solution.basesol[2].indices[0] = _ij2[0];
01452 solution.basesol[2].indices[1] = _ij2[1];
01453 solution.basesol[2].maxsolutions = _nj2;
01454 solution.basesol[3].foffset = j3;
01455 solution.basesol[3].indices[0] = _ij3[0];
01456 solution.basesol[3].indices[1] = _ij3[1];
01457 solution.basesol[3].maxsolutions = _nj3;
01458 solution.basesol[4].foffset = j4;
01459 solution.basesol[4].indices[0] = _ij4[0];
01460 solution.basesol[4].indices[1] = _ij4[1];
01461 solution.basesol[4].maxsolutions = _nj4;
01462 solution.basesol[5].foffset = j5;
01463 solution.basesol[5].indices[0] = _ij5[0];
01464 solution.basesol[5].indices[1] = _ij5[1];
01465 solution.basesol[5].maxsolutions = _nj5;
01466 solution.basesol[6].foffset = j6;
01467 solution.basesol[6].indices[0] = _ij6[0];
01468 solution.basesol[6].indices[1] = _ij6[1];
01469 solution.basesol[6].maxsolutions = _nj6;
01470 solution.vfree.resize(0);
01471 }
01472 }
01473 }
01474 }
01475 }
01476 
01477 } else
01478 {
01479 if( 1 )
01480 {
01481 continue;
01482 
01483 } else
01484 {
01485 }
01486 }
01487 }
01488 }
01489 
01490 } else
01491 {
01492 {
01493 IKReal j4array[1], cj4array[1], sj4array[1];
01494 bool j4valid[1]={false};
01495 _nj4 = 1;
01496 if( IKabs(((gconst4)*(new_r12)*(sj5))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((gconst4)*(new_r02)*(sj5))) < IKFAST_ATAN2_MAGTHRESH )
01497     continue;
01498 j4array[0]=IKatan2(((gconst4)*(new_r12)*(sj5)), ((gconst4)*(new_r02)*(sj5)));
01499 sj4array[0]=IKsin(j4array[0]);
01500 cj4array[0]=IKcos(j4array[0]);
01501 if( j4array[0] > IKPI )
01502 {
01503     j4array[0]-=IK2PI;
01504 }
01505 else if( j4array[0] < -IKPI )
01506 {    j4array[0]+=IK2PI;
01507 }
01508 j4valid[0] = true;
01509 for(int ij4 = 0; ij4 < 1; ++ij4)
01510 {
01511 if( !j4valid[ij4] )
01512 {
01513     continue;
01514 }
01515 _ij4[0] = ij4; _ij4[1] = -1;
01516 for(int iij4 = ij4+1; iij4 < 1; ++iij4)
01517 {
01518 if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
01519 {
01520     j4valid[iij4]=false; _ij4[1] = iij4; break; 
01521 }
01522 }
01523 j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
01524 {
01525 IKReal evalcond[6];
01526 IKReal x131=IKcos(j4);
01527 IKReal x132=IKsin(j4);
01528 evalcond[0]=((((new_r12)*(x131)))+(((-1.00000000000000)*(new_r02)*(x132))));
01529 evalcond[1]=((((new_r12)*(x132)))+(((new_r02)*(x131)))+(((-1.00000000000000)*(sj5))));
01530 evalcond[2]=((((cj5)*(new_r12)*(x132)))+(((-1.00000000000000)*(new_r22)*(sj5)))+(((cj5)*(new_r02)*(x131))));
01531 evalcond[3]=((((-1.00000000000000)*(new_r10)*(sj5)*(x132)))+(((-1.00000000000000)*(new_r00)*(sj5)*(x131)))+(((-1.00000000000000)*(cj5)*(new_r20))));
01532 evalcond[4]=((((-1.00000000000000)*(new_r11)*(sj5)*(x132)))+(((-1.00000000000000)*(new_r01)*(sj5)*(x131)))+(((-1.00000000000000)*(cj5)*(new_r21))));
01533 evalcond[5]=((1.00000000000000)+(((-1.00000000000000)*(new_r02)*(sj5)*(x131)))+(((-1.00000000000000)*(new_r12)*(sj5)*(x132)))+(((-1.00000000000000)*(cj5)*(new_r22))));
01534 if( IKabs(evalcond[0]) > 0.000001  || IKabs(evalcond[1]) > 0.000001  || IKabs(evalcond[2]) > 0.000001  || IKabs(evalcond[3]) > 0.000001  || IKabs(evalcond[4]) > 0.000001  || IKabs(evalcond[5]) > 0.000001  )
01535 {
01536 continue;
01537 }
01538 }
01539 
01540 {
01541 IKReal dummyeval[1];
01542 IKReal gconst6;
01543 gconst6=IKsign(sj5);
01544 dummyeval[0]=sj5;
01545 if( IKabs(dummyeval[0]) < 0.0000010000000000  )
01546 {
01547 {
01548 IKReal evalcond[11];
01549 IKReal x133=((cj4)*(new_r12));
01550 IKReal x134=((new_r02)*(sj4));
01551 IKReal x135=((x133)+(((-1.00000000000000)*(x134))));
01552 IKReal x136=((new_r12)*(sj4));
01553 IKReal x137=((cj4)*(new_r02));
01554 IKReal x138=((x137)+(x136));
01555 evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(j5)), 6.28318530717959)));
01556 evalcond[1]=((-1.00000000000000)+(new_r22));
01557 evalcond[2]=new_r20;
01558 evalcond[3]=new_r21;
01559 evalcond[4]=x135;
01560 evalcond[5]=x135;
01561 evalcond[6]=x138;
01562 evalcond[7]=x138;
01563 evalcond[8]=((-1.00000000000000)*(new_r20));
01564 evalcond[9]=((-1.00000000000000)*(new_r21));
01565 evalcond[10]=((1.00000000000000)+(((-1.00000000000000)*(new_r22))));
01566 if( IKabs(evalcond[0]) < 0.0000010000000000  && IKabs(evalcond[1]) < 0.0000010000000000  && IKabs(evalcond[2]) < 0.0000010000000000  && IKabs(evalcond[3]) < 0.0000010000000000  && IKabs(evalcond[4]) < 0.0000010000000000  && IKabs(evalcond[5]) < 0.0000010000000000  && IKabs(evalcond[6]) < 0.0000010000000000  && IKabs(evalcond[7]) < 0.0000010000000000  && IKabs(evalcond[8]) < 0.0000010000000000  && IKabs(evalcond[9]) < 0.0000010000000000  && IKabs(evalcond[10]) < 0.0000010000000000  )
01567 {
01568 {
01569 IKReal j6array[1], cj6array[1], sj6array[1];
01570 bool j6valid[1]={false};
01571 _nj6 = 1;
01572 if( IKabs(((((-1.00000000000000)*(cj4)*(new_r01)))+(((-1.00000000000000)*(new_r11)*(sj4))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((((cj4)*(new_r00)))+(((new_r10)*(sj4))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((((-1.00000000000000)*(cj4)*(new_r01)))+(((-1.00000000000000)*(new_r11)*(sj4)))))+IKsqr(((((cj4)*(new_r00)))+(((new_r10)*(sj4)))))-1) <= IKFAST_SINCOS_THRESH )
01573     continue;
01574 j6array[0]=IKatan2(((((-1.00000000000000)*(cj4)*(new_r01)))+(((-1.00000000000000)*(new_r11)*(sj4)))), ((((cj4)*(new_r00)))+(((new_r10)*(sj4)))));
01575 sj6array[0]=IKsin(j6array[0]);
01576 cj6array[0]=IKcos(j6array[0]);
01577 if( j6array[0] > IKPI )
01578 {
01579     j6array[0]-=IK2PI;
01580 }
01581 else if( j6array[0] < -IKPI )
01582 {    j6array[0]+=IK2PI;
01583 }
01584 j6valid[0] = true;
01585 for(int ij6 = 0; ij6 < 1; ++ij6)
01586 {
01587 if( !j6valid[ij6] )
01588 {
01589     continue;
01590 }
01591 _ij6[0] = ij6; _ij6[1] = -1;
01592 for(int iij6 = ij6+1; iij6 < 1; ++iij6)
01593 {
01594 if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
01595 {
01596     j6valid[iij6]=false; _ij6[1] = iij6; break; 
01597 }
01598 }
01599 j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
01600 {
01601 IKReal evalcond[4];
01602 IKReal x139=IKsin(j6);
01603 IKReal x140=IKcos(j6);
01604 evalcond[0]=((((cj4)*(new_r10)))+(((-1.00000000000000)*(x139)))+(((-1.00000000000000)*(new_r00)*(sj4))));
01605 evalcond[1]=((((-1.00000000000000)*(x140)))+(((cj4)*(new_r11)))+(((-1.00000000000000)*(new_r01)*(sj4))));
01606 evalcond[2]=((((cj4)*(new_r01)))+(((new_r11)*(sj4)))+(x139));
01607 evalcond[3]=((((-1.00000000000000)*(x140)))+(((cj4)*(new_r00)))+(((new_r10)*(sj4))));
01608 if( IKabs(evalcond[0]) > 0.000001  || IKabs(evalcond[1]) > 0.000001  || IKabs(evalcond[2]) > 0.000001  || IKabs(evalcond[3]) > 0.000001  )
01609 {
01610 continue;
01611 }
01612 }
01613 
01614 {
01615 vsolutions.push_back(IKSolution()); IKSolution& solution = vsolutions.back();
01616 solution.basesol.resize(7);
01617 solution.basesol[0].foffset = j0;
01618 solution.basesol[0].indices[0] = _ij0[0];
01619 solution.basesol[0].indices[1] = _ij0[1];
01620 solution.basesol[0].maxsolutions = _nj0;
01621 solution.basesol[1].foffset = j1;
01622 solution.basesol[1].indices[0] = _ij1[0];
01623 solution.basesol[1].indices[1] = _ij1[1];
01624 solution.basesol[1].maxsolutions = _nj1;
01625 solution.basesol[2].foffset = j2;
01626 solution.basesol[2].indices[0] = _ij2[0];
01627 solution.basesol[2].indices[1] = _ij2[1];
01628 solution.basesol[2].maxsolutions = _nj2;
01629 solution.basesol[3].foffset = j3;
01630 solution.basesol[3].indices[0] = _ij3[0];
01631 solution.basesol[3].indices[1] = _ij3[1];
01632 solution.basesol[3].maxsolutions = _nj3;
01633 solution.basesol[4].foffset = j4;
01634 solution.basesol[4].indices[0] = _ij4[0];
01635 solution.basesol[4].indices[1] = _ij4[1];
01636 solution.basesol[4].maxsolutions = _nj4;
01637 solution.basesol[5].foffset = j5;
01638 solution.basesol[5].indices[0] = _ij5[0];
01639 solution.basesol[5].indices[1] = _ij5[1];
01640 solution.basesol[5].maxsolutions = _nj5;
01641 solution.basesol[6].foffset = j6;
01642 solution.basesol[6].indices[0] = _ij6[0];
01643 solution.basesol[6].indices[1] = _ij6[1];
01644 solution.basesol[6].maxsolutions = _nj6;
01645 solution.vfree.resize(0);
01646 }
01647 }
01648 }
01649 
01650 } else
01651 {
01652 IKReal x141=((cj4)*(new_r12));
01653 IKReal x142=((new_r02)*(sj4));
01654 IKReal x143=((((-1.00000000000000)*(x142)))+(x141));
01655 IKReal x144=((new_r12)*(sj4));
01656 IKReal x145=((cj4)*(new_r02));
01657 IKReal x146=((x144)+(x145));
01658 IKReal x147=((1.00000000000000)+(new_r22));
01659 evalcond[0]=((-3.14159265358979)+(IKfmod(((1.11022302462516e-16)+(j5)), 6.28318530717959)));
01660 evalcond[1]=x147;
01661 evalcond[2]=new_r20;
01662 evalcond[3]=new_r21;
01663 evalcond[4]=x143;
01664 evalcond[5]=x143;
01665 evalcond[6]=x146;
01666 evalcond[7]=((-1.00000000000000)*(x146));
01667 evalcond[8]=new_r20;
01668 evalcond[9]=new_r21;
01669 evalcond[10]=x147;
01670 if( IKabs(evalcond[0]) < 0.0000010000000000  && IKabs(evalcond[1]) < 0.0000010000000000  && IKabs(evalcond[2]) < 0.0000010000000000  && IKabs(evalcond[3]) < 0.0000010000000000  && IKabs(evalcond[4]) < 0.0000010000000000  && IKabs(evalcond[5]) < 0.0000010000000000  && IKabs(evalcond[6]) < 0.0000010000000000  && IKabs(evalcond[7]) < 0.0000010000000000  && IKabs(evalcond[8]) < 0.0000010000000000  && IKabs(evalcond[9]) < 0.0000010000000000  && IKabs(evalcond[10]) < 0.0000010000000000  )
01671 {
01672 {
01673 IKReal j6array[1], cj6array[1], sj6array[1];
01674 bool j6valid[1]={false};
01675 _nj6 = 1;
01676 if( IKabs(((((cj4)*(new_r01)))+(((new_r11)*(sj4))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((((-1.00000000000000)*(new_r10)*(sj4)))+(((-1.00000000000000)*(cj4)*(new_r00))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((((cj4)*(new_r01)))+(((new_r11)*(sj4)))))+IKsqr(((((-1.00000000000000)*(new_r10)*(sj4)))+(((-1.00000000000000)*(cj4)*(new_r00)))))-1) <= IKFAST_SINCOS_THRESH )
01677     continue;
01678 j6array[0]=IKatan2(((((cj4)*(new_r01)))+(((new_r11)*(sj4)))), ((((-1.00000000000000)*(new_r10)*(sj4)))+(((-1.00000000000000)*(cj4)*(new_r00)))));
01679 sj6array[0]=IKsin(j6array[0]);
01680 cj6array[0]=IKcos(j6array[0]);
01681 if( j6array[0] > IKPI )
01682 {
01683     j6array[0]-=IK2PI;
01684 }
01685 else if( j6array[0] < -IKPI )
01686 {    j6array[0]+=IK2PI;
01687 }
01688 j6valid[0] = true;
01689 for(int ij6 = 0; ij6 < 1; ++ij6)
01690 {
01691 if( !j6valid[ij6] )
01692 {
01693     continue;
01694 }
01695 _ij6[0] = ij6; _ij6[1] = -1;
01696 for(int iij6 = ij6+1; iij6 < 1; ++iij6)
01697 {
01698 if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
01699 {
01700     j6valid[iij6]=false; _ij6[1] = iij6; break; 
01701 }
01702 }
01703 j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
01704 {
01705 IKReal evalcond[4];
01706 IKReal x148=IKsin(j6);
01707 IKReal x149=IKcos(j6);
01708 evalcond[0]=((((-1.00000000000000)*(x148)))+(((cj4)*(new_r10)))+(((-1.00000000000000)*(new_r00)*(sj4))));
01709 evalcond[1]=((((-1.00000000000000)*(x149)))+(((cj4)*(new_r11)))+(((-1.00000000000000)*(new_r01)*(sj4))));
01710 evalcond[2]=((((-1.00000000000000)*(x148)))+(((cj4)*(new_r01)))+(((new_r11)*(sj4))));
01711 evalcond[3]=((((cj4)*(new_r00)))+(((new_r10)*(sj4)))+(x149));
01712 if( IKabs(evalcond[0]) > 0.000001  || IKabs(evalcond[1]) > 0.000001  || IKabs(evalcond[2]) > 0.000001  || IKabs(evalcond[3]) > 0.000001  )
01713 {
01714 continue;
01715 }
01716 }
01717 
01718 {
01719 vsolutions.push_back(IKSolution()); IKSolution& solution = vsolutions.back();
01720 solution.basesol.resize(7);
01721 solution.basesol[0].foffset = j0;
01722 solution.basesol[0].indices[0] = _ij0[0];
01723 solution.basesol[0].indices[1] = _ij0[1];
01724 solution.basesol[0].maxsolutions = _nj0;
01725 solution.basesol[1].foffset = j1;
01726 solution.basesol[1].indices[0] = _ij1[0];
01727 solution.basesol[1].indices[1] = _ij1[1];
01728 solution.basesol[1].maxsolutions = _nj1;
01729 solution.basesol[2].foffset = j2;
01730 solution.basesol[2].indices[0] = _ij2[0];
01731 solution.basesol[2].indices[1] = _ij2[1];
01732 solution.basesol[2].maxsolutions = _nj2;
01733 solution.basesol[3].foffset = j3;
01734 solution.basesol[3].indices[0] = _ij3[0];
01735 solution.basesol[3].indices[1] = _ij3[1];
01736 solution.basesol[3].maxsolutions = _nj3;
01737 solution.basesol[4].foffset = j4;
01738 solution.basesol[4].indices[0] = _ij4[0];
01739 solution.basesol[4].indices[1] = _ij4[1];
01740 solution.basesol[4].maxsolutions = _nj4;
01741 solution.basesol[5].foffset = j5;
01742 solution.basesol[5].indices[0] = _ij5[0];
01743 solution.basesol[5].indices[1] = _ij5[1];
01744 solution.basesol[5].maxsolutions = _nj5;
01745 solution.basesol[6].foffset = j6;
01746 solution.basesol[6].indices[0] = _ij6[0];
01747 solution.basesol[6].indices[1] = _ij6[1];
01748 solution.basesol[6].maxsolutions = _nj6;
01749 solution.vfree.resize(0);
01750 }
01751 }
01752 }
01753 
01754 } else
01755 {
01756 if( 1 )
01757 {
01758 continue;
01759 
01760 } else
01761 {
01762 }
01763 }
01764 }
01765 }
01766 
01767 } else
01768 {
01769 {
01770 IKReal j6array[1], cj6array[1], sj6array[1];
01771 bool j6valid[1]={false};
01772 _nj6 = 1;
01773 if( IKabs(((gconst6)*(new_r21))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.00000000000000)*(gconst6)*(new_r20))) < IKFAST_ATAN2_MAGTHRESH )
01774     continue;
01775 j6array[0]=IKatan2(((gconst6)*(new_r21)), ((-1.00000000000000)*(gconst6)*(new_r20)));
01776 sj6array[0]=IKsin(j6array[0]);
01777 cj6array[0]=IKcos(j6array[0]);
01778 if( j6array[0] > IKPI )
01779 {
01780     j6array[0]-=IK2PI;
01781 }
01782 else if( j6array[0] < -IKPI )
01783 {    j6array[0]+=IK2PI;
01784 }
01785 j6valid[0] = true;
01786 for(int ij6 = 0; ij6 < 1; ++ij6)
01787 {
01788 if( !j6valid[ij6] )
01789 {
01790     continue;
01791 }
01792 _ij6[0] = ij6; _ij6[1] = -1;
01793 for(int iij6 = ij6+1; iij6 < 1; ++iij6)
01794 {
01795 if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
01796 {
01797     j6valid[iij6]=false; _ij6[1] = iij6; break; 
01798 }
01799 }
01800 j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
01801 {
01802 IKReal evalcond[8];
01803 IKReal x150=IKsin(j6);
01804 IKReal x151=IKcos(j6);
01805 evalcond[0]=((((sj5)*(x151)))+(new_r20));
01806 evalcond[1]=((new_r21)+(((-1.00000000000000)*(sj5)*(x150))));
01807 evalcond[2]=((((-1.00000000000000)*(x150)))+(((cj4)*(new_r10)))+(((-1.00000000000000)*(new_r00)*(sj4))));
01808 evalcond[3]=((((-1.00000000000000)*(x151)))+(((cj4)*(new_r11)))+(((-1.00000000000000)*(new_r01)*(sj4))));
01809 evalcond[4]=((((cj4)*(new_r01)))+(((new_r11)*(sj4)))+(((cj5)*(x150))));
01810 evalcond[5]=((((cj4)*(new_r00)))+(((new_r10)*(sj4)))+(((-1.00000000000000)*(cj5)*(x151))));
01811 evalcond[6]=((((-1.00000000000000)*(new_r21)*(sj5)))+(x150)+(((cj4)*(cj5)*(new_r01)))+(((cj5)*(new_r11)*(sj4))));
01812 evalcond[7]=((((-1.00000000000000)*(x151)))+(((cj4)*(cj5)*(new_r00)))+(((cj5)*(new_r10)*(sj4)))+(((-1.00000000000000)*(new_r20)*(sj5))));
01813 if( IKabs(evalcond[0]) > 0.000001  || IKabs(evalcond[1]) > 0.000001  || IKabs(evalcond[2]) > 0.000001  || IKabs(evalcond[3]) > 0.000001  || IKabs(evalcond[4]) > 0.000001  || IKabs(evalcond[5]) > 0.000001  || IKabs(evalcond[6]) > 0.000001  || IKabs(evalcond[7]) > 0.000001  )
01814 {
01815 continue;
01816 }
01817 }
01818 
01819 {
01820 vsolutions.push_back(IKSolution()); IKSolution& solution = vsolutions.back();
01821 solution.basesol.resize(7);
01822 solution.basesol[0].foffset = j0;
01823 solution.basesol[0].indices[0] = _ij0[0];
01824 solution.basesol[0].indices[1] = _ij0[1];
01825 solution.basesol[0].maxsolutions = _nj0;
01826 solution.basesol[1].foffset = j1;
01827 solution.basesol[1].indices[0] = _ij1[0];
01828 solution.basesol[1].indices[1] = _ij1[1];
01829 solution.basesol[1].maxsolutions = _nj1;
01830 solution.basesol[2].foffset = j2;
01831 solution.basesol[2].indices[0] = _ij2[0];
01832 solution.basesol[2].indices[1] = _ij2[1];
01833 solution.basesol[2].maxsolutions = _nj2;
01834 solution.basesol[3].foffset = j3;
01835 solution.basesol[3].indices[0] = _ij3[0];
01836 solution.basesol[3].indices[1] = _ij3[1];
01837 solution.basesol[3].maxsolutions = _nj3;
01838 solution.basesol[4].foffset = j4;
01839 solution.basesol[4].indices[0] = _ij4[0];
01840 solution.basesol[4].indices[1] = _ij4[1];
01841 solution.basesol[4].maxsolutions = _nj4;
01842 solution.basesol[5].foffset = j5;
01843 solution.basesol[5].indices[0] = _ij5[0];
01844 solution.basesol[5].indices[1] = _ij5[1];
01845 solution.basesol[5].maxsolutions = _nj5;
01846 solution.basesol[6].foffset = j6;
01847 solution.basesol[6].indices[0] = _ij6[0];
01848 solution.basesol[6].indices[1] = _ij6[1];
01849 solution.basesol[6].maxsolutions = _nj6;
01850 solution.vfree.resize(0);
01851 }
01852 }
01853 }
01854 
01855 }
01856 
01857 }
01858 }
01859 }
01860 
01861 }
01862 
01863 }
01864 
01865 } else
01866 {
01867 {
01868 IKReal j6array[1], cj6array[1], sj6array[1];
01869 bool j6valid[1]={false};
01870 _nj6 = 1;
01871 if( IKabs(((gconst5)*(new_r21))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.00000000000000)*(gconst5)*(new_r20))) < IKFAST_ATAN2_MAGTHRESH )
01872     continue;
01873 j6array[0]=IKatan2(((gconst5)*(new_r21)), ((-1.00000000000000)*(gconst5)*(new_r20)));
01874 sj6array[0]=IKsin(j6array[0]);
01875 cj6array[0]=IKcos(j6array[0]);
01876 if( j6array[0] > IKPI )
01877 {
01878     j6array[0]-=IK2PI;
01879 }
01880 else if( j6array[0] < -IKPI )
01881 {    j6array[0]+=IK2PI;
01882 }
01883 j6valid[0] = true;
01884 for(int ij6 = 0; ij6 < 1; ++ij6)
01885 {
01886 if( !j6valid[ij6] )
01887 {
01888     continue;
01889 }
01890 _ij6[0] = ij6; _ij6[1] = -1;
01891 for(int iij6 = ij6+1; iij6 < 1; ++iij6)
01892 {
01893 if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
01894 {
01895     j6valid[iij6]=false; _ij6[1] = iij6; break; 
01896 }
01897 }
01898 j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
01899 {
01900 IKReal evalcond[2];
01901 evalcond[0]=((new_r20)+(((sj5)*(IKcos(j6)))));
01902 evalcond[1]=((new_r21)+(((-1.00000000000000)*(sj5)*(IKsin(j6)))));
01903 if( IKabs(evalcond[0]) > 0.000001  || IKabs(evalcond[1]) > 0.000001  )
01904 {
01905 continue;
01906 }
01907 }
01908 
01909 {
01910 IKReal dummyeval[1];
01911 IKReal gconst7;
01912 gconst7=IKsign((((new_r12)*(new_r12))+((new_r02)*(new_r02))));
01913 dummyeval[0]=(((new_r12)*(new_r12))+((new_r02)*(new_r02)));
01914 if( IKabs(dummyeval[0]) < 0.0000010000000000  )
01915 {
01916 continue;
01917 
01918 } else
01919 {
01920 {
01921 IKReal j4array[1], cj4array[1], sj4array[1];
01922 bool j4valid[1]={false};
01923 _nj4 = 1;
01924 if( IKabs(((gconst7)*(new_r12)*(sj5))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((gconst7)*(new_r02)*(sj5))) < IKFAST_ATAN2_MAGTHRESH )
01925     continue;
01926 j4array[0]=IKatan2(((gconst7)*(new_r12)*(sj5)), ((gconst7)*(new_r02)*(sj5)));
01927 sj4array[0]=IKsin(j4array[0]);
01928 cj4array[0]=IKcos(j4array[0]);
01929 if( j4array[0] > IKPI )
01930 {
01931     j4array[0]-=IK2PI;
01932 }
01933 else if( j4array[0] < -IKPI )
01934 {    j4array[0]+=IK2PI;
01935 }
01936 j4valid[0] = true;
01937 for(int ij4 = 0; ij4 < 1; ++ij4)
01938 {
01939 if( !j4valid[ij4] )
01940 {
01941     continue;
01942 }
01943 _ij4[0] = ij4; _ij4[1] = -1;
01944 for(int iij4 = ij4+1; iij4 < 1; ++iij4)
01945 {
01946 if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
01947 {
01948     j4valid[iij4]=false; _ij4[1] = iij4; break; 
01949 }
01950 }
01951 j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
01952 {
01953 IKReal evalcond[12];
01954 IKReal x152=IKcos(j4);
01955 IKReal x153=IKsin(j4);
01956 evalcond[0]=((((new_r12)*(x152)))+(((-1.00000000000000)*(new_r02)*(x153))));
01957 evalcond[1]=((((new_r12)*(x153)))+(((new_r02)*(x152)))+(((-1.00000000000000)*(sj5))));
01958 evalcond[2]=((((new_r10)*(x152)))+(((-1.00000000000000)*(new_r00)*(x153)))+(((-1.00000000000000)*(sj6))));
01959 evalcond[3]=((((new_r11)*(x152)))+(((-1.00000000000000)*(cj6)))+(((-1.00000000000000)*(new_r01)*(x153))));
01960 evalcond[4]=((((new_r01)*(x152)))+(((new_r11)*(x153)))+(((cj5)*(sj6))));
01961 evalcond[5]=((((new_r00)*(x152)))+(((new_r10)*(x153)))+(((-1.00000000000000)*(cj5)*(cj6))));
01962 evalcond[6]=((((cj5)*(new_r02)*(x152)))+(((-1.00000000000000)*(new_r22)*(sj5)))+(((cj5)*(new_r12)*(x153))));
01963 evalcond[7]=((((-1.00000000000000)*(new_r10)*(sj5)*(x153)))+(((-1.00000000000000)*(new_r00)*(sj5)*(x152)))+(((-1.00000000000000)*(cj5)*(new_r20))));
01964 evalcond[8]=((((-1.00000000000000)*(new_r01)*(sj5)*(x152)))+(((-1.00000000000000)*(new_r11)*(sj5)*(x153)))+(((-1.00000000000000)*(cj5)*(new_r21))));
01965 evalcond[9]=((((-1.00000000000000)*(new_r21)*(sj5)))+(sj6)+(((cj5)*(new_r11)*(x153)))+(((cj5)*(new_r01)*(x152))));
01966 evalcond[10]=((1.00000000000000)+(((-1.00000000000000)*(new_r02)*(sj5)*(x152)))+(((-1.00000000000000)*(new_r12)*(sj5)*(x153)))+(((-1.00000000000000)*(cj5)*(new_r22))));
01967 evalcond[11]=((((-1.00000000000000)*(cj6)))+(((cj5)*(new_r00)*(x152)))+(((-1.00000000000000)*(new_r20)*(sj5)))+(((cj5)*(new_r10)*(x153))));
01968 if( IKabs(evalcond[0]) > 0.000001  || IKabs(evalcond[1]) > 0.000001  || IKabs(evalcond[2]) > 0.000001  || IKabs(evalcond[3]) > 0.000001  || IKabs(evalcond[4]) > 0.000001  || IKabs(evalcond[5]) > 0.000001  || IKabs(evalcond[6]) > 0.000001  || IKabs(evalcond[7]) > 0.000001  || IKabs(evalcond[8]) > 0.000001  || IKabs(evalcond[9]) > 0.000001  || IKabs(evalcond[10]) > 0.000001  || IKabs(evalcond[11]) > 0.000001  )
01969 {
01970 continue;
01971 }
01972 }
01973 
01974 {
01975 vsolutions.push_back(IKSolution()); IKSolution& solution = vsolutions.back();
01976 solution.basesol.resize(7);
01977 solution.basesol[0].foffset = j0;
01978 solution.basesol[0].indices[0] = _ij0[0];
01979 solution.basesol[0].indices[1] = _ij0[1];
01980 solution.basesol[0].maxsolutions = _nj0;
01981 solution.basesol[1].foffset = j1;
01982 solution.basesol[1].indices[0] = _ij1[0];
01983 solution.basesol[1].indices[1] = _ij1[1];
01984 solution.basesol[1].maxsolutions = _nj1;
01985 solution.basesol[2].foffset = j2;
01986 solution.basesol[2].indices[0] = _ij2[0];
01987 solution.basesol[2].indices[1] = _ij2[1];
01988 solution.basesol[2].maxsolutions = _nj2;
01989 solution.basesol[3].foffset = j3;
01990 solution.basesol[3].indices[0] = _ij3[0];
01991 solution.basesol[3].indices[1] = _ij3[1];
01992 solution.basesol[3].maxsolutions = _nj3;
01993 solution.basesol[4].foffset = j4;
01994 solution.basesol[4].indices[0] = _ij4[0];
01995 solution.basesol[4].indices[1] = _ij4[1];
01996 solution.basesol[4].maxsolutions = _nj4;
01997 solution.basesol[5].foffset = j5;
01998 solution.basesol[5].indices[0] = _ij5[0];
01999 solution.basesol[5].indices[1] = _ij5[1];
02000 solution.basesol[5].maxsolutions = _nj5;
02001 solution.basesol[6].foffset = j6;
02002 solution.basesol[6].indices[0] = _ij6[0];
02003 solution.basesol[6].indices[1] = _ij6[1];
02004 solution.basesol[6].maxsolutions = _nj6;
02005 solution.vfree.resize(0);
02006 }
02007 }
02008 }
02009 
02010 }
02011 
02012 }
02013 }
02014 }
02015 
02016 }
02017 
02018 }
02019 }
02020 }
02021 }
02022 }};
02023 
02024 
02027 IKFAST_API bool ik(const IKReal* eetrans, const IKReal* eerot, const IKReal* pfree, std::vector<IKSolution>& vsolutions) {
02028 IKSolver solver;
02029 return solver.ik(eetrans,eerot,pfree,vsolutions);
02030 }
02031 
02032 IKFAST_API const char* getKinematicsHash() { return "2f0978eec3507105782751e56c521b6b"; }
02033 
02034 IKFAST_API const char* getIKFastVersion() { return "55"; }
02035 
02036 #ifdef IKFAST_NAMESPACE
02037 } // end namespace
02038 #endif
02039 
02040 #ifndef IKFAST_NO_MAIN
02041 #include <stdio.h>
02042 #include <stdlib.h>
02043 #ifdef IKFAST_NAMESPACE
02044 using namespace IKFAST_NAMESPACE;
02045 #endif
02046 int main(int argc, char** argv)
02047 {
02048     if( argc != 12+getNumFreeParameters()+1 ) {
02049         printf("\nUsage: ./ik r00 r01 r02 t0 r10 r11 r12 t1 r20 r21 r22 t2 free0 ...\n\n"
02050                "Returns the ik solutions given the transformation of the end effector specified by\n"
02051                "a 3x3 rotation R (rXX), and a 3x1 translation (tX).\n"
02052                "There are %d free parameters that have to be specified.\n\n",getNumFreeParameters());
02053         return 1;
02054     }
02055 
02056     std::vector<IKSolution> vsolutions;
02057     std::vector<IKReal> vfree(getNumFreeParameters());
02058     IKReal eerot[9],eetrans[3];
02059     eerot[0] = atof(argv[1]); eerot[1] = atof(argv[2]); eerot[2] = atof(argv[3]); eetrans[0] = atof(argv[4]);
02060     eerot[3] = atof(argv[5]); eerot[4] = atof(argv[6]); eerot[5] = atof(argv[7]); eetrans[1] = atof(argv[8]);
02061     eerot[6] = atof(argv[9]); eerot[7] = atof(argv[10]); eerot[8] = atof(argv[11]); eetrans[2] = atof(argv[12]);
02062     for(std::size_t i = 0; i < vfree.size(); ++i)
02063         vfree[i] = atof(argv[13+i]);
02064     bool bSuccess = ik(eetrans, eerot, vfree.size() > 0 ? &vfree[0] : NULL, vsolutions);
02065 
02066     if( !bSuccess ) {
02067         fprintf(stderr,"Failed to get ik solution\n");
02068         return -1;
02069     }
02070 
02071     printf("Found %d ik solutions:\n", (int)vsolutions.size());
02072     std::vector<IKReal> sol(getNumJoints());
02073     for(std::size_t i = 0; i < vsolutions.size(); ++i) {
02074         printf("sol%d (free=%d): ", (int)i, (int)vsolutions[i].GetFree().size());
02075         std::vector<IKReal> vsolfree(vsolutions[i].GetFree().size());
02076         vsolutions[i].GetSolution(&sol[0],vsolfree.size()>0?&vsolfree[0]:NULL);
02077         for( std::size_t j = 0; j < sol.size(); ++j)
02078             printf("%.15f, ", sol[j]);
02079         printf("\n");
02080     }
02081     return 0;
02082 }
02083 
02084 #endif


SIA20D_Mesh_arm_navigation
Author(s): Shaun Edwards
autogenerated on Thu Jan 2 2014 11:30:02