From: Dr.-Ing. T. F. <fi...@ig...> - 2005-11-13 13:00:45
|
Hello Octave-Forge developers, may I suggest a little improvement to the function polyarea which calculates the area a of a given polygon with vertices (x, y). Now it is calculated as (line 47 of polyarea.m): a = abs ( sum (x .* shift (y,-1)) - sum (y .* shift (x, -1)) ) / 2; Since sum (y .* shift (x, -1)) == sum (shift(y, 1) .* x) one can reduce the amount of summation and multiplication to just the half: a = abs (sum (x .* (shift (y, 1) - shift (y, -1))) / 2); Thank You and best regards Torsten Finke -- ------------------------------------------------------------------------ Dr.-Ing. Torsten Finke Ingenieurgemeinschaft IgH Heinz-Baecker-Str. 34 D-45356 Essen Tel.: +49 201 / 360-14-17 Fax.: +49 201 / 360-14-14 E-mail: tor...@ig... ------------------------------------------------------------------------ |