home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / 2DLab / vector.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-14  |  1.6 KB  |  86 lines

  1. /* vector.h */
  2.  
  3. typedef struct pointstruct2D {
  4.     float px;
  5.     float py;
  6.     } POINT2D;
  7.  
  8. typedef struct rpointstruct2D {
  9.     float px;
  10.     float py;
  11.     float pw;
  12.     } RPOINT2D;
  13.  
  14. typedef struct pointstruct {
  15.     float px;
  16.     float py;
  17.     float pz;
  18.     } POINT;
  19.  
  20. typedef struct rpointstruct {
  21.     float px;
  22.     float py;
  23.     float pz;
  24.     float pw;
  25.     } RPOINT;
  26.  
  27. typedef struct vecstruct {
  28.     float dx;
  29.     float dy;
  30.     float dz;
  31.     } VECTOR;
  32.  
  33. /* 1/27/89 -- added DOUBLE structs seth */
  34.  
  35. typedef struct dpointstruct2D {
  36.     double px;
  37.     double py;
  38.     } DPOINT2D;
  39.  
  40. typedef struct rdpointstruct2D {
  41.     double px;
  42.     double py;
  43.     double pw;
  44.     } DRPOINT2D;
  45.  
  46. typedef struct dpointstruct {
  47.     double px;
  48.     double py;
  49.     double pz;
  50.     } DPOINT;
  51.  
  52. typedef struct drpointstruct {
  53.     double px;
  54.     double py;
  55.     double pz;
  56.     double pw;
  57.     } DRPOINT;
  58.  
  59. typedef struct dvecstruct {
  60.     double dx;
  61.     double dy;
  62.     double dz;
  63.     } DVECTOR;
  64.  
  65. float
  66. mag    (/*a*/),            /*    ||a||    */
  67. recip_mag (/*a*/),            /*    1.0/||a||*/
  68. dot    (/*a, b*/);            /*  a . b    */
  69.  
  70. VECTOR
  71. *vlerp    (/*p, a, b, t*/),        /*  v = ta + (a-t)b */
  72. *norm    (/*a*/),            /*  a /= ||a||  */
  73. *assign    (/*a, b*/),            /*    a = b        */
  74. *vscale    (/*a, t*/),            /*    a *= t        */
  75. *diff    (/*a, b, c*/),            /*    a = b - c   */
  76. *cross    (/*a, b, c*/),            /*    a = b x c   */
  77. *lcross    (/*a, b, c*/);            /*    a = -b x c  */
  78.  
  79. POINT
  80. *plerp    (/*p, a, b, t*/),        /* p = ta + (a-t)b */
  81. *midpoint (/*a, b, c*/),        /*    a = (b+c)/2 */
  82. *pminusv (/*a, p, v*/),            /*    a = p - v   */
  83. *pplusv  (/*a, p, v*/),            /*    a = p + v   */
  84. *pminustv (/*a, p, t, v*/),        /*    a = p - tv  */
  85. *pplustv (/*a, p, t, v*/);        /*    a = p + tv  */
  86.