home *** CD-ROM | disk | FTP | other *** search
/ Between Heaven & Hell 2 / BetweenHeavenHell.cdr / 500 / 470 / rccl037 < prev    next >
Text File  |  1987-03-02  |  4KB  |  208 lines

  1. /*
  2.  * RCCL Version 1.0           Author :  Vincent Hayward
  3.  *                                      School of Electrical Engineering
  4.  *                                      Purdue University
  5.  *      Dir     : src
  6.  *      File    : news.c
  7.  *      Remarks : Mostly dynamic allocation of rccl structures.
  8.  *      Usage   : part of the library
  9.  */
  10.  
  11. /*LINTLIBRARY*/
  12.  
  13. #include "../h/rccl.h"
  14. #include "../h/manip.h"
  15.  
  16. /*
  17.  * dummy function meaning that the transform is really a constant transform
  18.  */
  19.  
  20. int const() /*::*/
  21. {
  22. }
  23.  
  24. /*
  25.  * dummy function meaning that the transform may change during execution
  26.  * but whose value is taken into account at the transition time
  27.  */
  28.  
  29. int hold() /*::*/
  30. {
  31. }
  32.  
  33. /*
  34.  * dummy function meaning that the transform may change during execution
  35.  */
  36.  
  37. int varb() /*::*/
  38. {
  39. }
  40.  
  41. /*
  42.  * creates a position record
  43.  */
  44.  
  45. PST_PTR newposition_n() /*::*/
  46. {
  47.     char *malloc();
  48.     PST_PTR l;
  49.  
  50.     if ((l = (PST_PTR) malloc(sizeof(PST))) == NULL) {
  51.         giveup("mem. alloc error", YES);
  52.     }
  53.     l->name = "";
  54.     l->code = OK;
  55.     l->scal = 0.;
  56.     l->end = 0;
  57.     l->cfnsp = l->tfnsp = l->coorp = l->toolp = NO;
  58.     l->t6ptr = l->tlptr = l->pos = NULL;
  59.     return(l);
  60. }
  61.  
  62.  
  63. /*
  64.  * creates a term record
  65.  */
  66.  
  67. TERM_PTR newterm_n() /*::*/
  68. {
  69.     char *malloc();
  70.     TERM_PTR l;
  71.  
  72.     if ((l = (TERM_PTR) malloc(sizeof(TERM))) == NULL) {
  73.         giveup("mem. alloc error", YES);
  74.     }
  75.     l->trsf = NULL;
  76.     l->altr = NULL;
  77.     l->oldt = NULL;
  78.     l->hd.put = NULL;
  79.     l->hd.get = NULL;
  80.     return(l);
  81. }
  82.  
  83.  
  84. /*
  85.  * creates a transform record
  86.  */
  87.  
  88. TRSF_PTR newtrans(string, fct)  /*::*/
  89. char *string;
  90. TRFN fct; /* pointer to a function */
  91. {
  92.     TRSF_PTR p;
  93.  
  94.     if ((p = (TRSF_PTR) malloc(sizeof(TRSF))) == NULL) {
  95.         giveup("mem. alloc error", YES);
  96.     }
  97.     p->name     = string;
  98.     p->fn       = fct;
  99.     p->timeval  = 0;
  100.  
  101.     /* initialize with identity transforms */
  102.  
  103.     p->n.x = p->o.y = p->a.z = 1.;
  104.     p->n.y = p->n.z = p->o.x = p->o.z = p->a.x = p->a.y = 0.;
  105.     p->p.x = p->p.y = p->p.z = 0.;
  106.  
  107.     return(p);
  108. }
  109.  
  110.  
  111. /*
  112.  * genrates a transform given the translation
  113.  * vector, and the rotation about a vector
  114.  */
  115.  
  116. TRSF_PTR gentr_rot(name, tx, ty, tz, k, h) /*::*/
  117. char *name;
  118. real tx, ty, tz, h;
  119. VECT_PTR k;
  120. {
  121.     TRSF_PTR t;
  122.  
  123.     t = rot(trsl(newtrans(name, const), tx, ty, tz), k, h);
  124.  
  125.     if (prints_out > 1) /* print value of transform */
  126.         printrn(t, fpi);
  127.     return(t);
  128. }
  129.  
  130.  
  131. /*
  132.  * generates a transform given the translation
  133.  */
  134.  
  135. TRSF_PTR gentr_trsl(name, tx, ty, tz) /*::*/
  136. char *name;
  137. real tx, ty, tz;
  138. {
  139.     TRSF_PTR t;
  140.  
  141.     t = trsl(newtrans(name, const), tx, ty, tz);
  142.  
  143.     if (prints_out > 1) /* print value of transform */
  144.         printrn(t, fpi);
  145.     return(t);
  146. }
  147.  
  148.  
  149. /*
  150.  * generates a transform given the translation
  151.  * vector, and the rotation expressed with euler angles
  152.  */
  153.  
  154. TRSF_PTR gentr_eul(name, tx, ty, tz, phi, the, psi) /*::*/
  155. char *name;
  156. real tx, ty, tz;
  157. real phi, the, psi;
  158. {
  159.     TRSF_PTR t;
  160.  
  161.     t = eul(trsl(newtrans(name, const), tx, ty, tz), phi, the, psi);
  162.  
  163.     if (prints_out > 1) /* print value of transform */
  164.         printrn(t, fpi);
  165.     return(t);
  166. }
  167.  
  168.  
  169. /*
  170.  * generates a transform given the translation
  171.  * vector, and the rotation expressed with rpy angles
  172.  */
  173.  
  174. TRSF_PTR gentr_rpy(name, tx, ty, tz, phi, the, psi) /*::*/
  175. char *name;
  176. real tx, ty, tz;
  177. real phi, the, psi;
  178. {
  179.     TRSF_PTR t;
  180.  
  181.     t = rpy(trsl(newtrans(name, const), tx, ty, tz), phi, the, psi);
  182.  
  183.     if (prints_out > 1) /* print value of transform */
  184.         printrn(t, fpi);
  185.     return(t);
  186. }
  187.  
  188.  
  189. /*
  190.  * generates a transform given the
  191.  * p, a, o vectors
  192.  */
  193.  
  194. TRSF_PTR gentr_pao(name, px, py, pz, ax, ay, az, ox, oy, oz) /*::*/
  195. char *name;
  196. real px, py, pz, ax, ay, az, ox, oy, oz;
  197. {
  198.     TRSF_PTR t;
  199.  
  200.     t = vao(trsl(newtrans(name, const), px, py, pz), ax, ay, az, ox, oy, oz);
  201.  
  202.     if (prints_out > 1) /* print value of transform */
  203.         printrn(t, fpi);
  204.     return(t);
  205. }
  206.  
  207.  
  208.