423
* Compute the error in position between ideal location.
424
* and the current integer location.
423
* Compute the error in position between ideal location.
424
* and the current integer location.
428
(fn0 - p.N) * (fn0 - p.N) + (fm0 - p.M) * (fm0 - p.M);
430
* Adjust the error by the length of the vector. This gives
431
* a slight bias toward larger cell sizzes.
433
error /= p.N * p.N + p.M * p.M;
434
error = sqrt(error); /* The previous calcs. gave value squared */
428
(fn0 - p.N) * (fn0 - p.N) + (fm0 - p.M) * (fm0 - p.M);
430
* Adjust the error by the length of the vector. This gives
431
* a slight bias toward larger cell sizzes.
433
error /= p.N * p.N + p.M * p.M;
434
error = sqrt(error); /* The previous calcs. gave value squared */
435
435
if (error > e_best)
493
493
penum->x = penum->y = 0;
495
495
if (porder->wse == NULL) {
496
penum->strip = porder->num_levels / porder->width;
497
penum->shift = porder->shift;
499
* We want a transformation matrix that maps the parallelogram
500
* (0,0), (U,V), (U-V',V+U'), (-V',U') to the square (+/-1, +/-1).
501
* If the coefficients are [a b c d e f] and we let
502
* u = U = M/R, v = V = N/R,
503
* r = -V' = -N'/R', s = U' = M'/R',
504
* then we just need to solve the equations:
505
* a*0 + c*0 + e = -1 b*0 + d*0 + f = -1
506
* a*u + c*v + e = 1 b*u + d*v + f = 1
507
* a*r + c*s + e = -1 b*r + d*s + f = 1
508
* This has the following solution:
509
* Q = 2 / (M*M' + N*N')
518
const int M = porder->params.M, N = porder->params.N, R = porder->params.R;
519
const int M1 = porder->params.M1, N1 = porder->params.N1, R1 = porder->params.R1;
520
double Q = 2.0 / ((long)M * M1 + (long)N * N1);
496
penum->strip = porder->num_levels / porder->width;
497
penum->shift = porder->shift;
499
* We want a transformation matrix that maps the parallelogram
500
* (0,0), (U,V), (U-V',V+U'), (-V',U') to the square (+/-1, +/-1).
501
* If the coefficients are [a b c d e f] and we let
502
* u = U = M/R, v = V = N/R,
503
* r = -V' = -N'/R', s = U' = M'/R',
504
* then we just need to solve the equations:
505
* a*0 + c*0 + e = -1 b*0 + d*0 + f = -1
506
* a*u + c*v + e = 1 b*u + d*v + f = 1
507
* a*r + c*s + e = -1 b*r + d*s + f = 1
508
* This has the following solution:
509
* Q = 2 / (M*M' + N*N')
518
const int M = porder->params.M, N = porder->params.N, R = porder->params.R;
519
const int M1 = porder->params.M1, N1 = porder->params.N1, R1 = porder->params.R1;
520
double Q = 2.0 / ((long)M * M1 + (long)N * N1);
522
penum->mat.xx = Q * (R * M1);
523
penum->mat.xy = Q * (-R1 * N);
524
penum->mat.yx = Q * (R * N1);
525
penum->mat.yy = Q * (R1 * M);
526
penum->mat.tx = -1.0;
527
penum->mat.ty = -1.0;
528
gs_matrix_invert(&penum->mat, &penum->mat_inv);
530
if_debug7('h', "[h]Screen: (%dx%d)/%d [%f %f %f %f]\n",
531
porder->width, porder->height, porder->params.R,
532
penum->mat.xx, penum->mat.xy,
533
penum->mat.yx, penum->mat.yy);
522
penum->mat.xx = Q * (R * M1);
523
penum->mat.xy = Q * (-R1 * N);
524
penum->mat.yx = Q * (R * N1);
525
penum->mat.yy = Q * (R1 * M);
526
penum->mat.tx = -1.0;
527
penum->mat.ty = -1.0;
528
gs_matrix_invert(&penum->mat, &penum->mat_inv);
530
if_debug7('h', "[h]Screen: (%dx%d)/%d [%f %f %f %f]\n",
531
porder->width, porder->height, porder->params.R,
532
penum->mat.xx, penum->mat.xy,
533
penum->mat.yx, penum->mat.yy);
595
595
gs_screen_next(gs_screen_enum * penum, floatp value)
597
597
if (penum->order.wse) {
598
return gs_wts_screen_enum_next (penum->order.wse, value);
598
return gs_wts_screen_enum_next (penum->order.wse, value);
601
int width = penum->order.width;
602
gx_ht_bit *bits = (gx_ht_bit *)penum->order.bit_data;
601
int width = penum->order.width;
602
gx_ht_bit *bits = (gx_ht_bit *)penum->order.bit_data;
604
if (value < -1.0 || value > 1.0)
605
return_error(gs_error_rangecheck);
606
sample = (ht_sample_t) ((value + 1) * max_ht_sample);
604
if (value < -1.0 || value > 1.0)
605
return_error(gs_error_rangecheck);
606
sample = (ht_sample_t) ((value + 1) * max_ht_sample);
608
if (gs_debug_c('H')) {
608
if (gs_debug_c('H')) {
611
gs_screen_currentpoint(penum, &pt);
612
dlprintf6("[H]sample x=%d y=%d (%f,%f): %f -> %u\n",
613
penum->x, penum->y, pt.x, pt.y, value, sample);
611
gs_screen_currentpoint(penum, &pt);
612
dlprintf6("[H]sample x=%d y=%d (%f,%f): %f -> %u\n",
613
penum->x, penum->y, pt.x, pt.y, value, sample);
616
bits[penum->y * width + penum->x].mask = sample;
617
if (++(penum->x) >= width)
618
penum->x = 0, ++(penum->y);
616
bits[penum->y * width + penum->x].mask = sample;
617
if (++(penum->x) >= width)
618
penum->x = 0, ++(penum->y);