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:
[hidden email]
------------------------------------------------------------------------
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP. Click here to play:
http://sourceforge.net/geronimo.php_______________________________________________
Octave-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/octave-dev