[R] integrate over polygon

Paul Lynch plynchnlm at gmail.com
Thu Feb 15 23:30:14 CET 2007


I'm still pretty ignorant about R, but I think it might be possible to
work out an algorithm using  cross products.  First you would want to
subdivide the polygon into convex polygons.  I haven't tried to do
that before, but it looks like it might be possible by looking at the
sign of cross products of vectors between vertices.  (In other words,
pick a vertex, and then start working your way around the polygon and
pay attention to the sign of cross products of vectors from the
starting vertex to successive vertices.)  Once you have convex
polygons, you can calculate the area using cross products of vectors
from some point (e.g. the origin) to adjacent vertices of the polygon.
 I think that probably most computer graphics texts would have such an
algorithm.

How to implement that in R is not something I can answer, but it
doesn't sound hard.
       --Paul

On 2/14/07, Haiyong Xu <xuhy at ucla.edu> wrote:
> Hi there,
>
> I want to integrate a function over an irregular polygon. Is there
> any function which can implement this easily? Otherwise, I am
> thinking of divide the polygon into very small rectangles and use
> "adapt" to approximate it. Do you have any suggestions to get the
> fine division? Any advice is appreciated.
>
> Haiyong
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list