80 |
80 |
81 function cstr(const z: hwFloat): shortstring; // Returns a shortstring representations of the hwFloat. |
81 function cstr(const z: hwFloat): shortstring; // Returns a shortstring representations of the hwFloat. |
82 function hwRound(const t: hwFloat): LongInt; inline; // Does NOT really round but returns the integer representation of the hwFloat without fractional digits. (-_0_9 -> -0, _1_5 -> _1) |
82 function hwRound(const t: hwFloat): LongInt; inline; // Does NOT really round but returns the integer representation of the hwFloat without fractional digits. (-_0_9 -> -0, _1_5 -> _1) |
83 function hwAbs(const t: hwFloat): hwFloat; inline; // Returns the value of t with positive sign. |
83 function hwAbs(const t: hwFloat): hwFloat; inline; // Returns the value of t with positive sign. |
84 function hwSqr(const t: hwFloat): hwFloat; inline; // Returns the square value of parameter t. |
84 function hwSqr(const t: hwFloat): hwFloat; inline; // Returns the square value of parameter t. |
|
85 function hwPow(const t: hwFloat; p: LongWord): hwFloat; inline; // Returns the power of the value |
85 function hwSqrt(const t: hwFloat): hwFloat; inline; // Returns the the positive square root of parameter t. |
86 function hwSqrt(const t: hwFloat): hwFloat; inline; // Returns the the positive square root of parameter t. |
86 function Distance(const dx, dy: hwFloat): hwFloat; // Returns the distance between two points in 2-dimensional space, of which the parameters are the horizontal and vertical distance. |
87 function Distance(const dx, dy: hwFloat): hwFloat; // Returns the distance between two points in 2-dimensional space, of which the parameters are the horizontal and vertical distance. |
87 function DistanceI(const dx, dy: LongInt): hwFloat; // Same as above for integer parameters. |
88 function DistanceI(const dx, dy: LongInt): hwFloat; // Same as above for integer parameters. |
88 function AngleSin(const Angle: Longword): hwFloat; |
89 function AngleSin(const Angle: Longword): hwFloat; |
89 function AngleCos(const Angle: Longword): hwFloat; |
90 function AngleCos(const Angle: Longword): hwFloat; |
146 _1: hwFloat = (isNegative: false; QWordValue: 4294967296); |
147 _1: hwFloat = (isNegative: false; QWordValue: 4294967296); |
147 _1_5: hwFloat = (isNegative: false; QWordValue: 4294967296 * 3 div 2); |
148 _1_5: hwFloat = (isNegative: false; QWordValue: 4294967296 * 3 div 2); |
148 _1_9: hwFloat = (isNegative: false; QWordValue: 8160437862); |
149 _1_9: hwFloat = (isNegative: false; QWordValue: 8160437862); |
149 _2: hwFloat = (isNegative: false; QWordValue: 4294967296 * 2); |
150 _2: hwFloat = (isNegative: false; QWordValue: 4294967296 * 2); |
150 _3: hwFloat = (isNegative: false; QWordValue: 4294967296 * 3); |
151 _3: hwFloat = (isNegative: false; QWordValue: 4294967296 * 3); |
|
152 _PI: hwFloat = (isNegative: false; QWordValue: 13493037704); |
151 _4: hwFloat = (isNegative: false; QWordValue: 4294967296 * 4); |
153 _4: hwFloat = (isNegative: false; QWordValue: 4294967296 * 4); |
152 _4_5: hwFloat = (isNegative: false; QWordValue: 4294967296 * 9 div 2); |
154 _4_5: hwFloat = (isNegative: false; QWordValue: 4294967296 * 9 div 2); |
153 _5: hwFloat = (isNegative: false; QWordValue: 4294967296 * 5); |
155 _5: hwFloat = (isNegative: false; QWordValue: 4294967296 * 5); |
154 _6: hwFloat = (isNegative: false; QWordValue: 4294967296 * 6); |
156 _6: hwFloat = (isNegative: false; QWordValue: 4294967296 * 6); |
155 _10: hwFloat = (isNegative: false; QWordValue: 4294967296 * 10); |
157 _10: hwFloat = (isNegative: false; QWordValue: 4294967296 * 10); |
353 begin |
355 begin |
354 hwSqr.isNegative:= false; |
356 hwSqr.isNegative:= false; |
355 hwSqr.QWordValue:= ((QWord(t.Round) * t.Round) shl 32) + QWord(t.Round) * t.Frac * 2 + ((QWord(t.Frac) * t.Frac) shr 32); |
357 hwSqr.QWordValue:= ((QWord(t.Round) * t.Round) shl 32) + QWord(t.Round) * t.Frac * 2 + ((QWord(t.Frac) * t.Frac) shr 32); |
356 end; |
358 end; |
357 |
359 |
|
360 function hwPow(const t: hwFloat;p: LongWord): hwFloat; |
|
361 begin |
|
362 hwPow:= t; |
|
363 if p mod 2 = 0 then hwPow.isNegative:= t.isNegative; |
|
364 |
|
365 while p > 0 do |
|
366 begin |
|
367 hwPow.QWordValue:= QWord(hwPow.Round) * t.Frac + QWord(hwPow.Frac) * t.Round + ((QWord(hwPow.Frac) * t.Frac) shr 32); |
|
368 dec(p) |
|
369 end |
|
370 end; |
|
371 |
358 function hwSqrt(const t: hwFloat): hwFloat; |
372 function hwSqrt(const t: hwFloat): hwFloat; |
359 var l, r: QWord; |
373 var l, r: QWord; |
360 c: hwFloat; |
374 c: hwFloat; |
361 begin |
375 begin |
362 hwSqrt.isNegative:= false; |
376 hwSqrt.isNegative:= false; |