home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 501.lha / ProjectileMotion_v1.01 / src / gcalc.c < prev    next >
C/C++ Source or Header  |  1991-04-09  |  969b  |  74 lines

  1. /*
  2.  * Gcalc.c
  3.  * ~~~~~~~
  4.  * This is the calculation function to figure position
  5.  * of object (x,y) at time (time) it uses externaly 
  6.  * defined structure XY which is passed and def.
  7.  * from main module graph.c
  8.  * © Copyright 1991 Christian E. Hopps
  9. */
  10.  
  11.  
  12. #include <exec/types.h>
  13. #include <libraries/mathffp.h>
  14. #include "link:/graph/constants.h"
  15. float CalcGrav();
  16. extern struct MathBase *MathBase;
  17. extern struct MathTransBase *MathTransBase;
  18. extern struct Clip
  19.  
  20. {
  21.     short clipx1;
  22.     short clipy1;
  23.     short clipx2;
  24.     short clipy2;
  25. };
  26. extern struct XY
  27. {
  28.     float voy;
  29.     float vox;
  30.     float x;
  31.     float y;
  32.     short xp;
  33.     short yp;
  34.     BOOL clipped;
  35.     int scale;
  36.     struct Clip *clip;
  37. };
  38.  
  39.  
  40. void Gcalc(time, xy)
  41.  
  42. struct XY *xy;
  43. float time;
  44.  
  45. {
  46. float x,y,g,k;
  47. float vox,voy;
  48. vox = xy->vox;
  49. voy = xy->voy;
  50.  
  51. k = SPFlt(2);
  52. g = SPDiv(SPFlt(xy->scale),4.9);
  53. x = SPMul(vox,
  54.         time
  55.         );
  56.  
  57. y = SPSub(
  58.         
  59.         SPMul(
  60.                 g,
  61.                 SPPow(k,time)
  62.             ),
  63.         SPMul(
  64.             voy,
  65.             time
  66.             )  
  67.         );
  68.  
  69. xy->x = x; 
  70. xy->y = y;
  71. }
  72.  
  73.  
  74.