Go to the source code of this file.
Defines | |
#define | retfixed16 fixed16 |
Functions | |
fixed16 | Fixed16Mul (fixed16, fixed16) |
signed multiplication | |
fixed16 | Fixed16Div (fixed16, fixed16) |
signed division | |
double | Fixed16ToDouble (fixed16) |
General type conversion. | |
fixed16 | DoubleToFixed16 (double) |
General type conversion. | |
fixed16 | Fixed16Sin (fixed16) |
General trigonometry General trigonometry. | |
fixed16 | Fixed16Cos (fixed16) |
INT32 | MatrixCalc (fixed16, INT32, fixed16, INT32) |
Matrix multiply primitive done using intermediate 64-bit results so accuracy is maintained. Special cases are when fix1 or fix2 are 0.0 or 1.0 as multiplications may be avoided. Note that the result is rounded to the nearest integer. | |
INT32 | LongMulFixed16 (INT32, fixed16) |
Method of multiplying a INT32 by a fixed point number keeping as much accuracy as possible. | |
INT32 | LongDivFixed16 (INT32 arg, fixed16) |
Method of dividing an INT32 by a fixed point number keeping as much accuracy as possible. | |
INT32 | MPtoPixel (INT32 arg, fixed16) |
Method of dividing a INT32 by a fixed point number keeping as much accuracy as possible. This version will Round any fractional result to the NEAREST whole value. It is used for scaling Millipoints to Whole Pixels. Assumptions:Fix is +ve. | |
INT32 | MPtoOS256 (INT32 arg, fixed16) |
Method of dividing a INT32 by a fixed point number keeping as much accuracy as possible. This version will convert the MP value to 256ths of a Pixel. | |
Variables | |
fixed16 | InternalDiv32by32 (INT32, INT32) |
|
|
|
General type conversion.
Definition at line 234 of file fixed.cpp. 00235 { 00236 fixed16 result ; 00237 #if 0//defined(_M_IX86) 00238 // 00239 // This avoids the slow fix operation. Add a large number so that 00240 // the double always has the same exponent and the mantissa becomes, 00241 // in affect, a fixed point value with the value we want in the 00242 // bottom 32 bits. 00243 // 00244 // Note that we are relying on the compiler to convert this to 00245 // efficient code. 00246 // 00247 // TODO: Test! 00248 // 00249 static const double fFix = (XLONG)3<<(DBL_MANT_DIG-16-2); 00250 double F = arg+fFix; 00251 result.all = (INT32&)F ; 00252 #else 00253 result.all = INT32(arg*(1<<16)) ; 00254 #endif 00255 return result ; 00256 }
|
|
Definition at line 298 of file fixed.cpp. 00299 { 00300 return DoubleToFixed16( cos( double(2.6631610900792382460383465095346e-7) * arg.MakeDouble() ) ); 00301 }
|
|
signed division
Definition at line 147 of file fixed.cpp. 00148 { 00149 fixed16 result ; 00150 // result.all = MulDiv(a.all,1<<16,b.all) ; 00151 result.all = INT32(((xlong)a.all<<16)/b.all) ; 00152 return result ; 00153 }
|
|
signed multiplication
Definition at line 122 of file fixed.cpp. 00123 { 00124 fixed16 result ; 00125 // result.all = INT32(Int32x32To64(a.all,b.all)+0x8000>>16) ; 00126 result.all = INT32(((xlong)a.all*b.all+0x8000) >> 16) ; 00127 return result ; 00128 }
|
|
General trigonometry General trigonometry.
Definition at line 293 of file fixed.cpp. 00294 { 00295 return DoubleToFixed16( sin( double(2.6631610900792382460383465095346e-7) * arg.MakeDouble() ) ); 00296 }
|
|
General type conversion.
Definition at line 212 of file fixed.cpp. 00213 { 00214 return (double)a.all/(1<<16) ; 00215 }
|
|
Method of dividing an INT32 by a fixed point number keeping as much accuracy as possible.
Definition at line 367 of file fixed.cpp.
|
|
Method of multiplying a INT32 by a fixed point number keeping as much accuracy as possible.
Definition at line 346 of file fixed.cpp.
|
|
Matrix multiply primitive done using intermediate 64-bit results so accuracy is maintained. Special cases are when fix1 or fix2 are 0.0 or 1.0 as multiplications may be avoided. Note that the result is rounded to the nearest integer.
Definition at line 323 of file fixed.cpp.
|
|
Method of dividing a INT32 by a fixed point number keeping as much accuracy as possible. This version will convert the MP value to 256ths of a Pixel.
Definition at line 425 of file fixed.cpp.
|
|
Method of dividing a INT32 by a fixed point number keeping as much accuracy as possible. This version will Round any fractional result to the NEAREST whole value. It is used for scaling Millipoints to Whole Pixels. Assumptions:Fix is +ve.
Definition at line 392 of file fixed.cpp. 00393 { 00394 if ( arg<0 ) 00395 return INT32((((xlong)arg<<16)-(fix.all>>1))/fix.all) ; 00396 else 00397 return INT32((((xlong)arg<<16)+(fix.all>>1))/fix.all) ; 00398 00399 // Gavin says (07/03/2006) the following would be more accurate so long as 00400 // we could guarantee that fix.all<<1 does not overflow: 00401 // if ( arg<0 ) 00402 // return INT32((((xlong)arg<<17)-fix.all))/(fix.all<<1)) ; 00403 // else 00404 // return INT32((((xlong)arg<<17)+fix.all))/(fix.all<<1)) ; 00405 }
|
|
|