home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Virtual Reality Homebrewer's Handbook
/
vr.iso
/
vroom
/
fix_math.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1996-03-19
|
985b
|
39 lines
unit fix_math;
interface
{$L fixed}
function Int_to_Fixed(x : integer) : longint;
function Real_to_Fixed(x : real) : longint;
function Fixed_to_Real(x : longint) : real;
function FixedMul(M1, M2 : longint) : longint;
function FixedDiv(D1, D2 : longint) : longint;
procedure Init_CosTable;
procedure CosSin(TAngle : integer; var FixedCos, FixedSin : longint);
implementation
function Int_to_Fixed(x : integer) : longint;
var t : longint;
begin
t:=x;
Int_to_Fixed:=t shl 16;
end;
function Real_to_Fixed(x : real) : longint;
begin
Real_to_Fixed:=Trunc(x*65536.0+0.5);
end;
function Fixed_to_Real(x : longint) : real;
begin
Fixed_to_Real:=x/65536;
end;
function FixedMul(M1, M2 : longint) : longint; external;
function FixedDiv(D1, D2 : longint) : longint; external;
procedure Init_CosTable; external;
procedure CosSin(TAngle : integer; var FixedCos, FixedSin : longint); external;
end.