*============================================================================== * A subroutine to test if a position is within a hole in the 2QZ * Uses the corrected RA, Dec holes with 4 points: * inhol=1 (not in hole) * inhol=0 (in hole) * * SMC 28/02/01 * *############################################################################### * # * LICENCE # * # * This program is free software; you can redistribute it and/or # * modify it under the terms of the GNU General Public License # * as published by the Free Software Foundation; either version 2 # * of the License, or (at your option) any later version. # * # * This program is distributed in the hope that it will be useful, # * but WITHOUT ANY WARRANTY; without even the implied warranty of # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # * GNU General Public License for more details. # * # * You should have received a copy of the GNU General Public License # * along with this program; if not, write to the Free Software # * Foundation, Inc., 59 Temple Place - Suite 330, # * Boston, MA 02111-1307, USA. # * # *############################################################################### * subroutine check_raholes(xx,yy,inhol) implicit none integer inhol,j,nholes double precision raxhole,rayhole,xx,yy,xt,yy11,yy22,yy33,yy44,pi double precision xmin,xmax,ymin,ymax,a1,a2,a3,a4,b1,b2,b3,b4 parameter(pi=3.14592654) logical square * common block to pass the hole coordinates: common /raholes/ raxhole(4,400),rayhole(4,400),nholes *------------------------------------------------------------------------------ inhol = 1 do j = 1,nholes square=.TRUE. * first find the maximum and minimum x,y values: xmin=dmin1(raxhole(1,j),raxhole(2,j),raxhole(3,j),raxhole(4,j)) xmax=dmax1(raxhole(1,j),raxhole(2,j),raxhole(3,j),raxhole(4,j)) ymin=dmin1(rayhole(1,j),rayhole(2,j),rayhole(3,j),rayhole(4,j)) ymax=dmax1(rayhole(1,j),rayhole(2,j),rayhole(3,j),rayhole(4,j)) * check to see if there are negative RA values in the holes. If there * is then subtract 2*pi from the xx value if the xx value is greater * than 1.5*pi. This bit is 2QZ specific, while everything else is * fairly generic: if (ymin.lt.0.0.and.xx.gt.1.5*pi) then xt=xx-2.0*pi else xt=xx end if * if the object is inside the min and max values then continue: if (xt.ge.xmin.and.xt.le.xmax.and.yy.ge.ymin.and.yy.le.ymax) & then * check for a triangular hole: if (rayhole(3,j).eq.rayhole(4,j).and.raxhole(3,j).eq & .raxhole(4,j)) square=.FALSE. * define the parameters of each line and check that the object is on the * same side of the line as one of the other two points that makes up the * hole: * line 1 made from points 1 & 2, so use point 3 * line 2 made from points 1 & 3, so use point 2 * line 3 made from points 2 & 4, so use point 1 * line 4 made from points 3 & 4, so use point 1 a1=(rayhole(2,j)-rayhole(1,j))/(raxhole(2,j)-raxhole(1,j)) a2=(rayhole(3,j)-rayhole(1,j))/(raxhole(3,j)-raxhole(1,j)) a3=(rayhole(4,j)-rayhole(2,j))/(raxhole(4,j)-raxhole(2,j)) b1=rayhole(1,j)-a1*raxhole(1,j) b2=rayhole(1,j)-a2*raxhole(1,j) b3=rayhole(2,j)-a3*raxhole(2,j) yy11=(a1*xt+b1-yy)*(a1*raxhole(3,j)+b1-rayhole(3,j)) yy22=(a2*xt+b2-yy)*(a2*raxhole(2,j)+b2-rayhole(2,j)) yy33=(a3*xt+b3-yy)*(a3*raxhole(1,j)+b3-rayhole(1,j)) if (square) then a4=(rayhole(4,j)-rayhole(3,j))/(raxhole(4,j)-raxhole(3,j) & ) b4=rayhole(3,j)-a4*raxhole(3,j) yy44=(a4*xt+b4-yy)*(a4*raxhole(1,j)+b4-rayhole(1,j)) else yy44=1.0 end if * if all 4 are positive then the object is in a hole: if (yy11.ge.0.0.and.yy22.ge.0.0.and.yy33.ge.0.0.and.yy44.ge & .0.0) then inhol=0 return end if end if end do return end *==============================================================================