C  SUBROUTINE TO MAP AN OBJECT FILE ON TO A PICTURE PLANE
C  USING MATRICES CALCULATED FROM SUBROUTINE ROTER
C			BY DR. J.A.FIELD
C			   DEPT. OF ELECTRICAL ENGINEERING
C
          SUBROUTINE MAPPER(DIST)
          LOGICAL SWITCH, FIRST
          COMMON/GRXPQK/S11,S12,S13,S21,S22,S23,S31,S32,S33,T11,
          9T21,T31
          COMMON/BULK/I3STRT,I3END,OBJECT(6,60)
          COMMON/PAINT/I2STRT,I2END,PICT(4,60)
C 
          DATA BOUND/1.0E75/
C
C  CALCULATE ROTATED POINTS FROM OBJECT AND PLACE IN PICT
          JJ=I2STRT
          DO 100 J=I3STRT,I3END
          TEMPX=OBJECT(1,J)*S11+OBJECT(2,J)*S12+OBJECT(3,J)
          7*S13+T11
          TEMPY=OBJECT(1,J)*S21+OBJECT(2,J)*S22+OBJECT(3,J)*
          7S23+T21
          TEMPZ=OBJECT(1,J)*S31+OBJECT(2,J)*S32+OBJECT(3,J)*
          7S33+T31
          TEMPX2=OBJECT(4,J)*S11+OBJECT(5,J)*S12+OBJECT(6,J)*S13+T11
          TEMPY2=OBJECT(4,J)*S21+OBJECT(5,J)*S22+OBJECT(6,J)*S23+T21
          TEMPZ2=OBJECT(4,J)*S31+OBJECT(5,J)*S32+OBJECT(6,J)*S33+T31
C
C  GET VALUE IN PICTURE PLANE BY USING RATIO OF DISTANCES IN
C  Z DIRECTION (DISTANCE FROM EYE POINT TO PICTURE PLANE)
C
          IF(TEMPZ)3,3,1
3         IF(TEMPZ2)100,100,2
2         BIN=TEMPZ
          TEMPZ=TEMPZ2
          TEMPZ2=BIN
          BIN=TEMPX
          TEMPX=TEMPX2
          TEMPX2=BIN
          BIN=TEMPY
          TEMPY=TEMPY2
          TEMPY2=BIN
1         BIN=DIST/TEMPZ
          PICT(1,JJ)=TEMPX*BIN
          PICT(2,JJ)=TEMPY*BIN
          IF(TEMPZ2)5,5,4
5         B=BOUND
          XT=TEMPX2*TEMPZ-TEMPX*TEMPZ2
          YT=TEMPY2*TEMPZ-TEMPY*TEMPZ2
          IF(ABS(XT).GT.ABS(YT)) GO TO 7
          IF(YT)8,9,10
8         B=-B
10        PICT(4,JJ)=B
          PICT(3,JJ)=PICT(1,JJ)+(B-PICT(2,JJ))*XT/YT
          GO TO 101
9         PICT(3,JJ)=PICT(1,JJ)
          PICT(4,JJ)=PICT(2,JJ)
          GO TO 101
7         IF(XT)11,9,12
11        B=-B
12        PICT(3,JJ)=B
          PICT(4,JJ)=PICT(2,JJ)+(B-PICT(1,JJ))*YT/XT
          GO TO 101
4         BIN=DIST/TEMPZ2
          PICT(3,JJ)=TEMPX2*BIN
          PICT(4,JJ)=TEMPY2*BIN
101       JJ=JJ+1
100       CONTINUE
          I2END=JJ-1
          RETURN
          END
