home *** CD-ROM | disk | FTP | other *** search
/ Virtual Reality Homebrewer's Handbook / vr.iso / vroom / fix_math.pas < prev    next >
Pascal/Delphi Source File  |  1996-03-19  |  985b  |  39 lines

  1. unit fix_math;
  2.  
  3. interface
  4.  
  5. {$L fixed}
  6.  
  7.      function Int_to_Fixed(x : integer) : longint;
  8.      function Real_to_Fixed(x : real) : longint;
  9.      function Fixed_to_Real(x : longint) : real;
  10.      function FixedMul(M1, M2 : longint) : longint;
  11.      function FixedDiv(D1, D2 : longint) : longint;
  12.      procedure Init_CosTable;
  13.      procedure CosSin(TAngle : integer; var FixedCos, FixedSin : longint);
  14.  
  15. implementation
  16.  
  17. function Int_to_Fixed(x : integer) : longint;
  18. var t : longint;
  19. begin
  20.      t:=x;
  21.      Int_to_Fixed:=t shl 16;
  22. end;
  23.  
  24. function Real_to_Fixed(x : real) : longint;
  25. begin
  26.      Real_to_Fixed:=Trunc(x*65536.0+0.5);
  27. end;
  28.  
  29. function Fixed_to_Real(x : longint) : real;
  30. begin
  31.      Fixed_to_Real:=x/65536;
  32. end;
  33.  
  34. function FixedMul(M1, M2 : longint) : longint; external;
  35. function FixedDiv(D1, D2 : longint) : longint; external;
  36. procedure Init_CosTable; external;
  37. procedure CosSin(TAngle : integer; var FixedCos, FixedSin : longint); external;
  38.  
  39. end.