On Nov 13, 2005, at 8:00 AM, Dr.-Ing. Torsten Finke wrote:
> 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);
Applied.
Thanks,
- Paul
>
|