Re: Strange behavior of POLYFILL [message #77709] |
Thu, 22 September 2011 05:28  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Xavi Llort writes:
> I have to calculate this for ~1.E6 different polygons in less than 4
> minutes and all analytical solutions do not fulfill the benchmark.
> POLYFILLV does, but giving a wrong answer!!
Yes, the price of speed! :-)
Ronn Kling had an analytical solution that could do
many points at once and I believe was fast. I can't
find it now, and I'm just leaving the office for a
few days. You might check on Ronn's web page:
http://www.kilvarock.com
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
|
|
Re: Strange behavior of POLYFILL [message #77735 is a reply to message #77731] |
Wed, 21 September 2011 02:11   |
Xavi Llort
Messages: 15 Registered: September 2006
|
Junior Member |
|
|
I was meaning POLYFILLV instead of POLYFILL, sorry!
And by the way, I tested on 2 machines:
IDL> help, !version,/str
** Structure !VERSION, 8 tags, length=104, data length=100:
ARCH STRING 'x86_64'
OS STRING 'linux'
OS_FAMILY STRING 'unix'
OS_NAME STRING 'linux'
RELEASE STRING '8.0'
BUILD_DATE STRING 'Jun 18 2010'
MEMORY_BITS INT 64
FILE_OFFSET_BITS
INT 64
IDL> help, !version, /str
** Structure !VERSION, 8 tags, length=76, data length=76:
ARCH STRING 'i386'
OS STRING 'darwin'
OS_FAMILY STRING 'unix'
OS_NAME STRING 'Mac OS X'
RELEASE STRING '7.0'
BUILD_DATE STRING 'Oct 25 2007'
MEMORY_BITS INT 32
FILE_OFFSET_BITS
INT 64
|
|
|
Re: Strange behavior of POLYFILL [message #77793 is a reply to message #77709] |
Fri, 23 September 2011 02:48   |
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
|
|
|
Re: Strange behavior of POLYFILL [message #77904 is a reply to message #77793] |
Tue, 27 September 2011 06:06  |
Xavi Llort
Messages: 15 Registered: September 2006
|
Junior Member |
|
|
Dear all again,
I've tested massively the POLYFILLV against Ronn Kling's routine and
Polyfillv is preforming quite a lot of errors...
I wonder if there is a way to report it to ITT, does anyone know how
to do it?
Maybe it can be corrected for future versions and we will have the
wonderful the exactness of Ronn's routine with the speed of
Polyfillv...
Thanks,
Xavi
|
|
|