#include "camtypes.h"
Go to the source code of this file.
Functions | |
fixed16 | Fixed16Mul (fixed16 a, fixed16 b) |
signed multiplication | |
fixed16 | Fixed16Div (fixed16 a, fixed16 b) |
signed division | |
fixed16 | InternalDiv32by32 (INT32 a, INT32 b) |
Obtain a fixed-point representation of the ratio between two signed numbers. | |
double | Fixed16ToDouble (fixed16 a) |
General type conversion. | |
fixed16 | DoubleToFixed16 (double arg) |
General type conversion. | |
fixed16 | Fixed16Sin (fixed16 arg) |
General trigonometry General trigonometry. | |
fixed16 | Fixed16Cos (fixed16 arg) |
INT32 | MatrixCalc (fixed16 fix1, INT32 l1, fixed16 fix2, INT32 l2) |
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 arg, fixed16 fix) |
Method of multiplying a INT32 by a fixed point number keeping as much accuracy as possible. | |
INT32 | LongDivFixed16 (INT32 arg, fixed16 fix) |
Method of dividing an INT32 by a fixed point number keeping as much accuracy as possible. | |
INT32 | MPtoPixel (INT32 arg, fixed16 fix) |
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 fix) |
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. |
|
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 }
|
|
Obtain a fixed-point representation of the ratio between two signed numbers.
This is done by multiplying arg1 by 65536, then doing a 64-bit/32-bit division Curiously enough, this function is 100% the same as Fixed16Div. When you think about it, its not really that curious as both args are 65536 times bigger than the FIXED16 versions, and x/y is identical to x*65536/y*65536. Definition at line 184 of file fixed.cpp. 00185 { 00186 fixed16 result ; 00187 // result.all = MulDiv(a.all,1<<16,b.all) ; 00188 result.all = INT32( ( (xlong)a << 16 ) / b ); 00189 return result ; 00190 }
|
|
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 }
|