📄 intfx.cpp
字号:
if (Ratio >= ATAN_TABLE_SIZE) Ratio = ATAN_TABLE_SIZE - 1; Angle = AtanTable[Ratio]; if (X >= 0) if (Y >= 0) if (AbsX > AbsY) Angle = Angle; else Angle = 64 - Angle; else if (AbsX > AbsY) Angle = 256 - Angle; else Angle = 192 + Angle; else if (Y >= 0) if (AbsX > AbsY) Angle = 128 - Angle; else Angle = 64 + Angle; else if (AbsX > AbsY) Angle = 128 + Angle; else Angle = 192 - Angle; /* reverse angles to match old feature extractor: Angle += PI */ Angle += 128; Angle &= 255; return (UINT8) Angle;}/*--------------------------------------------------------------------------*/int SaveFeature(INT_FEATURE_ARRAY FeatureArray, UINT16 FeatureNum, INT16 X, INT16 Y, UINT8 Theta) { INT_FEATURE Feature; if (FeatureNum >= MAX_NUM_INT_FEATURES) return FALSE; Feature = &(FeatureArray[FeatureNum]); X = X + 128; Y = Y + 128; if (X > 255) Feature->X = 255; else if (X < 0) Feature->X = 0; else Feature->X = X; if (Y > 255) Feature->Y = 255; else if (Y < 0) Feature->Y = 0; else Feature->Y = Y; Feature->Theta = Theta; return TRUE;}/*---------------------------------------------------------------------------*/UINT16 MySqrt(INT32 X, INT32 Y) { register UINT16 SqRoot; register UINT32 Square; register UINT16 BitLocation; register UINT32 Sum; if (X < 0) X = -X; if (Y < 0) Y = -Y; if (X > EvidenceMultMask) X = EvidenceMultMask; if (Y > EvidenceMultMask) Y = EvidenceMultMask; Sum = X * X + Y * Y; BitLocation = 1024; SqRoot = 0; do { Square = (SqRoot | BitLocation) * (SqRoot | BitLocation); if (Square <= Sum) SqRoot |= BitLocation; BitLocation >>= 1; } while (BitLocation); return SqRoot;}/*--------------------------------------------------------------------------*/UINT8 MySqrt2(UINT16 N, UINT32 I, UINT8 *Exp) { register INT8 k; register UINT32 N2; register UINT8 SqRoot; register UINT16 Square; register UINT8 BitLocation; register UINT16 Ratio; N2 = N * 41943; k = 9; while ((N2 & 0xc0000000) == 0) { N2 <<= 2; k += 1; } while ((I & 0xc0000000) == 0) { I <<= 2; k -= 1; } if (((N2 & 0x80000000) == 0) && ((I & 0x80000000) == 0)) { N2 <<= 1; I <<= 1; } N2 &= 0xffff0000; I >>= 14; Ratio = N2 / I; BitLocation = 128; SqRoot = 0; do { Square = (SqRoot | BitLocation) * (SqRoot | BitLocation); if (Square <= Ratio) SqRoot |= BitLocation; BitLocation >>= 1; } while (BitLocation); if (k < 0) { *Exp = 0; return 255; } else { *Exp = k; return SqRoot; }}/*-------------------------------------------------------------------------*/void ClipRadius(UINT8 *RxInv, UINT8 *RxExp, UINT8 *RyInv, UINT8 *RyExp) { register UINT8 AM, BM, AE, BE; register UINT8 BitN, LastCarry; int RxInvLarge, RyInvSmall; AM = RadiusGyrMinMan; AE = RadiusGyrMinExp; BM = *RxInv; BE = *RxExp; LastCarry = 1; while ((AM != 0) || (BM != 0)) { if (AE > BE) { BitN = LastCarry + (AM & 1) + 1; AM >>= 1; AE--; } else if (AE < BE) { BitN = LastCarry + (!(BM & 1)); BM >>= 1; BE--; } else { /* AE == BE */ BitN = LastCarry + (AM & 1) + (!(BM & 1)); AM >>= 1; BM >>= 1; AE--; BE--; } LastCarry = (BitN & 2) > 1; BitN = BitN & 1; } BitN = LastCarry + 1; LastCarry = (BitN & 2) > 1; BitN = BitN & 1; if (BitN == 1) { *RxInv = RadiusGyrMinMan; *RxExp = RadiusGyrMinExp; } AM = RadiusGyrMinMan; AE = RadiusGyrMinExp; BM = *RyInv; BE = *RyExp; LastCarry = 1; while ((AM != 0) || (BM != 0)) { if (AE > BE) { BitN = LastCarry + (AM & 1) + 1; AM >>= 1; AE--; } else if (AE < BE) { BitN = LastCarry + (!(BM & 1)); BM >>= 1; BE--; } else { /* AE == BE */ BitN = LastCarry + (AM & 1) + (!(BM & 1)); AM >>= 1; BM >>= 1; AE--; BE--; } LastCarry = (BitN & 2) > 1; BitN = BitN & 1; } BitN = LastCarry + 1; LastCarry = (BitN & 2) > 1; BitN = BitN & 1; if (BitN == 1) { *RyInv = RadiusGyrMinMan; *RyExp = RadiusGyrMinExp; } AM = RadiusGyrMaxMan; AE = RadiusGyrMaxExp; BM = *RxInv; BE = *RxExp; LastCarry = 1; while ((AM != 0) || (BM != 0)) { if (AE > BE) { BitN = LastCarry + (AM & 1) + 1; AM >>= 1; AE--; } else if (AE < BE) { BitN = LastCarry + (!(BM & 1)); BM >>= 1; BE--; } else { /* AE == BE */ BitN = LastCarry + (AM & 1) + (!(BM & 1)); AM >>= 1; BM >>= 1; AE--; BE--; } LastCarry = (BitN & 2) > 1; BitN = BitN & 1; } BitN = LastCarry + 1; LastCarry = (BitN & 2) > 1; BitN = BitN & 1; if (BitN == 1) RxInvLarge = 1; else RxInvLarge = 0; AM = *RyInv; AE = *RyExp; BM = RadiusGyrMaxMan; BE = RadiusGyrMaxExp; LastCarry = 1; while ((AM != 0) || (BM != 0)) { if (AE > BE) { BitN = LastCarry + (AM & 1) + 1; AM >>= 1; AE--; } else if (AE < BE) { BitN = LastCarry + (!(BM & 1)); BM >>= 1; BE--; } else { /* AE == BE */ BitN = LastCarry + (AM & 1) + (!(BM & 1)); AM >>= 1; BM >>= 1; AE--; BE--; } LastCarry = (BitN & 2) > 1; BitN = BitN & 1; } BitN = LastCarry + 1; LastCarry = (BitN & 2) > 1; BitN = BitN & 1; if (BitN == 1) RyInvSmall = 1; else RyInvSmall = 0; if (RxInvLarge && RyInvSmall) { *RyInv = RadiusGyrMaxMan; *RyExp = RadiusGyrMaxExp; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -