Ticket #378: calculate_scale.2.diff

File calculate_scale.2.diff, 1.4 KB (added by Odlg, 12 years ago)

Patch to lookup scale instead of using fixed scale for platforms where floating point is slow

  • transform.c

     
    868868#ifdef AVOID_FLOAT
    869869static int
    870870tab_sqrt[]={14142,13379,12806,12364,12018,11741,11517,11333,11180,11051,10943,10850,10770,10701,10640,10587,10540,10499,10462,10429,10400,10373,10349,10327,10307,10289,10273,10257,10243,10231,10219,10208};
     871
     872static int tab_int_step = 0x20000;
     873static int tab_int_scale[]={10000,10002,10008,10019,10033,10052,10076,10103,10135,10171,10212,10257,10306,10359,10417,10479,10546,10617,10693,10773,10858,10947,11041,11140,11243,11352,11465,11582,11705,11833,11965,12103,12246,12394,12547,12706,12870,13039,13214,13395,13581,13773,13971,14174,14384,14600,14822,15050,15285,15526,15774,16028,16289,16557,16832,17114,17404,17700,18005,18316,18636,18964,19299,19643,19995,20355,20724,21102,21489,21885,22290,22705,23129,23563,24007,24461,24926,25401,25886,26383,26891};
     874
     875int transform_int_scale(int y)
     876{
     877        int a=tab_int_step,i,size = sizeof(tab_int_scale)/sizeof(int);
     878        if (y < 0)
     879                y=-y;
     880        i=y/tab_int_step;
     881        if (i >= size)
     882                i=size-1;
     883        return tab_int_scale[i];
     884}
    871885#endif
    872886
    873887double
     
    880894        dy=c1->y-c2->y;
    881895        return sqrt(dx*dx+dy*dy)/scale;
    882896#else
    883         int dx,dy,f,scale=15539;
     897        int dx,dy,f,scale=transform_int_scale((c1->y+c2->y)/2);
    884898        dx=c1->x-c2->x;
    885899        dy=c1->y-c2->y;
    886900        if (dx < 0)