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

Comparing ray/src/rt/fprism.c (file contents):
Revision 2.1 by greg, Wed Sep 29 10:40:31 1993 UTC vs.
Revision 2.3 by greg, Tue Feb 14 08:54:17 1995 UTC

# Line 24 | Line 24 | double x;
24                  return(0.);
25          return(sqrt(x));
26   }
27 #define sqrt(x) Sqrt(x)
27  
28   /* definitions de macros utiles */
29  
# Line 103 | Line 102 | extern long eclock;
102  
103   /* Definition des routines */
104  
105 < #define term(a,b) a/sqrt(a*a+b*b)
105 > #define term(a,b) a/Sqrt(a*a+b*b)
106   static
107   prepare_matrices()
108   {
# Line 209 | Line 208 | FVECT v,v_out;
208   FVECT v_temp;
209   double det;
210  
211 < det = sqrt( (YY(v)*YY(v)+ZZ(v)*ZZ(v))*(YY(v)*YY(v)+ZZ(v)*ZZ(v))+
211 > det = Sqrt( (YY(v)*YY(v)+ZZ(v)*ZZ(v))*(YY(v)*YY(v)+ZZ(v)*ZZ(v))+
212           (XX(v)*XX(v)*YY(v)*YY(v))+(XX(v)*XX(v)*ZZ(v)*ZZ(v)) );
213   XX(v_temp) = (YY(v)*YY(v)+ZZ(v)*ZZ(v))/det;
214   YY(v_temp) = -( XX(v)*YY(v) )/det;
# Line 227 | Line 226 | FVECT v,v_out;
226   FVECT v_temp;
227   double det;
228  
229 < det = sqrt( (ZZ(v)*ZZ(v)+YY(v)*YY(v)) );
229 > det = Sqrt( (ZZ(v)*ZZ(v)+YY(v)*YY(v)) );
230   XX(v_temp) = 0.;
231   YY(v_temp) = -ZZ(v)/det;
232   ZZ(v_temp) = YY(v)/det;
# Line 367 | Line 366 | TRAYON r_initial;
366  
367  
368  
369 + static int
370 + compare(r1,r2,marge)
371 + TRAYON r1, r2;
372 + double marge;
373  
374 + {
375 + double arctg1, arctg2;
376 +
377 + arctg1 = atan2(Y(r1),X(r1));
378 + arctg2 = atan2(Y(r2),X(r2));
379 + if ((arctg1 - marge <= arctg2) && (arctg1 + marge >= arctg2)) return 1;
380 + else return 0;
381 + }
382 +
383 +
384 +
385 +
386   static
387   sortie(r)
388   TRAYON r;
# Line 411 | Line 426 | TRAYON r;
426   {
427   double det;
428  
429 < det = sqrt(X(r)*X(r)+Y(r)*Y(r)+Z(r)*Z(r));
430 < sinus = sqrt(Y(r)*Y(r)+Z(r)*Z(r))/det;
431 < cosinus = sqrt(X(r)*X(r))/det;
429 > det = Sqrt(X(r)*X(r)+Y(r)*Y(r)+Z(r)*Z(r));
430 > sinus = Sqrt(Y(r)*Y(r)+Z(r)*Z(r))/det;
431 > cosinus = Sqrt(X(r)*X(r))/det;
432   if (r.n == 1.) rapport = prism.np * prism.np;
433   else rapport = 1./(prism.np * prism.np);
434   return;
# Line 432 | Line 447 | TRAYON r_incident;
447   X(r_reflechi) = -X(r_incident);
448   Y(r_reflechi) = Y(r_incident);
449   Z(r_reflechi) = Z(r_incident);
450 < if(sinus > sqrt(rapport) || r_incident.dest == tot_ref)
450 > if(sinus > Sqrt(rapport) || r_incident.dest == tot_ref)
451          {
452           r_reflechi.ppar1 = r_incident.ppar1;
453           r_reflechi.pper1 = r_incident.pper1;
# Line 442 | Line 457 | TRAYON r_incident;
457          }
458   else
459          {
460 <         r_reflechi.ppar1 = r_incident.ppar1*(rapport*cosinus-sqrt(rapport-
461 <                 (sinus*sinus)))/(rapport*cosinus+sqrt(rapport-(sinus*sinus)));
462 <         r_reflechi.pper1 = r_incident.pper1*(cosinus-sqrt
463 <                (rapport-(sinus*sinus)))/(cosinus+sqrt(rapport-(sinus*sinus)));
464 <         r_reflechi.ppar2 = r_incident.ppar2*(rapport*cosinus-sqrt(rapport-
465 <                 (sinus*sinus)))/(rapport*cosinus+sqrt(rapport-(sinus*sinus)));
466 <         r_reflechi.pper2 = r_incident.pper2*(cosinus-sqrt
467 <                (rapport-(sinus*sinus)))/(cosinus+sqrt(rapport-(sinus*sinus)));
460 >         r_reflechi.ppar1 = r_incident.ppar1*(rapport*cosinus-Sqrt(rapport-
461 >                 (sinus*sinus)))/(rapport*cosinus+Sqrt(rapport-(sinus*sinus)));
462 >         r_reflechi.pper1 = r_incident.pper1*(cosinus-Sqrt
463 >                (rapport-(sinus*sinus)))/(cosinus+Sqrt(rapport-(sinus*sinus)));
464 >         r_reflechi.ppar2 = r_incident.ppar2*(rapport*cosinus-Sqrt(rapport-
465 >                 (sinus*sinus)))/(rapport*cosinus+Sqrt(rapport-(sinus*sinus)));
466 >         r_reflechi.pper2 = r_incident.pper2*(cosinus-Sqrt
467 >                (rapport-(sinus*sinus)))/(cosinus+Sqrt(rapport-(sinus*sinus)));
468           r_reflechi.e = r_incident.e *(((r_reflechi.ppar1*r_reflechi.ppar1+
469           r_reflechi.pper1*r_reflechi.pper1)/(r_incident.ppar1*r_incident.ppar1+
470           r_incident.pper1*r_incident.pper1))+((r_reflechi.ppar2*r_reflechi.ppar2
# Line 471 | Line 486 | TRAYON r_incident;
486  
487   r_transmis = r_incident;
488   trigo(r_incident);
489 < if (sinus <= sqrt(rapport) && r_incident.dest != tot_ref)
489 > if (sinus <= Sqrt(rapport) && r_incident.dest != tot_ref)
490          {
491           X(r_transmis) = (X(r_incident)/(fabs(X(r_incident))))*
492 <                         (sqrt(1.-(Y(r_incident)*Y(r_incident)+Z(r_incident)*
492 >                         (Sqrt(1.-(Y(r_incident)*Y(r_incident)+Z(r_incident)*
493                                     Z(r_incident))/rapport));
494 <         Y(r_transmis) = Y(r_incident)/sqrt(rapport);
495 <         Z(r_transmis) = Z(r_incident)/sqrt(rapport);
496 <         r_transmis.ppar1 = r_incident.ppar1*2.*sqrt(rapport)*cosinus/
497 <                           (sqrt(rapport-sinus*sinus)+rapport*cosinus);
498 <         r_transmis.pper1 = r_incident.pper1*2.*cosinus/(cosinus+sqrt(rapport
494 >         Y(r_transmis) = Y(r_incident)/Sqrt(rapport);
495 >         Z(r_transmis) = Z(r_incident)/Sqrt(rapport);
496 >         r_transmis.ppar1 = r_incident.ppar1*2.*Sqrt(rapport)*cosinus/
497 >                           (Sqrt(rapport-sinus*sinus)+rapport*cosinus);
498 >         r_transmis.pper1 = r_incident.pper1*2.*cosinus/(cosinus+Sqrt(rapport
499                             - sinus*sinus));
500 <         r_transmis.ppar2 = r_incident.ppar2*2.*sqrt(rapport)*cosinus/
501 <                           (sqrt(rapport-sinus*sinus)+rapport*cosinus);
502 <         r_transmis.pper2 = r_incident.pper2*2.*cosinus/(cosinus+sqrt(rapport
500 >         r_transmis.ppar2 = r_incident.ppar2*2.*Sqrt(rapport)*cosinus/
501 >                           (Sqrt(rapport-sinus*sinus)+rapport*cosinus);
502 >         r_transmis.pper2 = r_incident.pper2*2.*cosinus/(cosinus+Sqrt(rapport
503                             - sinus*sinus));
504 <         r_transmis.e = (r_incident.e/2)*(sqrt(rapport-sinus*sinus)/cosinus)
504 >         r_transmis.e = (r_incident.e/2)*(Sqrt(rapport-sinus*sinus)/cosinus)
505              *(((r_transmis.ppar1*r_transmis.ppar1+r_transmis.pper1*
506                  r_transmis.pper1)
507              /(r_incident.ppar1*r_incident.ppar1+r_incident.pper1*
# Line 506 | Line 521 | TRAYON r_incident;
521  
522  
523  
509 static int
510 compare(r1,r2,marge)
511 TRAYON r1, r2;
512 double marge;
513
514 {
515 double arctg1, arctg2;
516
517 arctg1 = atan2(Y(r1),X(r1));
518 arctg2 = atan2(Y(r2),X(r2));
519 if ((arctg1 - marge <= arctg2) && (arctg1 + marge >= arctg2)) return 1;
520 else return 0;
521 }
522
523
524
524   #define ensuite(rayon,prob_passage,destination) r_suite = rayon; \
525                                   r_suite.e = prob_passage(rayon)*rayon.e; \
526                                   r_suite.dest = destination; \
# Line 633 | Line 632 | TRAYON *r1,*r2;
632  
633  
634  
636 static double
637 l_get_val()
638
639 {
640 int val, dir, i, trouve, curseur;
641 int nb;
642 double valeur;
643 TRAYON *rayt, raynull;
644
645 if (prismclock < 0 || prismclock < eclock) setprism();
646 if (bidon == BADVAL) {
647        errno = EDOM;
648        return(0.0);
649 }
650 val = (int)(argument(1) + .5);
651 dir = (int)(argument(2) + .5);
652 nb = (int)(argument(3) + .5);
653 X(raynull) = bidon;
654 Y(raynull) = Z(raynull) = 0.;
655 raynull.e = 0.;
656 trouve = curseur = 0;
657 if ( !nosource && nb==2 ) nb=1; /* on est en train de tracer la source
658                                     a partir de sa seconde source virtuelle */
659 #ifdef DEBUG
660 fprintf(stderr, " On considere le rayon no: %d\n", nb);
661 #endif
662 for(i=0; i < nbrayons &&!trouve; i++)
663  {
664   if(ray[i].v[0] * dir * sens >= 0.) curseur ++;
665   if(curseur == nb)
666   {
667    rayt = &ray[i];
668    trouve = 1;
669   }
670  }
671 if(!trouve) rayt = &raynull;
672 switch(val) {
673        case 0 : valeur = rayt->v[0];
674                 break;
675        case 1 : valeur = rayt->v[1];
676                 break;
677        case 2 : valeur = rayt->v[2];
678                 break;
679        case 3 : valeur = rayt->e;
680                 break;
681        default : errno = EDOM; return(0.0);
682    }
683 #ifdef DEBUG
684  fprintf(stderr, "get_val( %i, %i, %i) = %lf\n",val,dir,nb,valeur);
685 #endif
686  return valeur;
687 }
688
689
635   static
636   setprism()
692
637   {
638   double d;
639   TRAYON r_initial,rsource;
# Line 784 | Line 728 | if ( X(r_initial) != 0.)
728   bidon = BADVAL;
729   return;
730   }
731 +
732 +
733 + static double
734 + l_get_val()
735 +
736 + {
737 + int val, dir, i, trouve, curseur;
738 + int nb;
739 + double valeur;
740 + TRAYON *rayt, raynull;
741 +
742 + if (prismclock < 0 || prismclock < eclock) setprism();
743 + if (bidon == BADVAL) {
744 +        errno = EDOM;
745 +        return(0.0);
746 + }
747 + val = (int)(argument(1) + .5);
748 + dir = (int)(argument(2) + .5);
749 + nb = (int)(argument(3) + .5);
750 + X(raynull) = bidon;
751 + Y(raynull) = Z(raynull) = 0.;
752 + raynull.e = 0.;
753 + trouve = curseur = 0;
754 + if ( !nosource && nb==2 ) nb=1; /* on est en train de tracer la source
755 +                                     a partir de sa seconde source virtuelle */
756 + #ifdef DEBUG
757 + fprintf(stderr, " On considere le rayon no: %d\n", nb);
758 + #endif
759 + for(i=0; i < nbrayons &&!trouve; i++)
760 +  {
761 +   if(ray[i].v[0] * dir * sens >= 0.) curseur ++;
762 +   if(curseur == nb)
763 +   {
764 +    rayt = &ray[i];
765 +    trouve = 1;
766 +   }
767 +  }
768 + if(!trouve) rayt = &raynull;
769 + switch(val) {
770 +        case 0 : valeur = rayt->v[0];
771 +                 break;
772 +        case 1 : valeur = rayt->v[1];
773 +                 break;
774 +        case 2 : valeur = rayt->v[2];
775 +                 break;
776 +        case 3 : valeur = rayt->e;
777 +                 break;
778 +        default : errno = EDOM; return(0.0);
779 +    }
780 + #ifdef DEBUG
781 +  fprintf(stderr, "get_val( %i, %i, %i) = %lf\n",val,dir,nb,valeur);
782 + #endif
783 +  return valeur;
784 + }
785 +
786  
787   setprismfuncs()
788   {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines