PROGRAM LABCOORD C========================================================================== C C Programmer: Andrew Dainis 5-DEC-88 C C This program will calculate the X,Y coordinates of four points given the C the six distances between the points which are assumed to lie in a plane. C Point 1 is made the coordinate system origin, and point 2 is placed on the C Y-axis. The measurements S12, S13, S14, S23, S24, S34 are assumed to be C entered in that order and the first five are used to compute the point C coordinates. The sixth distance is computed from the first five, and C should agree with the measured distance between points 3 and 4. C Points are order clockwise. C=========================================================================== C WRITE(*,*) ' POINTS ARE ORDERED CLOCKWISE' WRITE(*,*) ' ' WRITE(5,200) 200 FORMAT(' Enter the distance between points 1 and 2 :',$) READ(*,*) S12 WRITE(5,203) 203 FORMAT(' Enter the distance between points 2 and 3 :',$) READ(*,*) S23 WRITE(5,205) 205 FORMAT(' Enter the distance between points 3 and 4 :',$) READ(*,*) S34 WRITE(5,202) 202 FORMAT(' Enter the distance between points 4 and 1 :',$) READ(*,*) S14 WRITE(5,201) 201 FORMAT(' Enter the distance between points 1 and 3 :',$) READ(*,*) S13 WRITE(5,204) 204 FORMAT(' Enter the distance between points 2 and 4 :',$) READ(*,*) S24 C PI=3.14159 A=(S12**2+S14**2-S24**2)/(2.*S12*S14) W=ACOS(A) IF(A.LT.0) W=PI-W ! > 90 degrees W=PI/2.-W X4=S14*COS(W) Y4=S14*SIN(W) IF(A.LT.0) Y4=-Y4 C A=(S12**2+S23**2-S13**2)/(2.*S12*S23) W=ACOS(A) IF(A.LT.0) W=PI-W W=W-PI/2. X3=S23*COS(W) Y3=S12+S23*SIN(W) IF(A.LT.0) Y3=S12-S23*SIN(W) C CS34=SQRT((X4-X3)**2+(Y4-Y3)**2) C WRITE(*,*) ' ' WRITE(5,100) 0.0,0.0 100 FORMAT(' Point 1 is located at ',2F10.4) WRITE(5,101) 0.0,S12 101 FORMAT(' Point 2 is located at ',2F10.4) WRITE(5,102) X3,Y3 102 FORMAT(' Point 3 is located at ',2F10.4) WRITE(5,103) X4,Y4 103 FORMAT(' Point 4 is located at ',2F10.4) WRITE(*,*) ' ' WRITE(5,104) CS34-S34 104 FORMAT(' Calculated distance points 3 to 4 is longer than the', * /' measured distance by ',F8.4) END