Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PlaneNorm.f90
Go to the documentation of this file.
1 !*********************************************************************
2 !* Illinois Open Source License *
3 !* *
4 !* University of Illinois/NCSA *
5 !* Open Source License *
6 !* *
7 !* Copyright@2008, University of Illinois. All rights reserved. *
8 !* *
9 !* Developed by: *
10 !* *
11 !* Center for Simulation of Advanced Rockets *
12 !* *
13 !* University of Illinois *
14 !* *
15 !* www.csar.uiuc.edu *
16 !* *
17 !* Permission is hereby granted, free of charge, to any person *
18 !* obtaining a copy of this software and associated documentation *
19 !* files (the "Software"), to deal with the Software without *
20 !* restriction, including without limitation the rights to use, *
21 !* copy, modify, merge, publish, distribute, sublicense, and/or *
22 !* sell copies of the Software, and to permit persons to whom the *
23 !* Software is furnished to do so, subject to the following *
24 !* conditions: *
25 !* *
26 !* *
27 !* @ Redistributions of source code must retain the above copyright *
28 !* notice, this list of conditions and the following disclaimers. *
29 !* *
30 !* @ Redistributions in binary form must reproduce the above *
31 !* copyright notice, this list of conditions and the following *
32 !* disclaimers in the documentation and/or other materials *
33 !* provided with the distribution. *
34 !* *
35 !* @ Neither the names of the Center for Simulation of Advanced *
36 !* Rockets, the University of Illinois, nor the names of its *
37 !* contributors may be used to endorse or promote products derived *
38 !* from this Software without specific prior written permission. *
39 !* *
40 !* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
41 !* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
42 !* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
43 !* NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR *
44 !* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
45 !* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
46 !* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
47 !* USE OR OTHER DEALINGS WITH THE SOFTWARE. *
48 !*********************************************************************
49 !* Please acknowledge The University of Illinois Center for *
50 !* Simulation of Advanced Rockets in works and publications *
51 !* resulting from this software or its derivatives. *
52 !*********************************************************************
53 subroutine planenorm ( x1, y1, z1, x2, y2, z2, x3, y3, z3, xn, yn, &
54  zn,same )
55 !
56 !*******************************************************************************
57 !
58 !! PLANE_EXP_NORMAL_3D finds the normal to an explicit plane in 3D.
59 !
60 !
61 ! Definition:
62 !
63 ! The explicit form of a plane in 3D is
64 !
65 ! (X1,Y1,Z1), (X2,Y2,Z2), (X3,Y3,Z3).
66 !
67 ! Modified:
68 !
69 ! 16 April 1999
70 !
71 ! Author:
72 !
73 ! John Burkardt
74 !
75 ! Parameters:
76 !
77 ! Input, REAL*8 :: X1, Y1, Z1, X2, Y2, Z2, X3, Y3, Z3, the coordinates
78 ! of three points that constitute a line. These points should not
79 ! be identical, nor colinear.
80 !
81 ! Output, REAL*8 :: XN, YN, ZN, the coordinates of the unit normal
82 ! vector to the plane containing the three points.
83 !
84  implicit none
85 !
86  REAL*8 :: temp
87  REAL*8 :: x1
88  REAL*8 :: x2
89  REAL*8 :: x3
90  REAL*8 :: xn
91  REAL*8 :: y1
92  REAL*8 :: y2
93  REAL*8 :: y3
94  REAL*8 :: yn
95  REAL*8 :: z1
96  REAL*8 :: z2
97  REAL*8 :: z3
98  REAL*8 :: zn
99  integer :: same
100  REAL*8 :: tol = 1.0e-10
101 
102  same = 0
103 
104 !
105 ! The cross product (P2-P1) x (P3-P1) is a vector normal to
106 ! (P2-P1) and (P3-P1).
107 !
108  call cross0_3d( x1, y1, z1, x2, y2, z2, x3, y3, z3, xn, yn, zn )
109 
110  temp = sqrt( xn * xn + yn * yn + zn * zn )
111 
112  if ( temp .LE. tol) then
113  xn = 0.d0
114  yn = 0.d0
115  zn = 0.d0
116  same = 1
117  else
118  xn = xn / temp
119  yn = yn / temp
120  zn = zn / temp
121  end if
122 
123  return
124 end
125 subroutine cross0_3d ( x0, y0, z0, x1, y1, z1, x2, y2, z2, x3, y3, z3 )
126 !
127 !*******************************************************************************
128 !
129 !! CROSS0_3D computes the cross product of (P1-P0) and (P2-P0) in 3D.
130 !
131 !
132 ! Discussion:
133 !
134 ! The vectors are specified with respect to a basis point P0.
135 ! We are computing the normal to the triangle (P0,P1,P2).
136 !
137 ! Modified:
138 !
139 ! 19 April 1999
140 !
141 ! Author:
142 !
143 ! John Burkardt
144 !
145 ! Parameters:
146 !
147 ! Input, real X0, Y0, Z0, X1, Y1, Z1, X2, Y2, Z2, the coordinates of
148 ! three points. The basis point is (X0,Y0,Z0).
149 !
150 ! Output, real X3, Y3, Z3, the cross product (P1-P0) x (P2-P0), or
151 ! (X1-X0,Y1-Y0,Z1-Z0) x (X2-X0,Y2-Y0,Z2-Z0).
152 !
153  implicit none
154 !
155  REAL*8 :: x0
156  REAL*8 :: x1
157  REAL*8 :: x2
158  REAL*8 :: x3
159  REAL*8 :: y0
160  REAL*8 :: y1
161  REAL*8 :: y2
162  REAL*8 :: y3
163  REAL*8 :: z0
164  REAL*8 :: z1
165  REAL*8 :: z2
166  REAL*8 :: z3
167 !
168  x3 = ( y1 - y0 ) * ( z2 - z0 ) - ( z1 - z0 ) * ( y2 - y0 )
169  y3 = ( z1 - z0 ) * ( x2 - x0 ) - ( x1 - x0 ) * ( z2 - z0 )
170  z3 = ( x1 - x0 ) * ( y2 - y0 ) - ( y1 - y0 ) * ( x2 - x0 )
171 
172  return
173 end
174 
175 function calcoffset ( x1, y1, z1, x2, y2, z2 )
176 !
177 !*******************************************************************************
178 !
179 !! DOT_3D computes the dot product of a pair of vectors in 3D.
180 !
181 !
182 ! Modified:
183 !
184 ! 19 April 1999
185 !
186 ! Author:
187 !
188 ! John Burkardt
189 !
190 ! Parameters:
191 !
192 ! Input, real X1, Y1, Z1, X2, Y2, Z2, the coordinates of the vectors.
193 !
194 ! Output, real DOT_3D, the dot product.
195 !
196  implicit none
197 !
198  REAL*8 :: calcoffset
199  REAL*8 :: x1
200  REAL*8 :: x2
201  REAL*8 :: y1
202  REAL*8 :: y2
203  REAL*8 :: z1
204  REAL*8 :: z2
205 !
206  calcoffset = x1 * x2 + y1 * y2 + z1 * z2
207 
208  return
209 end
210 
211 function offset ( vNorm, x2, y2, z2 )
212 !
213 !*******************************************************************************
214 !
215 !! DOT_3D computes the dot product of a pair of vectors in 3D.
216 !
217 !
218 ! Modified:
219 !
220 ! 19 April 1999
221 !
222 ! Author:
223 !
224 ! John Burkardt
225 !
226 ! Parameters:
227 !
228 ! Input, real X1, Y1, Z1, X2, Y2, Z2, the coordinates of the vectors.
229 !
230 ! Output, real DOT_3D, the dot product.
231 !
232  implicit none
233 !
234  REAL*8 :: offset
235  real*8, dimension(1:3) :: vnorm
236  REAL*8 :: x2
237  REAL*8 :: y2
238  REAL*8 :: z2
239 !
240  offset = vnorm(1) * x2 + vnorm(2) * y2 + vnorm(3) * z2
241 
242  return
243 end
244 
real *8 function calcoffset(x1, y1, z1, x2, y2, z2)
Definition: PlaneNorm.f90:175
double sqrt(double d)
Definition: double.h:73
real *8 function offset(vNorm, x2, y2, z2)
Definition: PlaneNorm.f90:211
subroutine planenorm(x1, y1, z1, x2, y2, z2, x3, y3, z3, xn, yn, zn, same)
Definition: PlaneNorm.f90:53
subroutine zn(P, qr, To, Ts, Toa, rb, fr)
subroutine cross0_3d(x0, y0, z0, x1, y1, z1, x2, y2, z2, x3, y3, z3)
Definition: PlaneNorm.f90:125