T
Hallo!
Hier nun meine Lösung:
#include "atantable.h"
float atanfield1[] = {0,0.001,0.002,0.003,0.004,0.005,0.0059999,0.0069999,0.0079998,0.0089998,0.0099997,0.011,0.011999,0.012999,0.013999,0.014999,0.015999,0.016998,0.017998,0.018998,0.019997,0.020997,0.021996,0.022996,0.023995,0.024995,0.025994,0.026993,0.027993,0.028992,0.029991,0.03099,0.031989,0.032988,0.033987,0.034986,0.035984,0.036983,0.037982,0.03898,0.039979,0.040977,0.041975,0.042974,0.043972,0.04497,0.045968,0.046965,0.047963,0.048961,0.049958,0.050956,0.051953,0.05295,0.053948,0.054945,0.055942,0.056938,0.057935,0.058932,0.059928,0.060925,0.061921,0.062917,0.063913,0.064909,0.065904,0.0669,0.067895,0.068891,0.069886,0.070881,0.071876,0.072871,0.073865,0.07486,0.075854,0.076848,0.077842,0.078836,0.07983,0.080824,0.081817,0.08281,0.083803,0.084796,0.085789,0.086781,0.087774,0.088766,0.089758,0.09075,0.091742,0.092733,0.093725,0.094716,0.095707,0.096697,0.097688,0.098678,0.099669,0.10066,0.10165,0.10264,0.10363,0.10462,0.10561,0.10659,0.10758,0.10857,0.10956,0.11055,0.11154,0.11252,0.11351,0.1145,0.11548,0.11647,0.11746,0.11844,0.11943,0.12041,0.1214,0.12239,0.12337,0.12435,0.12534,0.12632,0.12731,0.12829,0.12928,0.13026,0.13124,0.13222,0.13321,0.13419,0.13517,0.13615,0.13713,0.13812,0.1391,0.14008,0.14106,0.14204,0.14302,0.144,0.14498,0.14595,0.14693,0.14791,0.14889,0.14987,0.15085,0.15182,0.1528,0.15378,0.15475,0.15573,0.1567,0.15768,0.15866,0.15963,0.1606,0.16158,0.16255,0.16353,0.1645,0.16547,0.16645,0.16742,0.16839,0.16936,0.17033,0.1713,0.17228,0.17325,0.17422,0.17519,0.17616,0.17712,0.17809,0.17906,0.18003,0.181,0.18196,0.18293,0.1839,0.18486,0.18583,0.1868,0.18776,0.18873,0.18969,0.19066,0.19162,0.19258,0.19355,0.19451,0.19547,0.19643,0.1974,0.19836,0.19932,0.20028,0.20124,0.2022,0.20316,0.20412,0.20508,0.20603,0.20699,0.20795,0.20891,0.20986,0.21082,0.21178,0.21273,0.21369,0.21464,0.2156,0.21655,0.2175,0.21846,0.21941,0.22036,0.22131,0.22227,0.22322,0.22417,0.22512,0.22607,0.22702,0.22797,0.22892,0.22986,0.23081,0.23176,0.23271,0.23365,0.2346,0.23554,0.23649,0.23744,0.23838,0.23932,0.24027,0.24121,0.24215,0.2431,0.24404,0.24498,0.24592,0.24686,0.2478,0.24874,0.24968,0.25062,0.25156,0.25249,0.25343,0.25437,0.2553,0.25624,0.25718,0.25811,0.25905,0.25998,0.26091,0.26185,0.26278,0.26371,0.26464,0.26558,0.26651,0.26744,0.26837,0.2693,0.27022,0.27115,0.27208,0.27301,0.27394,0.27486,0.27579,0.27671,0.27764,0.27856,0.27949,0.28041,0.28133,0.28226,0.28318,0.2841,0.28502,0.28594,0.28686,0.28778,0.2887,0.28962,0.29054,0.29146,0.29237,0.29329,0.29421,0.29512,0.29604,0.29695,0.29787,0.29878,0.29969,0.30061,0.30152,0.30243,0.30334,0.30425,0.30516,0.30607,0.30698,0.30789,0.3088,0.3097,0.31061,0.31152,0.31242,0.31333,0.31423,0.31514,0.31604,0.31694,0.31785,0.31875,0.31965,0.32055,0.32145,0.32235,0.32325,0.32415,0.32505,0.32594,0.32684,0.32774,0.32863,0.32953,0.33043,0.33132,0.33221,0.33311,0.334,0.33489,0.33578,0.33667,0.33757,0.33846,0.33934,0.34023,0.34112,0.34201,0.3429,0.34378,0.34467,0.34556,0.34644,0.34732,0.34821,0.34909,0.34997,0.35086,0.35174,0.35262,0.3535,0.35438,0.35526,0.35614,0.35702,0.35789,0.35877,0.35965,0.36052,0.3614,0.36227,0.36315,0.36402,0.36489,0.36577,0.36664,0.36751,0.36838,0.36925,0.37012,0.37099,0.37186,0.37272,0.37359,0.37446,0.37532,0.37619,0.37705,0.37792,0.37878,0.37964,0.38051,0.38137,0.38223,0.38309,0.38395,0.38481,0.38567,0.38653,0.38738,0.38824,0.3891,0.38995,0.39081,0.39166,0.39252,0.39337,0.39422,0.39508,0.39593,0.39678,0.39763,0.39848,0.39933,0.40018,0.40102,0.40187,0.40272,0.40356,0.40441,0.40525,0.4061,0.40694,0.40778,0.40863,0.40947,0.41031,0.41115,0.41199,0.41283,0.41367,0.41451,0.41534,0.41618,0.41702,0.41785,0.41869,0.41952,0.42036,0.42119,0.42202,0.42285,0.42369,0.42452,0.42535,0.42618,0.427,0.42783,0.42866,0.42949,0.43031,0.43114,0.43196,0.43279,0.43361,0.43444,0.43526,0.43608,0.4369,0.43772,0.43854,0.43936,0.44018,0.441,0.44182,0.44263,0.44345,0.44426,0.44508,0.44589,0.44671,0.44752,0.44833,0.44914,0.44996,0.45077,0.45158,0.45239,0.45319,0.454,0.45481,0.45562,0.45642,0.45723,0.45803,0.45884,0.45964,0.46044,0.46124,0.46205,0.46285,0.46365,0.46445,0.46525,0.46604,0.46684,0.46764,0.46844,0.46923,0.47003,0.47082,0.47162,0.47241,0.4732,0.47399,0.47478,0.47558,0.47637,0.47715,0.47794,0.47873,0.47952,0.48031,0.48109,0.48188,0.48266,0.48345,0.48423,0.48501,0.4858,0.48658,0.48736,0.48814,0.48892,0.4897,0.49048,0.49125,0.49203,0.49281,0.49358,0.49436,0.49513,0.49591,0.49668,0.49745,0.49823,0.499,0.49977,0.50054,0.50131,0.50208,0.50284,0.50361,0.50438,0.50514,0.50591,0.50667,0.50744,0.5082,0.50896,0.50973,0.51049,0.51125,0.51201,0.51277,0.51353,0.51429,0.51504,0.5158,0.51656,0.51731,0.51807,0.51882,0.51958,0.52033,0.52108,0.52183,0.52259,0.52334,0.52409,0.52484,0.52558,0.52633,0.52708,0.52783,0.52857,0.52932,0.53006,0.53081,0.53155,0.53229,0.53303,0.53378,0.53452,0.53526,0.536,0.53673,0.53747,0.53821,0.53895,0.53968,0.54042,0.54115,0.54189,0.54262,0.54336,0.54409,0.54482,0.54555,0.54628,0.54701,0.54774,0.54847,0.5492,0.54992,0.55065,0.55138,0.5521,0.55283,0.55355,0.55427,0.555,0.55572,0.55644,0.55716,0.55788,0.5586,0.55932,0.56004,0.56075,0.56147,0.56219,0.5629,0.56362,0.56433,0.56505,0.56576,0.56647,0.56718,0.56789,0.5686,0.56931,0.57002,0.57073,0.57144,0.57215,0.57285,0.57356,0.57426,0.57497,0.57567,0.57638,0.57708,0.57778,0.57848,0.57918,0.57988,0.58058,0.58128,0.58198,0.58268,0.58337,0.58407,0.58476,0.58546,0.58615,0.58685,0.58754,0.58823,0.58893,0.58962,0.59031,0.591,0.59169,0.59237,0.59306,0.59375,0.59444,0.59512,0.59581,0.59649,0.59718,0.59786,0.59854,0.59923,0.59991,0.60059,0.60127,0.60195,0.60263,0.60331,0.60398,0.60466,0.60534,0.60601,0.60669,0.60736,0.60804,0.60871,0.60938,0.61005,0.61073,0.6114,0.61207,0.61274,0.61341,0.61407,0.61474,0.61541,0.61607,0.61674,0.61741,0.61807,0.61873,0.6194,0.62006,0.62072,0.62138,0.62204,0.6227,0.62336,0.62402,0.62468,0.62534,0.626,0.62665,0.62731,0.62796,0.62862,0.62927,0.62993,0.63058,0.63123,0.63188,0.63253,0.63318,0.63383,0.63448,0.63513,0.63578,0.63642,0.63707,0.63772,0.63836,0.63901,0.63965,0.64029,0.64094,0.64158,0.64222,0.64286,0.6435,0.64414,0.64478,0.64542,0.64606,0.64669,0.64733,0.64797,0.6486,0.64924,0.64987,0.6505,0.65114,0.65177,0.6524,0.65303,0.65366,0.65429,0.65492,0.65555,0.65618,0.65681,0.65743,0.65806,0.65869,0.65931,0.65993,0.66056,0.66118,0.6618,0.66243,0.66305,0.66367,0.66429,0.66491,0.66553,0.66615,0.66676,0.66738,0.668,0.66861,0.66923,0.66984,0.67046,0.67107,0.67168,0.6723,0.67291,0.67352,0.67413,0.67474,0.67535,0.67596,0.67657,0.67718,0.67778,0.67839,0.67899,0.6796,0.6802,0.68081,0.68141,0.68202,0.68262,0.68322,0.68382,0.68442,0.68502,0.68562,0.68622,0.68682,0.68742,0.68801,0.68861,0.6892,0.6898,0.69039,0.69099,0.69158,0.69218,0.69277,0.69336,0.69395,0.69454,0.69513,0.69572,0.69631,0.6969,0.69749,0.69807,0.69866,0.69925,0.69983,0.70042,0.701,0.70158,0.70217,0.70275,0.70333,0.70391,0.70449,0.70507,0.70565,0.70623,0.70681,0.70739,0.70797,0.70854,0.70912,0.7097,0.71027,0.71085,0.71142,0.71199,0.71257,0.71314,0.71371,0.71428,0.71485,0.71542,0.71599,0.71656,0.71713,0.7177,0.71826,0.71883,0.7194,0.71996,0.72053,0.72109,0.72165,0.72222,0.72278,0.72334,0.7239,0.72447,0.72503,0.72559,0.72615,0.7267,0.72726,0.72782,0.72838,0.72893,0.72949,0.73005,0.7306,0.73116,0.73171,0.73226,0.73282,0.73337,0.73392,0.73447,0.73502,0.73557,0.73612,0.73667,0.73722,0.73777,0.73831,0.73886,0.73941,0.73995,0.7405,0.74104,0.74158,0.74213,0.74267,0.74321,0.74376,0.7443,0.74484,0.74538,0.74592,0.74646,0.747,0.74753,0.74807,0.74861,0.74914,0.74968,0.75022,0.75075,0.75129,0.75182,0.75235,0.75289,0.75342,0.75395,0.75448,0.75501,0.75554,0.75607,0.7566,0.75713,0.75766,0.75818,0.75871,0.75924,0.75976,0.76029,0.76081,0.76134,0.76186,0.76238,0.76291,0.76343,0.76395,0.76447,0.76499,0.76551,0.76603,0.76655,0.76707,0.76759,0.76811,0.76862,0.76914,0.76966,0.77017,0.77069,0.7712,0.77171,0.77223,0.77274,0.77325,0.77376,0.77428,0.77479,0.7753,0.77581,0.77632,0.77683,0.77733,0.77784,0.77835,0.77886,0.77936,0.77987,0.78037,0.78088,0.78138,0.78189,0.78239,0.78289,0.78339,0.7839,0.7844,0.7849,0.7854};
float atan_1(int y,int x)
{
int index;
int vorz;
float erg;
vorz = 1;
if (((x < 0) && (y < 0)) || ((x > 0) && (y > 0))) {vorz = 0;}
else x = -x;
/*atan of y/x */
index =(int) (((y*10000)/x+5)/10); //+5 for rounding
//printf("%s%d%s%d%s%d\n","index=",index," x= ",x," y= ",y);
erg = atanfield1[index];
if (vorz == 0 ) return erg;
else return -erg;
}
float atan_2(int y, int x) {
float result;
if(abs(x) > abs(y))
result = atan_1(y,x);
else
{
result = atan_1(x,y);
if(result < 0)
result = -M_PI/2 - result;
else
result = M_PI/2 - result;
}
if (x < 0)
if(y < 0)
result = result - M_PI;
else
result = result + M_PI;
return result;
}
und das h file dazu:
#if !defined __ATAN_TABLE__
#define __ATAN_TABLE__
#define M_PI 3.14159265f
float atan_1(int y,int x);
float atan_2(int y, int x);
#endif
ich hoffe das es passt, wenn nicht bitte melden!
Lg THE_ONE