diff --git a/README.md b/README.md index 4eeb00a25019bd2fdb1cd0588ae79684d9377ca4..352b0d08d3dba1e9fe8281d7ce27f8cfc8793d97 100644 --- a/README.md +++ b/README.md @@ -196,7 +196,7 @@ ((fixed32)(((fa>>8)*(fb>>8))>>16)) ~~~ 1. Same as above, the same fuction as fa*fb>>32, first multiply fa/2^8, fb/2^8, and divide the remaining 2^16 -- a. div +- b. div - fx32_div ~~~ (fixed32)( (((fixed64)(fa) << FX32_QNUM) /(fb))) @@ -211,4 +211,45 @@ ~~~ ((((fa)<<24)/(fb))<<8) ~~~ - 1. same as above, it has the same fuction as (fa<<32)/fb. First, fa is multiplied by 2^24, divided by fb, and then the remaining 2^8 is multiplied. \ No newline at end of file + 1. same as above, it has the same fuction as (fa<<32)/fb. First, fa is multiplied by 2^24, divided by fb, and then the remaining 2^8 is multiplied. +- c. sin + - sin table + ~~~ + const fixed32 fx32_SinTable[92] = + { + 0,1143,2287,3429,4571,5711,6850,7986,9120,10252,11380,12504,13625,14742,15854,16961,18064,19160,20251,21336,22414,23486,24550,25606,26655, 27696,28729,29752, + 30767,31772,32768,33753,34728,35693,36647,37589,38521,39440,40347,41243,42125,42995,43852,44695,45525,46340,47142, 47929,48702,49460,50203,50931,51643,52339, + 53019,53683,54331,54963,55577,56175,56755,57319,57864,58393,58903,59395,59870,60326,60763, 61183,61583,61965,62328,62672,62997,63302,63589,63856,64103,64331, + 64540,64729,64898,65047,65176,65286,65376,65446,65496,65526,65536,65526 + }; + ~~~ + - sin fuction + ~~~ + fixed32 fx32_sind(fixed32 fa) +{ + int sign = 1; + fixed32 ret0, diff; + int idx; + if ( fa < 0 ) + { + sign = -1; + fa *= -1; + } + fa = fa % FX32_360; + if ( fa >= FX32_180 ) + { + sign *= -1; + fa -= FX32_180; + } + if ( fa > FX32_90 ) + fa = FX32_180 - fa; + idx = fa>>16; + ret0 = fx32_SinTable[idx]; + diff = fx32_SinTable[idx+1]-ret0; + return ( sign *( ret0 + ((diff*(fa&0xFFFF))>>16) )); +} + ~~~ + + + +