ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/pinterp.c
(Generate patch)

Comparing ray/src/px/pinterp.c (file contents):
Revision 2.16 by greg, Fri Dec 23 15:42:55 1994 UTC vs.
Revision 2.18 by greg, Fri Dec 23 19:15:48 1994 UTC

# Line 496 | Line 496 | double z;
496   }
497  
498  
499 + movepixel(pos)                          /* reposition image point */
500 + FVECT   pos;
501 + {
502 +        double  d0, d1;
503 +        FVECT   pt, direc;
504 +        
505 +        if (pos[2] <= 0)                /* empty pixel */
506 +                return(-1);
507 +        if (normdist && theirview.type == VT_PER) {     /* adjust distance */
508 +                d0 = pos[0] + theirview.hoff - .5;
509 +                d1 = pos[1] + theirview.voff - .5;
510 +                pos[2] /= sqrt(1. + d0*d0*theirview.hn2 + d1*d1*theirview.vn2);
511 +        }
512 +        if (hasmatrix) {
513 +                pos[0] += theirview.hoff - .5;
514 +                pos[1] += theirview.voff - .5;
515 +                if (theirview.type == VT_PER) {
516 +                        pos[0] *= pos[2];
517 +                        pos[1] *= pos[2];
518 +                }
519 +                multp3(pos, pos, theirs2ours);
520 +                if (pos[2] <= 0)
521 +                        return(-1);
522 +                if (ourview.type == VT_PER) {
523 +                        pos[0] /= pos[2];
524 +                        pos[1] /= pos[2];
525 +                }
526 +                pos[0] += .5 - ourview.hoff;
527 +                pos[1] += .5 - ourview.voff;
528 +                return(0);
529 +        }
530 +        if (viewray(pt, direc, &theirview, pos[0], pos[1]) < -FTINY)
531 +                return(-1);
532 +        pt[0] += direc[0]*pos[2];
533 +        pt[1] += direc[1]*pos[2];
534 +        pt[2] += direc[2]*pos[2];
535 +        viewloc(pos, &ourview, pt);
536 +        if (pos[2] <= 0)
537 +                return(-1);
538 +        return(0);
539 + }
540 +
541 +
542   getperim(xl, yl, zline, zfd)            /* compute overlapping image area */
543   register struct bound   *xl;
544   struct bound    *yl;
# Line 561 | Line 604 | int    zfd;
604                          }
605                  }
606                                                          /* fill in between */
607 <                if (xl[y].min < xl[y-step].min)
607 >                if (y < step) {
608                          xl[y-1].min = xl[y].min;
566                else
567                        xl[y-1].min = xl[y-step].min;
568                if (xl[y].max > xl[y-step].max)
609                          xl[y-1].max = xl[y].max;
610 <                else
611 <                        xl[y-1].max = xl[y-step].max;
610 >                } else {
611 >                        if (xl[y].min < xl[y-step].min)
612 >                                xl[y-1].min = xl[y].min;
613 >                        else
614 >                                xl[y-1].min = xl[y-step].min;
615 >                        if (xl[y].max > xl[y-step].max)
616 >                                xl[y-1].max = xl[y].max;
617 >                        else
618 >                                xl[y-1].max = xl[y-step].max;
619 >                }
620                  for (x = 2; x < step; x++)
621                          copystruct(xl+y-x, xl+y-1);
622          }
# Line 580 | Line 628 | int    zfd;
628   }
629  
630  
583 movepixel(pos)                          /* reposition image point */
584 FVECT   pos;
585 {
586        double  d0, d1;
587        FVECT   pt, direc;
588        
589        if (pos[2] <= 0)                /* empty pixel */
590                return(-1);
591        if (normdist && theirview.type == VT_PER) {     /* adjust distance */
592                d0 = pos[0] + theirview.hoff - .5;
593                d1 = pos[1] + theirview.voff - .5;
594                pos[2] /= sqrt(1. + d0*d0*theirview.hn2 + d1*d1*theirview.vn2);
595        }
596        if (hasmatrix) {
597                pos[0] += theirview.hoff - .5;
598                pos[1] += theirview.voff - .5;
599                if (theirview.type == VT_PER) {
600                        pos[0] *= pos[2];
601                        pos[1] *= pos[2];
602                }
603                multp3(pos, pos, theirs2ours);
604                if (pos[2] <= 0)
605                        return(-1);
606                if (ourview.type == VT_PER) {
607                        pos[0] /= pos[2];
608                        pos[1] /= pos[2];
609                }
610                pos[0] += .5 - ourview.hoff;
611                pos[1] += .5 - ourview.voff;
612                return(0);
613        }
614        if (viewray(pt, direc, &theirview, pos[0], pos[1]) < -FTINY)
615                return(-1);
616        pt[0] += direc[0]*pos[2];
617        pt[1] += direc[1]*pos[2];
618        pt[2] += direc[2]*pos[2];
619        viewloc(pos, &ourview, pt);
620        if (pos[2] <= 0)
621                return(-1);
622        return(0);
623 }
624
625
631   backpicture(fill, samp)                 /* background fill algorithm */
632   int     (*fill)();
633   int     samp;
# Line 738 | Line 743 | clipaft()                      /* perform aft clipping as indicated */
743  
744          if (ourview.vaft <= FTINY)
745                  return;
746 <        tstdist = ourview.vaft;
746 >        tstdist = ourview.vaft - ourview.vfore;
747          for (y = 0; y < vresolu; y++) {
748                  if (ourview.type == VT_PER) {           /* adjust distance */
749                          yzn2 = (y+.5)/vresolu + ourview.voff - .5;
750                          yzn2 = 1. + yzn2*yzn2*ourview.vn2;
751 <                        tstdist = ourview.vaft * sqrt(yzn2);
751 >                        tstdist = (ourview.vaft - ourview.vfore)*sqrt(yzn2);
752                  }
753                  for (x = 0; x < hresolu; x++)
754                          if (zscan(y)[x] > tstdist) {
755                                  if (ourview.type == VT_PER) {
756                                          vx = (x+.5)/hresolu + ourview.hoff - .5;
757 <                                        if (zscan(y)[x] <= ourview.vaft *
757 >                                        if (zscan(y)[x] <= (ourview.vaft -
758 >                                                        ourview.vfore) *
759                                                  sqrt(vx*vx*ourview.hn2 + yzn2))
760                                                  continue;
761                                  }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines