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 straighteq3d(col,straight) 20! 21! calculate the equation of the planes through the 22! edges of a triangle and perpendicular to the triangle together 23! with the plane of the triangle itself with 24! (col(1,1),col(2,1),col(3,1)),(col(1,2),col(2,2),col(3,2)), 25! (col(1,3),col(2,3),col(3,3)) 26! as vertices. The equation of the plane through the edge 27! opposite nodet(1) is of the form 28! straight(1)*x+straight(2)*y+straight(3)*z+straight(4)=0, such that the 29! vector (straight(1),straight(2),straight(3)) points outwards; 30! for the edge opposite of nodet(2) the equation is 31! straight(5)*x+straight(6)*y+straight(7)*z+straight(8)=0 and for the edge 32! oppositie of nodet(3) it is 33! straight(9)*x+straight(10)*y+straight(11)*z+straight(12)=0. 34! Here too, the normals 35! (straight(5),straight(6),straight(7)) and 36! (straight(9),straight(10),straight(11)) point 37! outwards of the triangle. The equation of the triangle plane is 38! straight(13)*x+straight(14)*y+straight(15)*z+straight(16)=0 such 39! that the triangle is numbered clockwise when looking in the 40! direction of vector (straight(13),straight(14),straight(15)). 41! 42 implicit none 43! 44 integer i 45! 46 real*8 col(3,3),straight(16),p12(3),p23(3),p31(3),dd 47! 48! 49! 50! sides of the triangle 51! 52 do i=1,3 53 p12(i)=col(i,2)-col(i,1) 54 p23(i)=col(i,3)-col(i,2) 55 p31(i)=col(i,1)-col(i,3) 56 enddo 57! 58! normalized vector normal to the triangle: xn = p12 x p23 59! 60 straight(13)=p12(2)*p23(3)-p12(3)*p23(2) 61 straight(14)=p12(3)*p23(1)-p12(1)*p23(3) 62 straight(15)=p12(1)*p23(2)-p12(2)*p23(1) 63 dd=dsqrt(straight(13)*straight(13)+straight(14)*straight(14)+ 64 & straight(15)*straight(15)) 65 do i=13,15 66 straight(i)=straight(i)/dd 67 enddo 68! 69! p12 x xn 70! 71 straight(9)=p12(2)*straight(15)-p12(3)*straight(14) 72 straight(10)=p12(3)*straight(13)-p12(1)*straight(15) 73 straight(11)=p12(1)*straight(14)-p12(2)*straight(13) 74 dd=dsqrt(straight(9)*straight(9)+straight(10)*straight(10)+ 75 & straight(11)*straight(11)) 76 do i=9,11 77 straight(i)=straight(i)/dd 78 enddo 79! 80! p23 x xn 81! 82 straight(1)=p23(2)*straight(15)-p23(3)*straight(14) 83 straight(2)=p23(3)*straight(13)-p23(1)*straight(15) 84 straight(3)=p23(1)*straight(14)-p23(2)*straight(13) 85 dd=dsqrt(straight(1)*straight(1)+straight(2)*straight(2)+ 86 & straight(3)*straight(3)) 87 do i=1,3 88 straight(i)=straight(i)/dd 89 enddo 90! 91! p31 x xn 92! 93 straight(5)=p31(2)*straight(15)-p31(3)*straight(14) 94 straight(6)=p31(3)*straight(13)-p31(1)*straight(15) 95 straight(7)=p31(1)*straight(14)-p31(2)*straight(13) 96 dd=dsqrt(straight(5)*straight(5)+straight(6)*straight(6)+ 97 & straight(7)*straight(7)) 98 do i=5,7 99 straight(i)=straight(i)/dd 100 enddo 101! 102! determining the inhomogeneous terms 103! 104 straight(12)=-straight(9)*col(1,1)-straight(10)*col(2,1)- 105 & straight(11)*col(3,1) 106 straight(4)=-straight(1)*col(1,2)-straight(2)*col(2,2)- 107 & straight(3)*col(3,2) 108 straight(8)=-straight(5)*col(1,3)-straight(6)*col(2,3)- 109 & straight(7)*col(3,3) 110 straight(16)=-straight(13)*col(1,1)-straight(14)*col(2,1)- 111 & straight(15)*col(3,1) 112! 113 return 114 end 115 116