Oops. I just re-read your message and saw you were trying to integrate a function over a polygon, not calculate its area. I'm sorry I didn't read more carefully. --Paul
On 2/15/07, Paul Lynch <[EMAIL PROTECTED]> wrote: > 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 <[EMAIL PROTECTED]> 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@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. > > > ______________________________________________ R-help@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.