1! 2! CalculiX - A 3-dimensional finite element program 3! Copyright (C) 1998-2021 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! S.W. Sloan, Adv.Eng.Software,1987,9(1),34-55. 20! Permission for use with the GPL license granted by Prof. Scott 21! Sloan on 17. Nov. 2013 22! 23 function swap(x1,y1,x2,y2,x3,y3,xp,yp) 24! 25 implicit none 26! 27 real*8 x1,y1,x2,y2,x3,y3,xp,yp,x13,y13,x23,y23, 28 & x1p,y1p,x2p,y2p,cosa,cosb,sina,sinb,c00000 29! 30 logical swap 31! 32 parameter(c00000=0.d0) 33! 34 x13=x1-x3 35 y13=y1-y3 36 x23=x2-x3 37 y23=y2-y3 38 x1p=x1-xp 39 y1p=y1-yp 40 x2p=x2-xp 41 y2p=y2-yp 42 cosa=x13*x23+y13*y23 43 cosb=x2p*x1p+y1p*y2p 44 if((cosa.ge.c00000).and.(cosb.ge.c00000)) then 45 swap=.false. 46 elseif((cosa.lt.c00000).and.(cosb.lt.c00000)) then 47 swap=.true. 48 else 49 sina=x13*y23-x23*y13 50 sinb=x2p*y1p-x1p*y2p 51 if((sina*cosb+sinb*cosa).lt.c00000) then 52 swap=.true. 53 else 54 swap=.false. 55 end if 56 end if 57 end 58