subroutine aptvpln (ax, ay, az, bx, by, bz, cx, cy, cz, np, tol, & dx, dy, dz, vlen, nerr) ccbeg. cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc c c SUBROUTINE APTVPLN c c call aptvpln (ax, ay, az, bx, by, bz, cx, cy, cz, np, tol, c & dx, dy, dz, vlen, nerr) c c Version: aptvpln Updated 1990 November 26 10:00. c aptvpln Originated 1989 November 2 14:10. c c Author: Arthur L. Edwards, LLNL, L-298, Telephone (925) 422-4123. c c c Purpose: To find the vector d = (dx, dy, dz) normal to the plane defined c by the three points a = (ax, ay, az), b = (bx, by, bz), and c c = (cx, cy, cz), for each of the np sets of points (a, b, c). c The magnitude vlen of the normal vector "d" is equal to the area c of the parallelopiped for which 3 of the vertices are (a, b, c). c If vlen = 0, the points (a, b, c) are congruent or colinear. c The components of vector "d" will be truncated to zero, if less c than the estimated numerical error in their calculation, based c on tol. Flag nerr indicates any input error, if not zero. c c History: 1990 February 22. Deleted truncation of vector components to c zero based on vector magnitude. c c Input: ax, ay, az, bx, by, bz, cx, cy, cz, np, tol. c c Output: dx, dy, dz, vlen, nerr. c c Glossary: c c ax,ay,az Input The x, y, z coordinates of point "a". Size np. c c bx,by,bz Input The x, y, z coordinates of point "b". Size np. c c cx,cy,cz Input The x, y, z coordinates of point "c". Size np. c c dx,dy,dz Output The x, y, z components of normal vector "d". Size np. c May be truncated to zero, if less than the estimated c numerical error in their calculation. See tol. c c nerr Output Indicates an input error, if not 0. c 1 if np is not positive. c c np Input The number of sets of points (a, b, c) for which the c normal vector "d" is to be calculated. c Must be positive. c c tol Input Numerical tolerance limit for dx, dy, dz. c On Cray computers, recommend 1.e-5 to 1.e-11. c c vlen Output The magnitude of the normal vector "d". Size np. c Zero if points (a, b, c) are congruent or colinear. c cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc ccend. c.... Dimensioned arguments. c---- Coordinate x of input point "a". dimension ax (1) c---- Coordinate y of input point "a". dimension ay (1) c---- Coordinate z of input point "a". dimension az (1) c---- Coordinate x of input point "b". dimension bx (1) c---- Coordinate y of input point "b". dimension by (1) c---- Coordinate z of input point "b". dimension bz (1) c---- Coordinate x of input point "c". dimension cx (1) c---- Coordinate y of input point "c". dimension cy (1) c---- Coordinate z of input point "c". dimension cz (1) c---- Component x of normal vector "d". dimension dx (1) c---- Component y of normal vector "d". dimension dy (1) c---- Component z of normal vector "d". dimension dz (1) c---- Magnitude of normal vector "d". dimension vlen (1) c.... Local variables. c---- Index in arrays. common /laptvpln/ n c---- Estimated error in dx. common /laptvpln/ dxerr c---- Estimated error in dy. common /laptvpln/ dyerr c---- Estimated error in dz. common /laptvpln/ dzerr cbugc***DEBUG begins. cbug 9901 format (/ 'aptvpln finding normal vector to plane', cbug & ' through points:' / cbug & (i3,' ax,ay,az=',1p3e22.14 / cbug & ' bx,by,bz=',1p3e22.14 / cbug & ' cx,cy,cz=',1p3e22.14)) cbug write ( 3, 9901) (n, ax(n), ay(n), az(n), bx(n), by(n), bz(n), cbug & cx(n), cy(n), cz(n), n = 1, np) cbugc***DEBUG ends. c.... Initialize. nerr = 0 c.... Test for input errors. if (np .le. 0) then nerr = 1 go to 210 endif c.... Find the components of the normal vector "d", which is upward from the c.... side of the plane for which points (a, b, c) are counterclockwise. c---- Loop over planes. do 110 n = 1, np dx(n) = az(n) * (cy(n) - by(n)) + bz(n) * (ay(n) - cy(n)) + & cz(n) * (by(n) - ay(n)) dy(n) = ax(n) * (cz(n) - bz(n)) + bx(n) * (az(n) - cz(n)) + & cx(n) * (bz(n) - az(n)) dz(n) = ay(n) * (cx(n) - bx(n)) + by(n) * (ax(n) - cx(n)) + & cy(n) * (bx(n) - ax(n)) c---- End of loop over planes. 110 continue c.... See if components should be tested for numerical error. c---- Test for numerical error. if (tol .gt. 0.0) then c---- Loop over normal vectors. do 120 n = 1, np dxerr = 2.0 * tol * & (abs (az(n) * cy(n)) + abs (az(n) * by(n)) + & abs (bz(n) * ay(n)) + abs (bz(n) * cy(n)) + & abs (cz(n) * by(n)) + abs (cz(n) * ay(n))) if (abs (dx(n)) .lt. dxerr) then dx(n) = 0.0 endif dyerr = 2.0 * tol * & (abs (ax(n) * cz(n)) + abs (ax(n) * bz(n)) + & abs (bx(n) * az(n)) + abs (bx(n) * cz(n)) + & abs (cx(n) * bz(n)) + abs (cx(n) * az(n))) if (abs (dy(n)) .lt. dyerr) then dy(n) = 0.0 endif dzerr = 2.0 * tol * & (abs (ay(n) * cx(n)) + abs (ay(n) * bx(n)) + & abs (by(n) * ax(n)) + abs (by(n) * cx(n)) + & abs (cy(n) * bx(n)) + abs (cy(n) * ax(n))) if (abs (dz(n)) .lt. dzerr) then dz(n) = 0.0 endif c---- End of loop over normal vectors. 120 continue c---- Tested tol. endif c.... Find the magnitudes of the normal vectors. c---- Loop over normal vectors. do 130 n = 1, np vlen(n) = sqrt (dx(n)**2 + dy(n)**2 + dz(n)**2) c---- End of loop over normal vectors. 130 continue cbugc***DEBUG begins. cbug 9902 format (/ 'aptvpln results:' / cbug & (i3,' vlen= ',1pe22.14 / cbug & ' dx,dy,dz=',1p3e22.14)) cbug write ( 3, 9902) (n, vlen(n), dx(n), dy(n), dz(n), n = 1, np) cbugc***DEBUG ends. 210 return c.... End of subroutine aptvpln. (+1 line.) end UCRL-WEB-209832