1!
2!     CalculiX - A 3-dimensional finite element program
3!              Copyright (C) 1998 Guido Dhondt
4!
5!     This program is free software; you can redistribute it and/or
6!     modify it under the terms of the GNU General Public License as
7!     published by the Free Software Foundation(version 2);
8!
9!
10!     This program is distributed in the hope that it will be useful,
11!     but WITHOUT ANY WARRANTY; without even the implied warranty of
12!     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13!     GNU General Public License for more details.
14!
15!     You should have received a copy of the GNU General Public License
16!     along with this program; if not, write to the Free Software
17!     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18!
19      subroutine planeeq(cotet,nodef,planfal)
20!
21!     calculate the equation of a plane through the points nodef(1),
22!     nodef(2) and nodef(3). The equation of the plane is
23!     planfal(1)*x+planfal(2)*y+planfal(3)*z+planfal(4)=0; the
24!     coordinates of the nodes are stored in cotet
25!
26!     the vector (planefal(1),planfal(2),planfal(3)) is orthogonal
27!     to the plane and is normalized
28!
29      implicit none
30!
31      integer nodef(3)
32      real*8 cotet(3,*),planfal(4),x1,y1,z1,x2,y2,z2,dd
33!
34      x1=cotet(1,nodef(1))-cotet(1,nodef(2))
35      y1=cotet(2,nodef(1))-cotet(2,nodef(2))
36      z1=cotet(3,nodef(1))-cotet(3,nodef(2))
37!
38      x2=cotet(1,nodef(1))-cotet(1,nodef(3))
39      y2=cotet(2,nodef(1))-cotet(2,nodef(3))
40      z2=cotet(3,nodef(1))-cotet(3,nodef(3))
41!
42      planfal(1)=y1*z2-y2*z1
43      planfal(2)=x2*z1-x1*z2
44      planfal(3)=x1*y2-x2*y1
45!
46      dd=dsqrt(planfal(1)*planfal(1)+planfal(2)*planfal(2)+
47     &         planfal(3)*planfal(3))
48!
49      if(dd.lt.1.d-10) then
50         planfal(1)=0.d0
51         planfal(2)=0.d0
52         planfal(3)=0.d0
53         planfal(4)=0.d0
54         return
55      endif
56!
57      planfal(1)=planfal(1)/dd
58      planfal(2)=planfal(2)/dd
59      planfal(3)=planfal(3)/dd
60!
61      planfal(4)=-(planfal(1)*cotet(1,nodef(1))+
62     &             planfal(2)*cotet(2,nodef(1))+
63     &             planfal(3)*cotet(3,nodef(1)))
64!
65      return
66      end
67
68