Debian Codegraph @

packages/seacas/applications/blot/cutrot.f

raw
1 C Copyright(C) 1999-2020 National Technology & Engineering Solutions
2 C of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
3 C NTESS, the U.S. Government retains certain rights in this software.
4 C
5 C See packages/seacas/LICENSE for details
6
7 C=======================================================================
8 SUBROUTINE CUTROT (CUTPLA, CUTMAT, *)
9 C=======================================================================
10
11 C --*** CUTROT *** (MESH) Get rotation matrix for cut
12 C -- Written by Amy Gilkey - revised 07/03/86
13 C --
14 C --CUTROT makes up the rotation matrix that will rotate the mesh
15 C --along the cutting plane.
16 C --
17 C --Parameters:
18 C -- CUTPLA - IN - the 3 points defining the cutting plane;
19 C -- CUTPLA(1,i) is the x coordinate for point i, etc
20 C -- CUTMAT - OUT - the rotation matrix
21 C -- * - return statement if the 3 points do not define a plane
22
23 REAL CUTPLA(3,3)
24 REAL CUTMAT(3,3)
25
26 X1 = CUTPLA(1,1)
27 Y1 = CUTPLA(2,1)
28 Z1 = CUTPLA(3,1)
29 X2 = CUTPLA(1,2)
30 Y2 = CUTPLA(2,2)
31 Z2 = CUTPLA(3,2)
32 X3 = CUTPLA(1,3)
33 Y3 = CUTPLA(2,3)
34 Z3 = CUTPLA(3,3)
35
36 X12 = SQRT ((X2-X1)**2 + (Y2-Y1)**2 + (Z2-Z1)**2)
37 X13 = SQRT ((X3-X1)**2 + (Y3-Y1)**2 + (Z3-Z1)**2)
38 X23 = SQRT ((X2-X3)**2 + (Y2-Y3)**2 + (Z2-Z3)**2)
39 IF (X12 .EQ. 0.0) GOTO 100
40 X15 = (X12**2 + X13**2 - X23**2) / (2.0*X12)
41 XLAM = (X2-X1) / X12
42 YLAM = (Y2-Y1) / X12
43 ZLAM = (Z2-Z1) / X12
44 X5 = X1 + XLAM*X15
45 Y5 = Y1 + YLAM*X15
46 Z5 = Z1 + ZLAM*X15
47 X35 = SQRT ((X3-X5)**2 + (Y3-Y5)**2 + (Z3-Z5)**2)
48 IF (X35 .EQ. 0.0) GOTO 100
49 XPSI = (X3-X5) / X35
50 YPSI = (Y3-Y5) / X35
51 ZPSI = (Z3-Z5) / X35
52 XNU = YLAM*ZPSI - ZLAM*YPSI
53 YNU = ZLAM*XPSI - XLAM*ZPSI
54 ZNU = XLAM*YPSI - YLAM*XPSI
55
56 CUTMAT(1,1) = XLAM
57 CUTMAT(2,1) = YLAM
58 CUTMAT(3,1) = ZLAM
59 CUTMAT(1,2) = XPSI
60 CUTMAT(2,2) = YPSI
61 CUTMAT(3,2) = ZPSI
62 CUTMAT(1,3) = XNU
63 CUTMAT(2,3) = YNU
64 CUTMAT(3,3) = ZNU
65
66 RETURN
67
68 100 CONTINUE
69 CALL PRTERR ('CMDERR', 'Points do not define a plane')
70 RETURN 1
71 END