summaryrefslogtreecommitdiff
path: root/Dragon/src/XCWREC.f
diff options
context:
space:
mode:
authorstainer_t <thomas.stainer@oecd-nea.org>2025-09-08 13:48:49 +0200
committerstainer_t <thomas.stainer@oecd-nea.org>2025-09-08 13:48:49 +0200
commit7dfcc480ba1e19bd3232349fc733caef94034292 (patch)
tree03ee104eb8846d5cc1a981d267687a729185d3f3 /Dragon/src/XCWREC.f
Initial commit from Polytechnique Montreal
Diffstat (limited to 'Dragon/src/XCWREC.f')
-rw-r--r--Dragon/src/XCWREC.f229
1 files changed, 229 insertions, 0 deletions
diff --git a/Dragon/src/XCWREC.f b/Dragon/src/XCWREC.f
new file mode 100644
index 0000000..8a949ee
--- /dev/null
+++ b/Dragon/src/XCWREC.f
@@ -0,0 +1,229 @@
+*DECK XCWREC
+ SUBROUTINE XCWREC(ANGD,SIDE,TRKPOS,LINTER,ROTPOS,INDS,IMS)
+*
+*-----------------------------------------------------------------------
+*
+*Purpose:
+* Track outer rectangle for 2-D cluster.
+*
+*Copyright:
+* Copyright (C) 1992 Ecole Polytechnique de Montreal
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License as published by the Free Software Foundation; either
+* version 2.1 of the License, or (at your option) any later version
+*
+*Author(s): G.Marleau
+*
+*Parameters: input
+* ANGD track director cosines (cos(a),sin(a)).
+* SIDE side of rectangle.
+* IMS surface merge.
+*
+*Parameters: input/output
+* TRKPOS one track point at input (*,1).
+* Track origin at output (*,1).
+* Track origin at input (*,2).
+*
+*Parameters: output
+* LINTER intersection logical.
+* ROTPOS position wrt rotated axis.
+* INDS surface of intersection.
+*
+*----------------------------------------------------------------------
+*
+ IMPLICIT DOUBLE PRECISION (A-H,O-Z)
+ DOUBLE PRECISION ANGD(2),SIDE(2),TRKPOS(2,2),ROTPOS(2,2)
+ INTEGER IMS(6),INDS(2)
+ LOGICAL LINTER
+*----
+* EQUATIONS FOR SIDES
+* SIDE 1: XR= SIDE(1)/2 (-SIDE(2)/2<=YR<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COSAI=1.0/ANGD(1)
+ SINAI=1.0/ANGD(2)
+*----
+* SLOPEY=TAN(ANGD)
+* SLOPEX=COTAN(ANGD)
+* RINTY=TRKPOS(2,1)-SLOPEY*TRKPOS(1,1)
+* RINTX=TRKPOS(1,1)-SOLPEX*TRKPOS(2,1)
+*----
+ SLOPEY=ANGD(2)*COSAI
+ SLOPEX=ANGD(1)*SINAI
+ RINTY=TRKPOS(2,1)-SLOPEY*TRKPOS(1,1)
+ RINTX=TRKPOS(1,1)-SLOPEX*TRKPOS(2,1)
+*----
+* SURFACE 3: YR=RINTY-SLOPEY*XTOP
+* (-YTOP <=YR<= YTOP)
+*----
+ TRKPOS(2,NSEG)=RINTY-SLOPEY*XTOP
+ IF( ABS(TRKPOS(2,NSEG)).LE.YTOP ) THEN
+*----
+* TRACK INTERSEPT SURFACE 3
+*----
+ INDS(NSEG)=IMS(3)
+ TRKPOS(1,NSEG)=-XTOP
+ NSEG=NSEG+1
+ ENDIF
+*----
+* SURFACE 1: YR=RINTY+SLOPEY*XTOP
+* (-YTOP <=YR<= YTOP)
+*----
+ TRKPOS(2,NSEG)=RINTY+SLOPEY*XTOP
+ IF( ABS(TRKPOS(2,NSEG)).LE.YTOP ) THEN
+*----
+* TRACK INTERSEPT SURFACE 1
+*----
+ INDS(NSEG)=IMS(1)
+ TRKPOS(1,NSEG)=XTOP
+ IF(NSEG.EQ.2) GO TO 100
+ NSEG=NSEG+1
+ ENDIF
+*----
+* SURFACE 4: XR=RINTX-SLOPEX*YTOP
+* (-XTOP <=XR<= XTOP)
+*----
+ TRKPOS(1,NSEG)=RINTX-SLOPEX*YTOP
+ IF( ABS(TRKPOS(1,NSEG)).LE.XTOP ) THEN
+*----
+* TRACK INTERSEPT SURFACE 4
+*----
+ INDS(NSEG)=IMS(4)
+ TRKPOS(2,NSEG)=-YTOP
+ IF(NSEG.EQ.2) GO TO 100
+ NSEG=NSEG+1
+ ENDIF
+*----
+* SURFACE 2: XR=RINTX+SLOPEX*YTOP
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