      SUBROUTINE PROJET(NBON,XMIN,XMAX,YMIN,YMAX)
C
      INCLUDE 'com_coor.f'
      INCLUDE 'com_faces.f'
      INCLUDE 'com_options.f'
C
      REAL*8  UU1,UU2,UU3,UU,UN,VN
      LOGICAL*4 CACHPA
      DATA US3 / 0.3333333333333333 /
C
      XMIN =  BIG
      XMAX = -BIG
      YMIN =  BIG
      YMAX = -BIG
C
      NBON = 0
      CACHPA = IFC.LT.0.OR.ISHRINK.LT.0.OR.ICOURB.LT.0.OR.I2D.NE.0
     &     .OR.IPREFC.LT.0.OR.IFC.EQ.2
      SENS = REAL(ISENS)
      IF (NDS.EQ.3) THEN
        KMAX = 1
      ELSE
        KMAX = 4
      ENDIF
      IF (ICTFAC.EQ.97.OR.ICTFAC.EQ.96) THEN
        DO I=1,3*NUMNP
          PHONG(1,I) = 0.
          PHONG(2,I) = 0.
          PHONG(3,I) = 0.
          ITOUCH(I)  = 0
        ENDDO
      ENDIF
      IF (NRECON.EQ.ISYM) THEN
        NRECONCON = 0
      ELSE
        NRECONCON = ISYM+1-NRECON
      ENDIF
      DO 50 N=1,NFACE
        IF (IFPLAN(N).LE.NRECONCON.OR.ISHRINK.LE.0) THEN
          U1 = XF(3,N)-XF(1,N)
          U2 = YF(3,N)-YF(1,N)
          U3 = ZF(3,N)-ZF(1,N)
          V1 = XF(KMAX,N)-XF(2,N)
          V2 = YF(KMAX,N)-YF(2,N)
          V3 = ZF(KMAX,N)-ZF(2,N)
          IF (IPERSP.NE.1) THEN
            IF (NDS.EQ.3) THEN
              OBS1 = XPUP(1) - US3*(XF(1,N) + XF(2,N) + XF(3,N))
              OBS2 = XPUP(2) - US3*(YF(1,N) + YF(2,N) + YF(3,N))
              OBS3 = XPUP(3) - US3*(ZF(1,N) + ZF(2,N) + ZF(3,N))
            ELSE
              OBS1 = XPUP(1) - 0.25*(XF(1,N)+XF(2,N)+XF(3,N)+XF(4,N))
              OBS2 = XPUP(2) - 0.25*(YF(1,N)+YF(2,N)+YF(3,N)+YF(4,N))
              OBS3 = XPUP(3) - 0.25*(ZF(1,N)+ZF(2,N)+ZF(3,N)+ZF(4,N))
            ENDIF
            PMIXT = ( (U2*V3-U3*V2)*OBS1
     &            +   (U3*V1-U1*V3)*OBS2
     &            +   (U1*V2-U2*V1)*OBS3 )*SENS
          ELSE
            PMIXT = ( U2*V3+U3*V1+U1*V2 - (U3*V2+U1*V3+U2*V1) )*SENS
          ENDIF
          IF (PMIXT.GT.0..OR.CACHPA) THEN
            NBON = NBON + 1
            DO I=1,NDS
              CALL PROJEC(XF(I,N),YF(I,N),ZF(I,N),SENS
     &                   ,XX(I,NBON),YY(I,NBON),IPERSP,XPUP,DIST)
            ENDDO
            ISD(NBON) = ISD2(N)
            NPROJE(NBON) = N
            IF (PMIXT.GT.0.) THEN
              NSENS(NBON) = NNUMFA(N)
            ELSE
              NSENS(NBON) = -NNUMFA(N)
            ENDIF
            IF (ICTFAC.GT.15) THEN
              UU1 = U2*V3-V2*U3
              UU2 = U3*V1-V3*U1
              UU3 = U1*V2-V1*U2
              UU = UU1**2+UU2**2+UU3**2
              UN = U1**2 + U2**2 + U3**2
              VN = V1**2 + V2**2 + V3**2
              IF (UN*VN.GT.0.) THEN
                IF (UU**2.LE.1.D-30*UN*VN) UU = 1.
              ELSE
                UU = 1.
              ENDIF
              IF (ICTFAC.EQ.99) THEN
CCCC                REFLEC(NBON) = .15+.85*ABS( DIRLUM(1)*UU1 +
                REFLEC(NBON) = ABS( DIRLUM(1)*UU1 +
     &                              DIRLUM(2)*UU2 +
     &                              DIRLUM(3)*UU3 ) / SQRT(UU)
              ELSEIF(ICTFAC.EQ.98) THEN
                TOTO = ABS( DIRLUM(1)*UU1 +
     &                      DIRLUM(2)*UU2 +
     &                      DIRLUM(3)*UU3 ) / SQRT(UU)
ccc                TOTO = 2.5*TOTO*TOTO*(TOTO-1.)+TOTO
ccc                TOTO = TOTO*(4.*TOTO*TOTO-6.*TOTO+3.)
                TOTO = TOTO*(3.*TOTO*TOTO-4.5*TOTO+2.5)
                REFLEC(NBON) = MIN(1.,MAX(0.,TOTO))
Cfj                REFLEC(NBON) = .1 + .9*(( DIRLUM(1)*UU1 +
Cfj     &                                    DIRLUM(2)*UU2 +
Cfj     &                                    DIRLUM(3)*UU3 )**2 / UU )**2
              ELSEIF(N.LE.NF) THEN
                USQU = 1./SQRT(UU)
                DO I=1,NDS
                  PHONG(1,NFAC(I,N)) = PHONG(1,NFAC(I,N)) + UU1*USQU
                  PHONG(2,NFAC(I,N)) = PHONG(2,NFAC(I,N)) + UU2*USQU
                  PHONG(3,NFAC(I,N)) = PHONG(3,NFAC(I,N)) + UU3*USQU
                  ITOUCH(NFAC(I,N))  = 1
                ENDDO
              ENDIF
            ENDIF
          ELSEIF(ICTFAC.GT.15.AND.ICTFAC.LT.98) THEN
            IF (N.LE.NF) THEN
              UU1 = U2*V3-V2*U3
              UU2 = U3*V1-V3*U1
              UU3 = U1*V2-V1*U2
              UU = UU1**2+UU2**2 +UU3**2
              UN = U1**2 + U2**2 + U3**2
              VN = V1**2 + V2**2 + V3**2
              IF (UN*VN.GT.0.) THEN
                IF (UU**2.LE.1.D-30*UN*VN) UU = 1.
              ELSE
                UU = 1.
              ENDIF
              USQU = 1./SQRT(UU)
              DO I=1,NDS
                PHONG(1,NFAC(I,N)) = PHONG(1,NFAC(I,N)) + UU1*USQU
                PHONG(2,NFAC(I,N)) = PHONG(2,NFAC(I,N)) + UU2*USQU
                PHONG(3,NFAC(I,N)) = PHONG(3,NFAC(I,N)) + UU3*USQU
                ITOUCH(NFAC(I,N))  = 1
              ENDDO
            ENDIF
          ENDIF
        ENDIF
 50   CONTINUE
      IF (ICTFAC.GT.15.AND.ICTFAC.LT.98) THEN
        DO I=1,3*NUMNP
          IF (ITOUCH(I).NE.0) THEN
            UU = PHONG(1,I)**2 + PHONG(2,I)**2 + PHONG(3,I)**2
            IF (UU.LT.1.D-30) UU = 1.
            USQU = 1./SQRT(UU)
            DO K=1,3
              PHONG(K,I) = PHONG(K,I)*USQU
            ENDDO
          ENDIF
        ENDDO
      ENDIF
C
      IF (NBON.EQ.0) THEN
        XMIN = -1.
        XMAX = 1.
        YMIN = -1.
        YMAX = 1.
      ELSE
        CMINI = BIG
        CMAXI = -BIG
        IF (NDS.EQ.3) THEN
          IF (IPERSP.EQ.1) THEN
            DO N=1,NBON
              NN = NPROJE(N)
              C1 = (XF(1,NN)+YF(1,NN)+ZF(1,NN))*SENS
              C2 = (XF(2,NN)+YF(2,NN)+ZF(2,NN))*SENS
              C3 = (XF(3,NN)+YF(3,NN)+ZF(3,NN))*SENS
              CENTRMI(N) = MIN(C1,C2,C3)
              CENTRMA(N) = MAX(C1,C2,C3)
              CENTR(N)   = (C1+C2+C3)*US3
Cfj              CENTR(N) = (XF(1,NN) + XF(2,NN) + XF(3,NN)
Cfj     &             +  YF(1,NN) + YF(2,NN) + YF(3,NN)
Cfj     &             +  ZF(1,NN) + ZF(2,NN) + ZF(3,NN))*SENS3
              XMIN = MIN(XMIN,XX(1,N),XX(2,N),XX(3,N))
              XMAX = MAX(XMAX,XX(1,N),XX(2,N),XX(3,N))
              YMIN = MIN(YMIN,YY(1,N),YY(2,N),YY(3,N))
              YMAX = MAX(YMAX,YY(1,N),YY(2,N),YY(3,N))
              CMINI = MIN(CMINI,CENTR(N))
              CMAXI = MAX(CMAXI,CENTR(N))
            ENDDO
          ELSE
            DO N=1,NBON
              NN = NPROJE(N)
              NN = NPROJE(N)
              C1 =-((XF(1,NN)-XPUP(1))**2
     &             +(YF(1,NN)-XPUP(2))**2
     &             +(ZF(1,NN)-XPUP(3))**2)*SENS
              C2 =-((XF(2,NN)-XPUP(1))**2
     &             +(YF(2,NN)-XPUP(2))**2
     &             +(ZF(2,NN)-XPUP(3))**2)*SENS
              C3 =-((XF(3,NN)-XPUP(1))**2
     &             +(YF(3,NN)-XPUP(2))**2
     &             +(ZF(3,NN)-XPUP(3))**2)*SENS
              CENTRMI(N) = MIN(C1,C2,C3)
              CENTRMA(N) = MAX(C1,C2,C3)
              CENTR(N) =-((US3*(XF(1,NN)+XF(2,NN)+XF(3,NN))-XPUP(1))**2
     &                 +  (US3*(YF(1,NN)+YF(2,NN)+YF(3,NN))-XPUP(2))**2
     &                 +  (US3*(ZF(1,NN)+ZF(2,NN)+ZF(3,NN))-XPUP(3))**2
     &                   )*SENS
              XMIN = MIN(XMIN,XX(1,N),XX(2,N),XX(3,N))
              XMAX = MAX(XMAX,XX(1,N),XX(2,N),XX(3,N))
              YMIN = MIN(YMIN,YY(1,N),YY(2,N),YY(3,N))
              YMAX = MAX(YMAX,YY(1,N),YY(2,N),YY(3,N))
              CMINI = MIN(CMINI,CENTR(N))
              CMAXI = MAX(CMAXI,CENTR(N))
            ENDDO
          ENDIF
        ELSE
          IF (IPERSP.EQ.1) THEN
            DO N=1,NBON
              NN = NPROJE(N)
              C1 = (XF(1,NN)+YF(1,NN)+ZF(1,NN))*SENS
              C2 = (XF(2,NN)+YF(2,NN)+ZF(2,NN))*SENS
              C3 = (XF(3,NN)+YF(3,NN)+ZF(3,NN))*SENS
              C4 = (XF(4,NN)+YF(4,NN)+ZF(4,NN))*SENS
              CENTRMI(N) = MIN(C1,C2,C3,C4)
              CENTRMA(N) = MAX(C1,C2,C3,C4)
              CENTR(N)   = (C1+C2+C3+C4)*0.25
Cfj              CENTR(N) = (XF(1,NN)+XF(2,NN)+XF(3,NN)+XF(4,NN)
Cfj     &                 +  YF(1,NN)+YF(2,NN)+YF(3,NN)+YF(4,NN)
Cfj     &                 +  ZF(1,NN)+ZF(2,NN)+ZF(3,NN)+ZF(4,NN))*SENS4
              XMIN = MIN(XMIN,XX(1,N),XX(2,N),XX(3,N),XX(4,N))
              XMAX = MAX(XMAX,XX(1,N),XX(2,N),XX(3,N),XX(4,N))
              YMIN = MIN(YMIN,YY(1,N),YY(2,N),YY(3,N),YY(4,N))
              YMAX = MAX(YMAX,YY(1,N),YY(2,N),YY(3,N),YY(4,N))
              CMINI = MIN(CMINI,CENTR(N))
              CMAXI = MAX(CMAXI,CENTR(N))
            ENDDO
          ELSE
            DO N=1,NBON
              NN = NPROJE(N)
              C1 =-((XF(1,NN)-XPUP(1))**2
     &             +(YF(1,NN)-XPUP(2))**2
     &             +(ZF(1,NN)-XPUP(3))**2)*SENS
              C2 =-((XF(2,NN)-XPUP(1))**2
     &             +(YF(2,NN)-XPUP(2))**2
     &             +(ZF(2,NN)-XPUP(3))**2)*SENS
              C3 =-((XF(3,NN)-XPUP(1))**2
     &             +(YF(3,NN)-XPUP(2))**2
     &             +(ZF(3,NN)-XPUP(3))**2)*SENS
              C4 =-((XF(4,NN)-XPUP(1))**2
     &             +(YF(4,NN)-XPUP(2))**2
     &             +(ZF(4,NN)-XPUP(3))**2)*SENS
              CENTRMI(N) = MIN(C1,C2,C3,C4)
              CENTRMA(N) = MAX(C1,C2,C3,C4)
              CENTR(N) =-( (.25*(XF(1,NN)+XF(2,NN)+XF(3,NN)+XF(4,NN))
     &                     -XPUP(1))**2
     &                 +   (.25*(YF(1,NN)+YF(2,NN)+YF(3,NN)+YF(4,NN))
     &                     -XPUP(2))**2
     &                 +   (.25*(ZF(1,NN)+ZF(2,NN)+ZF(3,NN)+ZF(4,NN))
     &                     -XPUP(3))**2
     &                   )*SENS
              XMIN = MIN(XMIN,XX(1,N),XX(2,N),XX(3,N),XX(4,N))
              XMAX = MAX(XMAX,XX(1,N),XX(2,N),XX(3,N),XX(4,N))
              YMIN = MIN(YMIN,YY(1,N),YY(2,N),YY(3,N),YY(4,N))
              YMAX = MAX(YMAX,YY(1,N),YY(2,N),YY(3,N),YY(4,N))
              CMINI = MIN(CMINI,CENTR(N))
              CMAXI = MAX(CMAXI,CENTR(N))
            ENDDO
          ENDIF
        ENDIF
      ENDIF
C
      ITOUS = 0
      DO I=1,NUMSD
        IF (ISDVU(I).EQ.0) ITOUS = ITOUS+1
      ENDDO
      IF (ITOUS.NE.0) THEN
        NBON2 = 0
        CMINI = BIG
        CMAXI = -BIG
        DO N=1,NBON
          NSD = MOD(ISD(N),1000)
          IF (ISDVU(NSD).GT.0) THEN
            NBON2 = NBON2+1
            DO I=1,NDS
              XX(I,NBON2) = XX(I,N)
              YY(I,NBON2) = YY(I,N)
            ENDDO
            ISD(NBON2) = ISD(N)
            NPROJE(NBON2) = NPROJE(N)
            CENTRMI(NBON2)= CENTRMI(N)
            CENTRMA(NBON2)= CENTRMA(N)
            CENTR(NBON2)  = CENTR(N)
            REFLEC(NBON2) = REFLEC(N)
            NSENS(NBON2)  = NSENS(N)
            CMINI = MIN(CMINI,CENTR(NBON2))
            CMAXI = MAX(CMAXI,CENTR(NBON2))
          ENDIF
        ENDDO
        NBON = NBON2
      ENDIF
C
      IF (CMINI.EQ.CMAXI) THEN
        USDC = 1.
      ELSE
        USDC = 1./(CMAXI-CMINI)
      ENDIF
C
      END
C=======================================================================
      SUBROUTINE PROJEC(X,Y,Z,SENS,XX,YY,IPERSP,XPUP,DIST)
      DIMENSION XPUP(3)
ctrans      common / dirobs / obsobs(3),uuuu(3),vvvv(3)
      DATA R3Q2 / .866025403784439 /
      DATA SQR2 / 1.41421356237310 /
      DATA SQR6 / 2.44948974278318 /
C
      IF (IPERSP.EQ.1) THEN
        XX = R3Q2*(Y-X)*SENS
        YY = -.5*(Y+X) + Z
      ELSE
        XL = DIST/(X+Y+Z-XPUP(1)-XPUP(2)-XPUP(3))
        XX = XL*SQR6*(X-Y)*SENS
        YY = XL*SQR2*(X+Y-2.*Z)
ctrans        xl = 2.*dist/((x-xpup(1))*obsobs(1)
ctrans     &               +(y-xpup(2))*obsobs(2)
ctrans     &               +(z-xpup(3))*obsobs(3))
ctrans        xx = xl*(x*uuuu(1)+y*uuuu(2))*sens
ctrans        yy = xl*(x*vvvv(1)+y*vvvv(2)+z*vvvv(3))*sens
      ENDIF
      END
C=======================================================================
Cfj      SUBROUTINE ZFICTIF(X,Y,Z,YY,ZFIC,IPERSP)
CfjC
Cfj      IF (IPERSP.EQ.1) THEN
Cfj        ZFIC = Z
Cfj      ELSE
Cfj        ZFIC = YY+.5*(Y+X)
Cfj      ENDIF
Cfj      END
C=======================================================================
      SUBROUTINE PROSUR(NBON)
C
      INCLUDE 'com_coor.f'
      INCLUDE 'com_faces.f'
      INCLUDE 'com_options.f'
      DATA US3 / .3333333333333333 /
C
      SENS = REAL(ISENS)
Cfj      SENS3 = SENS*US3
Cfj      SENS4 = SENS*.25
      DO I=1,NSURF
        N = I+NBON
        NPROJE(N) = NCMAX
        IF (IPERSP.EQ.1) THEN
          IF (XIS(3,I).EQ.XIS(4,I).AND.YIS(3,I).EQ.YIS(4,I)
     &   .AND.ZIS(3,I).EQ.ZIS(4,I)) THEN
            C1 = (XIS(1,I)+YIS(1,I)+ZIS(1,I))*SENS
            C2 = (XIS(2,I)+YIS(2,I)+ZIS(2,I))*SENS
            C3 = (XIS(3,I)+YIS(3,I)+ZIS(3,I))*SENS
            CENTRMI(N) = MIN(C1,C2,C3)
            CENTRMA(N) = MAX(C1,C2,C3)
            CENTR(N)   = (C1+C2+C3)*US3
Cfj            CENTR(N) = (XIS(1,I) + XIS(2,I) + XIS(3,I)
Cfj     &               +  YIS(1,I) + YIS(2,I) + YIS(3,I)
Cfj     &               +  ZIS(1,I) + ZIS(2,I) + ZIS(3,I))*SENS3
          ELSE
            C1 = (XIS(1,I)+YIS(1,I)+ZIS(1,I))*SENS
            C2 = (XIS(2,I)+YIS(2,I)+ZIS(2,I))*SENS
            C3 = (XIS(3,I)+YIS(3,I)+ZIS(3,I))*SENS
            C4 = (XIS(4,I)+YIS(4,I)+ZIS(4,I))*SENS
            CENTRMI(N) = MIN(C1,C2,C3,C4)
            CENTRMA(N) = MAX(C1,C2,C3,C4)
            CENTR(N)   = (C1+C2+C3+C4)*0.25
Cfj            CENTR(N) = (XIS(1,I) + XIS(2,I) + XIS(3,I) + XIS(4,I)
Cfj     &               +  YIS(1,I) + YIS(2,I) + YIS(3,I) + YIS(4,I)
Cfj     &               +  ZIS(1,I) + ZIS(2,I) + ZIS(3,I) + ZIS(4,I)
Cfj     &               )*SENS4
          ENDIF
        ELSE
          IF (XIS(3,I).EQ.XIS(4,I).AND.YIS(3,I).EQ.YIS(4,I)
     &   .AND.ZIS(3,I).EQ.ZIS(4,I)) THEN
            C1 =-((XIS(1,I)-XPUP(1))**2
     &           +(YIS(1,I)-XPUP(2))**2
     &           +(ZIS(1,I)-XPUP(3))**2)*SENS
            C2 =-((XIS(2,I)-XPUP(1))**2
     &           +(YIS(2,I)-XPUP(2))**2
     &           +(ZIS(2,I)-XPUP(3))**2)*SENS
            C3 =-((XIS(3,I)-XPUP(1))**2
     &           +(YIS(3,I)-XPUP(2))**2
     &           +(ZIS(3,I)-XPUP(3))**2)*SENS
            CENTRMI(N) = MIN(C1,C2,C3)
            CENTRMA(N) = MAX(C1,C2,C3)
            CENTR(N) =-((US3*(XIS(1,I)+XIS(2,I)+XIS(3,I))-XPUP(1))**2
     &               +  (US3*(YIS(1,I)+YIS(2,I)+YIS(3,I))-XPUP(2))**2
     &               +  (US3*(ZIS(1,I)+ZIS(2,I)+ZIS(3,I))-XPUP(3))**2
     &                  )*SENS
          ELSE
            C1 =-((XIS(1,I)-XPUP(1))**2
     &           +(YIS(1,I)-XPUP(2))**2
     &           +(ZIS(1,I)-XPUP(3))**2)*SENS
            C2 =-((XIS(2,I)-XPUP(1))**2
     &           +(YIS(2,I)-XPUP(2))**2
     &           +(ZIS(2,I)-XPUP(3))**2)*SENS
            C3 =-((XIS(3,I)-XPUP(1))**2
     &           +(YIS(3,I)-XPUP(2))**2
     &           +(ZIS(3,I)-XPUP(3))**2)*SENS
            C4 =-((XIS(4,I)-XPUP(1))**2
     &           +(YIS(4,I)-XPUP(2))**2
     &           +(ZIS(4,I)-XPUP(3))**2)*SENS
            CENTRMI(N) = MIN(C1,C2,C3,C4)
            CENTRMA(N) = MAX(C1,C2,C3,C4)
            CENTR(N) =-((.25*(XIS(1,I)+XIS(2,I)+XIS(3,I)+XIS(4,I))
     &                  -XPUP(1))**2
     &               +  (.25*(YIS(1,I)+YIS(2,I)+YIS(3,I)+YIS(4,I))
     &                  -XPUP(2))**2
     &               +  (.25*(ZIS(1,I)+ZIS(2,I)+ZIS(3,I)+ZIS(4,I))
     &                  -XPUP(3))**2
     &                  )*SENS
          ENDIF
        ENDIF
      ENDDO
      END
C=======================================================================
      SUBROUTINE PROFLE(VIVI,N,NN,I)
      DIMENSION VIVI(2)
C
      INCLUDE 'com_coor.f'
      INCLUDE 'com_faces.f'
      INCLUDE 'com_options.f'
      DATA US3 / .3333333333333333 /
C
      SENS = REAL(ISENS)
      FACFAC = (BX+BY+BZ)*.2
      VX = VITF(1,I,NN)
      VY = VITF(2,I,NN)
      VZ = VITF(3,I,NN)
      VINOR = SQRT(VX**2+VY**2+VZ**2)
      IF (VINOR.NE.0.) THEN
        RENOR = FACFAC/VINOR
        USREN = VINOR/FACFAC
        IF (IVIT.EQ.-1) THEN
          APX = XF(I,NN)
          APY = YF(I,NN)
          APZ = ZF(I,NN)
          APXP = XX(I,N)
          APYP = YY(I,N)
        ELSE
          IF (NDS.EQ.3) THEN
            APX = (XF(1,NN)+XF(2,NN)+XF(3,NN))*US3
            APY = (YF(1,NN)+YF(2,NN)+YF(3,NN))*US3
            APZ = (ZF(1,NN)+ZF(2,NN)+ZF(3,NN))*US3
          ELSE
            APX = (XF(1,NN)+XF(2,NN)+XF(3,NN)+XF(4,NN))*.25
            APY = (YF(1,NN)+YF(2,NN)+YF(3,NN)+YF(4,NN))*.25
            APZ = (ZF(1,NN)+ZF(2,NN)+ZF(3,NN)+ZF(4,NN))*.25
          ENDIF
          CALL PROJEC(APX,APY,APZ,SENS,APXP,APYP,IPERSP,XPUP,DIST)
        ENDIF
        VVX = APX+(ROTA(1,1)*VX+ROTA(1,2)*VY+ROTA(1,3)*VZ)*RENOR
        VVY = APY+(ROTA(2,1)*VX+ROTA(2,2)*VY+ROTA(2,3)*VZ)*RENOR
        VVZ = APZ+(ROTA(3,1)*VX+ROTA(3,2)*VY+ROTA(3,3)*VZ)*RENOR
        CALL PROJEC(VVX,VVY,VVZ,SENS,VIVI(1),VIVI(2),IPERSP,XPUP,DIST)
        VIVI(1) = (VIVI(1)-APXP)*USREN
        VIVI(2) = (VIVI(2)-APYP)*USREN
      ELSE
        VIVI(1) = 0.
        VIVI(2) = 0.
      ENDIF
      END
C=======================================================================
      SUBROUTINE PROBOI(XC,YC,ZC)
C
      INCLUDE 'com_coor.f'
      INCLUDE 'com_faces.f'
      INCLUDE 'com_options.f'
      REAL*4  XC(8),YC(8),ZC(8)
C
C Boite
C
      CALL ROTATION( BX, BY,-BZ,ROTA,XC(1),YC(1),ZC(1))
      CALL ROTATION(-BX, BY,-BZ,ROTA,XC(2),YC(2),ZC(2))
      CALL ROTATION(-BX,-BY,-BZ,ROTA,XC(3),YC(3),ZC(3))
      CALL ROTATION( BX,-BY,-BZ,ROTA,XC(4),YC(4),ZC(4))
      CALL ROTATION( BX, BY, BZ,ROTA,XC(5),YC(5),ZC(5))
      CALL ROTATION(-BX, BY, BZ,ROTA,XC(6),YC(6),ZC(6))
      CALL ROTATION(-BX,-BY, BZ,ROTA,XC(7),YC(7),ZC(7))
      CALL ROTATION( BX,-BY, BZ,ROTA,XC(8),YC(8),ZC(8))
C
      SENS = REAL(ISENS)
      DO I=1,8
        CALL PROJEC(XC(I),YC(I),ZC(I),SENS,XBOITE(I),YBOITE(I)
     &             ,IPERSP,XPUP,DIST)
      ENDDO
      END     
C=======================================================================
      SUBROUTINE METLAPERSP
      INCLUDE 'com_options.f'
C
      IF (IPERSP.EQ.-1) THEN
        DIST = 2.*DIST0
      ELSEIF(IPERSP.EQ.-2) THEN
        DIST = DIST0
      ELSEIF(IPERSP.EQ.-3) THEN
        DIST = .6*DIST0
      ENDIF
      IF (IPERSP.LT.0) THEN
        XPUP(1) = DIST
        XPUP(2) = DIST
        XPUP(3) = DIST
      ENDIF
      END     
C=======================================================================
      SUBROUTINE METLALIGHT
      INCLUDE 'com_faces.f'
      INCLUDE 'com_options.f'
      DATA USR2 / 0.707106781186548 /
      DATA USR3 / 0.577350269189626 /
C
      IF (IDIRL.EQ.0) THEN
        DIRLUM(1) = USR2
        DIRLUM(2) = 0.
        DIRLUM(3) = USR2
      ELSEIF(IDIRL.EQ.1) THEN
        DIRLUM(1) = 0.
        DIRLUM(2) = USR2
        DIRLUM(3) = USR2
      ELSEIF(IDIRL.EQ.2) THEN
        DIRLUM(1) = USR2
        DIRLUM(2) = USR2
        DIRLUM(3) = 0.
      ELSEIF(IDIRL.EQ.3) THEN
        DIRLUM(1) = 0.
        DIRLUM(2) = 1.
        DIRLUM(3) = 0.
      ELSEIF(IDIRL.EQ.4) THEN
        DIRLUM(1) = 0.
        DIRLUM(2) = 0.
        DIRLUM(3) = 1.
      ELSEIF(IDIRL.EQ.5) THEN
        DIRLUM(1) = 1.
        DIRLUM(2) = 0.
        DIRLUM(3) = 0.
      ELSE
        DIRLUM(1) = USR3
        DIRLUM(2) = USR3
        DIRLUM(3) = USR3
      ENDIF
      END
