00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <IKOR/general.h>
00025 #include <IKOR/Globals.h>
00026
00027 #define DEBUG_OUT 1
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 int IKOR_driver(IKCriterion, IKMethod, Optimization, N_use, M_use)
00053 int *IKCriterion,
00054 *IKMethod,
00055 Optimization,
00056 M_use,
00057 N_use;
00058 {
00059 int i, j, k,
00060 ns,
00061 STEP,
00062 Num_Of_Pts,
00063 quit = 0;
00064
00065 float distance;
00066 double XTraj[MAX_PTS][6],
00067 spheredata[4][4];
00068 MATRIX *Jacob,
00069 *dx,
00070 *dq,
00071 *x_of_link,
00072 *Pos_error;
00073 Solutions *FSP_data;
00074 History Old_DQs;
00075
00076
00077
00078
00079 N=N_use;
00080 M=M_use;
00081 Old_DQs.whereami = -1;
00082 for (i=0; i<HIST_SIZE; i++)
00083 Old_DQs.dq[i].DQ = mat_malloc( M , 1 );
00084 Pos_error = mat_malloc(N, 1);
00085 dx = mat_malloc(N, 1);
00086 Jacob = mat_malloc(N, M);
00087
00088 x_of_link=mat_malloc(Robot->NL+1,N);
00089 FSP_data =Solutions_init(M,N);
00090
00091 if (!(Num_Of_Pts=OPEN_FILES(XTraj, PoorMansFile, FSP_data->Qarray)))
00092 return (-2);
00093 ns=spheres(spheredata,datafp);
00094 dq = mat_malloc(M,1);
00095 Update_History(&Old_DQs, dq);
00096 mat_free(dq);
00097
00098 Robot->Weights->rows = Robot->Weights->cols = M;
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111 #ifdef DEBUG_OUT
00112 fprintf (stderr, "\n\n\n"
00113 " *********************************************\n"
00114 " INVERSE KINEMATIC AND REDUNDANCY RESOLVER \n"
00115 " For HERMIES CESARm, %d D.O.F, %d D.O.R. \n"
00116 " *********************************************", M,M-N);
00117 fprintf (stderr, "\n\n\n"
00118 " < NUMBER OF POINTS IN TRAJECTORY > %d \n"
00119 " << Time Step >> \n"
00120 " --------------------- \n"
00121 "\n<< -1>>", Num_Of_Pts);
00122 #endif
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132 for (STEP = 0; STEP < Num_Of_Pts ; STEP++)
00133 {
00134
00135
00136
00137
00138
00139
00140 for (i=0;i< Robot->NA;i++)
00141 if (i<M) fprintf (CheezyFile, "%f ", FSP_data->Qarray->p[i][0]);
00142 fprintf (CheezyFile, " \n");
00143 fflush (CheezyFile);
00144
00145 if (DEBUG)
00146 fprintf (datafp, "\n*************STEP <%d> ****************\n", STEP+1);
00147 #ifdef DEBUG_OUT
00148 fprintf (stderr, "\r<<%3d>>", STEP+1);
00149 #endif
00150
00151
00152
00153
00154 #ifndef FSP_DEBUG
00155 GET_JACOBIAN(Jacob, FSP_data->Qarray);
00156 GET_ACTUAL_X(FSP_data->Qarray, x_of_link);
00157
00158 if (DEBUG) {
00159 fmat_pr (datafp, "Jacobian for Current Configuration", Jacob);
00160 fprintf (datafp, "\nCurrent Position\n" );
00161 for (i = 0; i < N; i++)
00162 fprintf(datafp,"%s : %9f\n", dxLabel[i], x_of_link->p[Robot->NL][i]);
00163 fprintf (datafp, "Next Point in Trajectory\n");
00164 }
00165
00166
00167
00168
00169
00170
00171 for (i = 0; i < N; i++)
00172 {
00173 if (DEBUG) fprintf(datafp,"%s : %9f\n", dxLabel[i], XTraj[STEP][i]);
00174 dx -> p[i][0] = XTraj[STEP][i] - x_of_link->p[Robot->NL][i];
00175 Pos_error->p[i][0]=XTraj[STEP?STEP-1:0][i] - x_of_link->p[Robot->NL][i];
00176 if ( fabs( dx->p[i][0] ) < SMALL ) dx->p[i][0]=ZERO;
00177 if (( i < 3) && ( fabs(dx->p[i][0]) > BIG) ) IKerror(26,OK,dxLabel[i]);
00178 }
00179
00180 if (DEBUG) fmat_prf(datafp,"Pos Error (Cur Pos - Prev Target)",Pos_error);
00181
00182
00183
00184
00185
00186
00187 if (Robot->Orient)
00188 {
00189
00190 dx->p[3][0] =
00191 correct_euler( dx->p[3][0],x_of_link->p[Robot->NL][3],XTraj[STEP+1][3]);
00192 dx->p[5][0] =
00193 correct_euler( dx->p[5][0],x_of_link->p[Robot->NL][5],XTraj[STEP+1][5]);
00194
00195 Euler_to_Velocities (x_of_link, dx);
00196 if (Robot->Orient == ZEROD_OMEGAS)
00197 dx->p[3][0]=dx->p[4][0]=dx->p[5][0]=ZERO;
00198 }
00199 #else
00200 GetData(Jacob, dx);
00201 STEP = Num_Of_Pts;
00202 #endif
00203
00204
00205
00206
00207
00208 FSP_data->cn = 0;
00209 if (IKCriterion[0] != 1)
00210 dq = FSP (FSP_data, &Old_DQs, Jacob, dx, IKCriterion, IKMethod,
00211 Optimization, ns, spheredata, x_of_link, datafp);
00212 else
00213 dq = CALC_PSEUDO (Jacob, dx);
00214 if (dq== (MATRIX *) -1) break;
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224 for (i = 0; i < M; i++)
00225 {
00226 if ((IKCriterion[0]!=1)&&(fabs(FSP_data->Xelim->p[i][0]) > SMALL))
00227 dq->p[i][0] = FSP_data->Xelim->p[i][0];
00228
00229 FSP_data->Qarray->p[i][0] += dq-> p[i][0];
00230
00231 if (!Robot->Angles[i].Prism)
00232 {
00233 if (FSP_data->Qarray->p[i][0] > 2*PI)
00234 FSP_data->Qarray->p[i][0] -= 2*PI;
00235 if (FSP_data->Qarray->p[i][0] < -2*PI)
00236 FSP_data->Qarray->p[i][0] += 2*PI;
00237 }
00238 }
00239
00240 mat_mul(Jacob,dq,dx);
00241 distance = ZERO;
00242 for (i = 0; i<3; i++) distance += dx->p[i][0] * dx->p[i][0];
00243 distance = sqrt (distance);
00244 for (i = 0; i < M; i++) {
00245 fprintf(dqfile, "%10.7f", dq->p[i][0]);
00246
00247
00248
00249
00250 }
00251 fprintf(dqfile,"\n");
00252
00253 Update_History(&Old_DQs, dq);
00254
00255 if (DEBUG) {
00256 fmat_prf(datafp, "dq (radians)", dq);
00257 fmat_prf(datafp, "resulting dx", dx);
00258 fmat_prf(datafp, "Qarray (radians)", FSP_data->Qarray);
00259 }
00260
00261 #ifdef DEBUG_OUT
00262
00263 fprint_norm( NormFile, dq, datafp );
00264
00265 #endif
00266 mat_free(dq);
00267
00268 if (quit < 0) break;
00269 }
00270
00271
00272
00273
00274
00275
00276 fprintf (datafp, "\n\n ----FINAL SUMMARY------\n"
00277 " --- Exit Status: %d ---\n"
00278 " Errors in final point: \n", quit);
00279
00280 fprintf (datafp, "\nStarting Coordinates:\n");
00281 for (i = 0; i < N; i++)
00282 fprintf (datafp, "Element [%d] >%f\n", i, XTraj[0][i]);
00283
00284 fprintf (datafp, "\nRequested Ending Coordinates\n");
00285 for (i = 0; i < N; i++)
00286 fprintf (datafp, "Element [%d] >%f\n", i, XTraj[Num_Of_Pts-1][i]);
00287
00288 fmat_pr (datafp, "Actual Ending Coordinates:", x_of_link);
00289
00290 #ifdef DEBUG_OUT
00291 fprintf (stderr,"\n DATA FILE %s HAS BEEN CREATED AND CONTAINS\n"
00292 " THE ANGLES FOR THE MANIPULATOR FOR EACH TIME \n"
00293 " STEP. EXAMINE, OR RUN IT THROUGH A SIMULATOR.\n",
00294 PoorMansFile);
00295 #endif
00296
00297
00298
00299
00300 fclose(ErrorFile);
00301 fclose(NormFile);
00302 fclose(CheezyFile);
00303 fclose(datafp);
00304
00305 Solutions_free(FSP_data);
00306 mat_free(Pos_error);
00307 mat_free(x_of_link);
00308 mat_free(Jacob);
00309 mat_free(dx);
00310 for (i=0; i<HIST_SIZE; i++)
00311 mat_free(Old_DQs.dq[i].DQ);
00312 free (LL);
00313
00314 return (quit);
00315 }
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335 void Euler_to_Velocities (MATRIX *x_of_link, MATRIX *dx)
00336 {
00337 float dGAMMA, gamma,
00338 dBETA, beta,
00339 dALPHA, alpha;
00340
00341
00342 gamma = x_of_link->p[Robot->NL][3];
00343 dGAMMA = dx->p[3][0];
00344
00345 beta = x_of_link->p[Robot->NL][4];
00346 dBETA = dx->p[4][0];
00347
00348 alpha = x_of_link->p[Robot->NL][5];
00349 dALPHA = dx->p[5][0];
00350
00351 dx->p[3][0]= dALPHA*cos(gamma)*cos(beta) - dBETA*sin(gamma);
00352 dx->p[4][0]= dALPHA*sin(gamma)*cos(beta) + dBETA*cos(gamma);
00353 dx->p[5][0]=-dALPHA*sin(beta) + dGAMMA;
00354
00355 if (DEBUG) {
00356 fprintf(datafp,"\nEuler Velocity Transforms and Corrections\n");
00357 fprintf(datafp,"\n%s%12.8f%s%12.8f\n%s%12.8f%s%12.8f\n%s%12.8f%s%12.8f\n",
00358 "YAW : gamma : ", gamma , " dGAMMA : ", dGAMMA,
00359 "PITCH: beta : ", beta , " dBETA : ", dBETA,
00360 "ROLL : alpha : ", alpha , " dALPHA : ", dALPHA );
00361 fprintf(datafp,"dx(wx) : %12.8f\ndx(wy) : %12.8f\ndx(wz) : %12.8f\n",
00362 (dx->p[3][0]), (dx->p[4][0]), (dx->p[5][0]) );
00363 }
00364 }
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383 float correct_euler ( float angle, float curr, float dest )
00384 {
00385
00386
00387 if ( fabs( angle ) > PI )
00388 {
00389 if (DEBUG) fprintf(datafp,"\nFaulty orientation velocity, old: %f", angle);
00390
00391 angle = PI - fabs(dest) + PI - fabs(curr);
00392
00393 if (( curr < 0 ) && ( dest > 0 ))
00394 angle = -angle;
00395
00396 if (DEBUG) fprintf(datafp, "... new: %f\n", angle);
00397 }
00398
00399 return (angle);
00400 }
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419 MATRIX *CALC_PSEUDO (MATRIX *Jacob, MATRIX *dx)
00420 {
00421 int i, j;
00422 MATRIX *Jacobinv,
00423 *dq;
00424
00425 Jacobinv = mat_malloc(M,M);
00426
00427 mat_cp(Jacob, Jacobinv);
00428
00429 for (i=0;i<M;i++)
00430 for (j=N; j< M; j++)
00431 Jacobinv->p[j][i] = 0.0;
00432
00433 mat_pseudoinv(Jacobinv);
00434
00435 Jacobinv->cols = N;
00436 dq = mat_mul2(Jacobinv, dx);
00437 Jacobinv->cols = M;
00438
00439 if (DEBUG) {
00440 fmat_pr(datafp,"*** Jacobian ***", Jacob);
00441 fmat_prf(datafp,"requested dx", dx);
00442 }
00443
00444 mat_free(Jacobinv);
00445 return (dq);
00446 }
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471 MATRIX *FSP(FSP_data, Old_DQs, Jacob, dx, IKCriterion, IKMethod, Optimization,
00472 ns, spheredata, x_of_link, datafp)
00473 FILE *datafp;
00474 int *IKCriterion,
00475 *IKMethod,
00476 Optimization,
00477 ns;
00478 double spheredata[4][4];
00479 MATRIX *dx,
00480 *Jacob,
00481 *x_of_link;
00482 Solutions *FSP_data;
00483 History *Old_DQs;
00484 {
00485 int i, j, k,
00486 got_gs=TRUE,
00487 Terminate;
00488 MATRIX *dq,
00489 *B,
00490 *H;
00491
00492 Terminate = Solution_generator(FSP_data, Jacob, dx, datafp);
00493 if (Terminate == NOT_COMPLETE) IKerror(10, FATAL, "");
00494 B = mat_malloc ( M, M );
00495 H = mat_malloc ( SPAN, 1 );
00496
00497 switch (IKCriterion[0]) {
00498 case 0: Least_Norm (B, H, datafp); break;
00499 case 1:
00500 case 2:
00501 case 3:
00502 case 4: Least_Flow (B, H, FSP_data->Qarray, datafp); break;
00503 default: fprintf(stderr, "Requested criterion does not exist! \n");
00504 break;
00505 }
00506
00507 if (Optimization == BANGBANG)
00508 {
00509 if (IKCriterion[0] == 4)
00510 {
00511 dq = findt_without_Betas_BANGBANG(FSP_data, B, H,
00512 Old_DQs->dq[Old_DQs->whereami].DQ, datafp);
00513 }
00514 else IKerror(31, FATAL, "BANGBANG only for Flow Currently\n");
00515 }
00516 else if (Optimization == LAGRANGIAN)
00517 {
00518 if (STEP == ONE)
00519 {
00520
00521
00522
00523 if (IKMethod[OBSTACLES])
00524 avoid_obstacles (FSP_data, Jacob, dx, x_of_link,
00525 ns, spheredata, &got_gs, datafp);
00526 if (IKMethod[JN_LIMITS])
00527 avoid_limits (FSP_data, Jacob, dx, &got_gs, datafp);
00528 }
00529
00530 if (Robot->PLAT.Holonomic)
00531 if (FSP_data->cn)
00532 dq = findt_with_Betas_Holonomic(FSP_data, B, H, datafp);
00533 else
00534 dq = findt_without_Betas_Holonomic(FSP_data, B, H, datafp);
00535 else
00536 if (FSP_data->cn)
00537 dq = findt_with_Betas_Nonholonomic(FSP_data, B, H, datafp);
00538 else
00539 dq = findt_without_Betas_Nonholonomic(FSP_data, B, H, datafp);
00540
00541
00542 if (STEP == TWO)
00543 {
00544
00545
00546
00547
00548 got_gs = FALSE;
00549
00550 for (i = 0; i < M; i++)
00551 {
00552 if (fabs(FSP_data->Xelim->p[i][0]) > SMALL)
00553 dq->p[i][0] = FSP_data->Xelim->p[i][0];
00554
00555 FSP_data->Qarray->p[i][0] += dq-> p[i][0];
00556
00557 if (!Robot->Angles[i].Prism)
00558 {
00559 if (FSP_data->Qarray->p[i][0] > 2*PI)
00560 FSP_data->Qarray->p[i][0] -= 2*PI;
00561 if (FSP_data->Qarray->p[i][0] < -2*PI)
00562 FSP_data->Qarray->p[i][0] += 2*PI;
00563 }
00564 dq -> p[i][0] = ZERO;
00565 }
00566
00567
00568
00569
00570
00571 if (IKMethod[OBSTACLES])
00572 avoid_obstacles (FSP_data, Jacob, dx, x_of_link,
00573 ns, spheredata, &got_gs, datafp);
00574 if (IKMethod[JN_LIMITS])
00575 avoid_limits (FSP_data, Jacob, dx, &got_gs, datafp);
00576
00577 if (got_gs)
00578 {
00579 Update_History(Old_DQs, dq);
00580 mat_free(dq);
00581 if (Robot->PLAT.Holonomic)
00582 dq = findt_with_Betas_Holonomic(FSP_data, B, H, datafp);
00583 else
00584 dq = findt_with_Betas_Nonholonomic(FSP_data, B, H, datafp);
00585 }
00586 }
00587 }
00588 else if (Optimization == SIMPLEX)
00589 {
00590 if (IKCriterion[0] == 4)
00591 {
00592 dq = findt_without_Betas_SIMPLX(FSP_data, B, H, datafp);
00593 }
00594 else IKerror(31, FATAL, "SIMPLX only for Flow Currently\n");
00595 }
00596
00597
00598 mat_free (B);
00599 mat_free (H);
00600
00601 return(dq);
00602 }
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622 int OPEN_FILES(XTraj, PoorMansFile, Qarray)
00623 char *PoorMansFile;
00624 double XTraj[MAX_PTS][6];
00625 MATRIX *Qarray;
00626 {
00627 FILE *XYZfile, *EAfile;
00628 int i, Num_Of_Pts,
00629 flag = -1,
00630 fatal= 1;
00631 char tempname[20];
00632 float temp_Q;
00633
00634
00635 #ifdef DEBUG_OUT
00636 fprintf (stderr, "\nANGLES PRINTED TO %s.\n", PoorMansFile);
00637 #endif
00638
00639 if (Robot->Orient)
00640 if ((EAfile = fopen("EulerAngles", "r")) == NULL)
00641 { IKerror (11, OK, "EulerAngles"); flag = 0; }
00642 if ((XYZfile = fopen("TrajectoryPts","r")) == NULL)
00643 { IKerror (11, OK, "TrajectoryPts"); flag = 0; }
00644 if ((CheezyFile = fopen(PoorMansFile, "w")) == NULL)
00645 { IKerror (11, OK, PoorMansFile); flag = 0; }
00646 if ((NormFile = fopen("NORMFILE", "w")) == NULL)
00647 { IKerror (11, OK, "NORMFILE"); flag = 0; }
00648 if ((ErrorFile = fopen("ERRORFILE", "w")) == NULL)
00649 { IKerror (11, OK, "ERRORFILE"); flag = 0; }
00650 if ((FLWfile = fopen("FLOW", "w")) == NULL)
00651 { IKerror (11, OK, "FLOW"); flag = 0; }
00652 if ((dqfile = fopen("Delta-qs", "w")) == NULL)
00653 { IKerror (11, OK, "Delta-qs"); flag = 0; }
00654 if ((distfp = fopen("Distance", "w")) == NULL)
00655 { IKerror (11, OK, "Distance"); flag = 0; }
00656
00657 if (!flag) IKerror (12, FATAL, "OPEN_FILES");
00658
00659
00660
00661
00662 fscanf(XYZfile, "%d", &Num_Of_Pts);
00663 if (Num_Of_Pts > MAX_PTS)
00664 { IKerror (15, OK, "MAX_PTS in general.h"); Num_Of_Pts = MAX_PTS; }
00665
00666
00667
00668
00669
00670 for (i = 0; i < Robot->NA; i++)
00671 {
00672 fscanf ( XYZfile, "%f", &temp_Q);
00673 if (i < M) Qarray->p[i][0] = rad(temp_Q);
00674 }
00675 fmat_pr (datafp, "Initial Q Array", Qarray);
00676 for (i = 0; i < Num_Of_Pts; i++)
00677 {
00678 fscanf(XYZfile, "%lf %lf %lf",
00679 &XTraj[i][0], &XTraj[i][1], &XTraj[i][2]);
00680 if (N>3)
00681 fscanf(EAfile, "%lf %lf %lf",
00682 &XTraj[i][3], &XTraj[i][4], &XTraj[i][5]);
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693 }
00694 fclose(XYZfile);
00695 if (N>3) fclose(EAfile);
00696
00697
00698
00699
00700
00701
00702
00703
00704 fprintf (CheezyFile, "M: %d N: %d\n", M, N);
00705
00706 return (Num_Of_Pts);
00707 }
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728 int Init_Globals()
00729 {
00730 int i,j;
00731 float HandWidth =0.05,
00732 HandLength =0.05,
00733 FrontLength =ZERO,
00734 SideLength =ZERO;
00735
00736
00737 if ((datafp = fopen("data", "w")) == NULL) IKerror (11, FATAL, "data");
00738
00739
00740
00741
00742 init_ARM();
00743
00744
00745 all_links = (MATRIX **) malloc ( sizeof(MATRIX *) * Robot->NL );
00746 link_location = (MATRIX **) malloc ( sizeof(MATRIX *) * Robot->NL );
00747
00748
00749
00750 E1 = mat_malloc(4,1);
00751 E2 = mat_malloc(4,1);
00752 E3 = mat_malloc(4,1);
00753 E4 = mat_malloc(4,1);
00754
00755
00756 EW1 = mat_malloc(4,1);
00757 EW2 = mat_malloc(4,1);
00758 EW3 = mat_malloc(4,1);
00759 EW4 = mat_malloc(4,1);
00760
00761
00762 P1 = mat_malloc(4,1);
00763 P2 = mat_malloc(4,1);
00764 P3 = mat_malloc(4,1);
00765 P4 = mat_malloc(4,1);
00766
00767 PW1 = mat_malloc(4,1);
00768 PW2 = mat_malloc(4,1);
00769 PW3 = mat_malloc(4,1);
00770 PW4 = mat_malloc(4,1);
00771
00772
00773
00774 for ( i = 0; i < Robot->NL; i++) {
00775
00776 all_links[i] = mat_malloc(4,1);
00777
00778 link_location[i] = mat_malloc(4,1);
00779 }
00780
00781 R = mat_malloc(4,1);
00782 X = mat_malloc(4,1);
00783 RW = mat_malloc(4,1);
00784 XW = mat_malloc(4,1);
00785
00786
00787 for (i=0;i<=3;i++)
00788 {
00789 for (j=0; j<Robot->NL; j++) {
00790 link_location[j]->p[i][0]=0;
00791 }
00792 R->p[i][0]=0; X->p[i][0]=0;
00793 P1->p[i][0]=0;P2->p[i][0]=0;P3->p[i][0]=0;P4->p[i][0]=0;
00794 E1->p[i][0]=0;E2->p[i][0]=0;E3->p[i][0]=0;E4->p[i][0]=0;
00795 }
00796
00797
00798 E1->p[0][0]=Robot->LINKS[Robot->NL-1]+HandLength; E1->p[2][0]=-HandWidth;
00799 E1->p[3][0]=1.0;
00800 E2->p[0][0]=Robot->LINKS[Robot->NL-1] ; E2->p[2][0]=-HandWidth;
00801 E2->p[3][0]=1.0;
00802 E3->p[0][0]=Robot->LINKS[Robot->NL-1] ; E3->p[2][0]= HandWidth;
00803 E3->p[3][0]=1.0;
00804 E4->p[0][0]=Robot->LINKS[Robot->NL-1]+HandLength; E4->p[2][0]= HandWidth;
00805 E4->p[3][0]=1.0;
00806
00807
00808 if (Robot->PLAT.Exist) {
00809 FrontLength = Robot->PLAT.Length;
00810 SideLength = Robot->PLAT.Width;
00811 }
00812 P1->p[0][0]=-FrontLength/2; P1->p[1][0]=-SideLength/2; P1->p[3][0]=1.0;
00813 P2->p[0][0]=-FrontLength/2; P2->p[1][0]= SideLength/2; P2->p[3][0]=1.0;
00814 P3->p[0][0]= FrontLength/2; P3->p[1][0]= SideLength/2; P3->p[3][0]=1.0;
00815 P4->p[0][0]= FrontLength/2; P4->p[1][0]=-SideLength/2; P4->p[3][0]=1.0;
00816
00817
00818 R->p[2][0]=0; R->p[3][0]=1.0;
00819 X->p[2][0]=0; X->p[3][0]=1.0;
00820 }
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833 void Update_History(History *Old_DQs, MATRIX *dq)
00834 {
00835 int prev;
00836
00837 Old_DQs->whereami++;
00838 if (Old_DQs->whereami == HIST_SIZE) Old_DQs->whereami = 0;
00839 prev = Old_DQs->whereami-1;
00840 if (prev == -1) prev = HIST_SIZE - 1;
00841
00842 mat_cp(dq, Old_DQs->dq[Old_DQs->whereami].DQ);
00843 Old_DQs->dq[Old_DQs->whereami].time=Old_DQs->dq[prev].time+0.033332;
00844
00845
00846
00847 }