function Inside_Wedge, p_box, p, exclude_p_box=exclude_p_box @compile_opt.pro ; On error, return to caller ;+ ; NAME: ; Inside_Wedge ; PURPOSE: ; Tests whether image locations are inside a wedge ; CATEGORY: ; CALLING SEQUENCE: ; result = Inside_Wedge(p_box,p) ; INPUTS: ; p_box array[2,2]; type: float ; two opposite corners of the wedge in polar coordinates ; in the form [ [angle1,radius1],[angle2,radius2] ] ; p array[2,n,m,...]; type: float ; image locations in polar coordinates ; (same form as p_box) ; OPTIONAL INPUT PARAMETERS: ; exclude_p_box=exclude_p_box ; array[2,2]; type: float ; two opposite corners of another wedge in polar coordinates ; in the form [ [angle1,radius1],[angle2,radius2] ] ; This second wedge must lie entirely inside the first one. ; If specified the coordinate array p is tested for inside ; p_box and outside exclude_p_box. ; OUTPUTS: ; result array[n,m,...]; type: byte ; 0 for locations p outside the wedge ; 1 for locations inside the wedge ; CALLS: ; SubArray, IsType ; RESTRICTIONS: ; If p contains !values.f_nan the value 1 is returned ; PROCEDURE: ; > Formerly called qImage_cw_WTest ; > The array p can have more than two dimensions, e.g. [2,n,m]. ; MODIFICATION HISTORY: ; FEB-2000, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ;- p0 = SubArray(p, element=0) p1 = SubArray(p, element=1) case IsType(exclude_p_box, /defined) of 0: begin if p_box[2] ge p_box[0] then $ return, p_box[1] le p1 and p1 le p_box[3] and $ p_box[0] le p0 and p0 le p_box[2] $ else $ return, p_box[1] le p1 and p1 le p_box[3] and $ p_box[0] le p0 or p0 le p_box[2] end 1: begin q_box = exclude_p_box if p_box[2] ge p_box[0] then $ return, (p_box[1] le p1 and p1 le p_box[3] and $ p_box[0] le p0 and p0 le p_box[2]) and $ (q_box[1] gt p1 or p1 gt q_box[3] or $ q_box[0] gt p0 or p0 gt q_box[2]) $ else $ return, ((p_box[1] le p1 and p1 le p_box[3]) and $ (p_box[0] le p0 or p0 le p_box[2])) and $ ((q_box[1] gt p1 or p1 gt q_box[3]) or $ (q_box[0] gt p0 and p0 gt q_box[2])) end endcase end