Ticket #378: calculate_scale.diff

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

Patch to calculate 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);
     878        for(i=0;i<size; i++) {
     879                if(a>y) {
     880                        return tab_int_scale[i];
     881                }
     882                a+=tab_int_step;
     883        }
     884        return tab_int_scale[size-1];
     885}
    871886#endif
    872887
    873888double
     
    880895        dy=c1->y-c2->y;
    881896        return sqrt(dx*dx+dy*dy)/scale;
    882897#else
    883         int dx,dy,f,scale=15539;
     898        int dx,dy,f,scale=transform_int_scale((c1->y+c2->y)/2);
    884899        dx=c1->x-c2->x;
    885900        dy=c1->y-c2->y;
    886901        if (dx < 0)