comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Strange behavior of POLYFILL
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Strange behavior of POLYFILL [message #77793 is a reply to message #77709] Fri, 23 September 2011 02:48 Go to previous messageGo to previous message
Xavi Llort is currently offline  Xavi Llort
Messages: 15
Registered: September 2006
Junior Member
Thank you very much for the alternative!

It works (below there is a piece of code comparing against POLYFILLV),
but the computational is quite high, specially searching in a large
number of points.
In my case (a 1024 by 1024) the overall time goes from ~1.E-5 secs of
POLYFILLV to ~2 secs of Ronn Kling's routine, and I cannot afford.

Is this a bug of POLYFILLV? Does anyone experienced similar problems?

Thanks again for your help,
Xavi Llort


PRO POLY_HELL_2
dim_x = 1024l & dim_y = 1024l
lon_res = 0.02 & lat_res = 0.02
lon_arr = FINDGEN(dim_x)*lon_res - 12.99
lat_arr = FINDGEN(dim_y)*lat_res + 29.53
triangle_xx = [-4.27, -4.3221145, -4.3234300, -4.27]
triangle_yy = [35.449997, 35.535344, 35.365467,35.449997]

;
************************************************************ **********
; POLYFILL calculus
t0 = SYSTIME(/SEC)
xx_n = (triangle_xx - lon_arr[0]) / lon_res +1.
yy_n = (triangle_yy - lat_arr[0]) / lat_res +1.
points_in = POLYFILLV(xx_n, yy_n, dim_x, dim_y )
lap1 = SYSTIME(/SEC) - t0

DEVICE, DEC=0
LOADCT, 5
WINDOW, 0, XSIZE=800, YSIZE=800, TITLE='RESULT WITH POLYFILL'

PLOT, triangle_xx, triangle_yy, PSYM=-4, XR=[-4.39, -4.15], XSTYLE=1,
$
YR=[35.33, 35.57], YSTYLE=1
lon_mat = REBIN(lon_arr, dim_x, dim_y)
lat_mat = REBIN(TRANSPOSE(lat_arr), dim_x, dim_y)
OPLOT, lon_mat, lat_mat, psym=1, SYMSIZE=0.7
OPLOT, lon_mat[points_in], lat_mat[points_in], psym=4, SYMSIZE=1.4,
COLOR=115, THICK=2.

;
************************************************************ **********
; Ron Kling calculus
t1 = SYSTIME(/SEC)
lon_vals = REFORM( REBIN(lon_arr, dim_x, dim_y), dim_x*dim_y)
lat_vals = REFORM( REBIN(TRANSPOSE(lat_arr), dim_x, dim_y),
dim_x*dim_y)
data = TRANSPOSE([[lon_vals],[lat_vals]])
connect = REFORM( INDGEN(3),3,1)
points_in_Kling = pointInsideApolygon (triangle_xx[0:2],
triangle_yy[0:2], connect, data)
lap2 = SYSTIME(/SEC) - t1

WINDOW, 1, XSIZE=800, YSIZE=800, TITLE='RESULT WITH RONN KLING
ROUTINE'
PLOT, triangle_xx, triangle_yy, PSYM=-4, XR=[-4.39, -4.15], XSTYLE=1,
$
YR=[35.33, 35.57], YSTYLE=1
OPLOT, lon_vals, lat_vals, psym=1, SYMSIZE=0.7
OPLOT, lon_vals[points_in_Kling], lat_vals[points_in_Kling], psym=4,
SYMSIZE=1.4, COLOR=115, THICK=2.

PRINT, ' '
PRINT, '*** POLYFILL used ' + STRING(lap1,FORMAT='(E9.3)') + '
seconds'
PRINT, '*** Ronn Kling used ' + STRING(lap2,FORMAT='(E9.3)') + '
seconds'

END
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: IDL 8.1 PostScript Output on a Sheet of Paper
Next Topic: Best way to share 'enum' between various functions

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Nov 29 01:52:04 PST 2025

Total time taken to generate the page: 3.28609 seconds