41 |
40 |
42 function int2hwFloat (const i: LongInt) : hwFloat; inline; |
41 function int2hwFloat (const i: LongInt) : hwFloat; inline; |
43 |
42 |
44 operator + (const z1, z2: hwFloat) z : hwFloat; inline; |
43 operator + (const z1, z2: hwFloat) z : hwFloat; inline; |
45 operator - (const z1, z2: hwFloat) z : hwFloat; inline; |
44 operator - (const z1, z2: hwFloat) z : hwFloat; inline; |
46 operator - (const z1: hwFloat) z : hwFloat; |
45 operator - (const z1: hwFloat) z : hwFloat; inline; |
47 |
46 |
48 operator * (const z1, z2: hwFloat) z : hwFloat; |
47 operator * (const z1, z2: hwFloat) z : hwFloat; inline; |
49 operator * (const z1: hwFloat; const z2: LongInt) z : hwFloat; inline; |
48 operator * (const z1: hwFloat; const z2: LongInt) z : hwFloat; inline; |
50 operator / (const z1: hwFloat; z2: hwFloat) z : hwFloat; |
49 operator / (const z1: hwFloat; z2: hwFloat) z : hwFloat; inline; |
51 operator / (const z1: hwFloat; const z2: LongInt) z : hwFloat; |
50 operator / (const z1: hwFloat; const z2: LongInt) z : hwFloat; inline; |
52 |
51 |
53 operator < (const z1, z2: hwFloat) b : boolean; |
52 operator < (const z1, z2: hwFloat) b : boolean; inline; |
54 operator > (const z1, z2: hwFloat) b : boolean; |
53 operator > (const z1, z2: hwFloat) b : boolean; inline; |
55 |
54 |
56 function cstr(const z: hwFloat): shortstring; |
55 function cstr(const z: hwFloat): shortstring; |
57 function hwRound(const t: hwFloat): LongInt; |
56 function hwRound(const t: hwFloat): LongInt; inline; |
58 function hwAbs(const t: hwFloat): hwFloat; |
57 function hwAbs(const t: hwFloat): hwFloat; inline; |
59 function hwSqr(const t: hwFloat): hwFloat; inline; |
58 function hwSqr(const t: hwFloat): hwFloat; inline; |
60 function hwSqrt(const t: hwFloat): hwFloat; inline; |
59 function hwSqrt(const t: hwFloat): hwFloat; inline; |
61 function Distance(const dx, dy: hwFloat): hwFloat; |
60 function Distance(const dx, dy: hwFloat): hwFloat; |
62 function DistanceI(const dx, dy: LongInt): hwFloat; |
61 function DistanceI(const dx, dy: LongInt): hwFloat; |
63 function AngleSin(const Angle: Longword): hwFloat; |
62 function AngleSin(const Angle: Longword): hwFloat; |
64 function AngleCos(const Angle: Longword): hwFloat; |
63 function AngleCos(const Angle: Longword): hwFloat; |
65 function SignAs(const num, signum: hwFloat): hwFloat; |
64 function SignAs(const num, signum: hwFloat): hwFloat; inline; |
66 |
65 |
67 {$IFDEF FPC} |
66 {$IFDEF FPC} |
68 {$J-} |
67 {$J-} |
69 {$ENDIF} |
68 {$ENDIF} |
70 {$WARNINGS OFF} |
69 {$WARNINGS OFF} |
346 {$INCLUDE "SinTable.inc"} |
345 {$INCLUDE "SinTable.inc"} |
347 |
346 |
348 function AngleSin(const Angle: Longword): hwFloat; |
347 function AngleSin(const Angle: Longword): hwFloat; |
349 begin |
348 begin |
350 {$IFDEF DEBUGFILE} |
349 {$IFDEF DEBUGFILE} |
351 TryDo((Angle >= 0) and (Angle <= 2048), 'Sin param exceeds limits', true); |
350 //TryDo((Angle >= 0) and (Angle <= 2048), 'Sin param exceeds limits', true); |
352 {$ENDIF} |
351 {$ENDIF} |
353 AngleSin.isNegative:= false; |
352 AngleSin.isNegative:= false; |
354 if Angle < 1024 then AngleSin.QWordValue:= SinTable[Angle] |
353 if Angle < 1024 then AngleSin.QWordValue:= SinTable[Angle] |
355 else AngleSin.QWordValue:= SinTable[2048 - Angle] |
354 else AngleSin.QWordValue:= SinTable[2048 - Angle] |
356 end; |
355 end; |
357 |
356 |
358 function AngleCos(const Angle: Longword): hwFloat; |
357 function AngleCos(const Angle: Longword): hwFloat; |
359 begin |
358 begin |
360 {$IFDEF DEBUGFILE} |
359 {$IFDEF DEBUGFILE} |
361 TryDo((Angle >= 0) and (Angle <= 2048), 'Cos param exceeds limits', true); |
360 //TryDo((Angle >= 0) and (Angle <= 2048), 'Cos param exceeds limits', true); |
362 {$ENDIF} |
361 {$ENDIF} |
363 AngleCos.isNegative:= Angle > 1024; |
362 AngleCos.isNegative:= Angle > 1024; |
364 if Angle < 1024 then AngleCos.QWordValue:= SinTable[1024 - Angle] |
363 if Angle < 1024 then AngleCos.QWordValue:= SinTable[1024 - Angle] |
365 else AngleCos.QWordValue:= SinTable[Angle - 1024] |
364 else AngleCos.QWordValue:= SinTable[Angle - 1024] |
366 end; |
365 end; |