From: Peter <>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to integration a polynomial on a polygon?
Date: Mon, 22 Dec 2008 12:26:05 -0800 (PST)
Lines: 50
Message-ID: <>
References: <gikgkj$4qp$> <gikgtu$mfv$> 
	<gini8e$3mn$> <giooii$pf5$>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: 1229977565 3926 (22 Dec 2008 20:26:05 GMT)
NNTP-Posting-Date: Mon, 22 Dec 2008 20:26:05 +0000 (UTC)
Injection-Info:; posting-host=; 
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: 
	Gecko/2008120122 Firefox/3.0.5,gzip(gfe),gzip(gfe)
Xref: comp.soft-sys.matlab:508415

On Dec 22, 11:08=A0am, "Roger Stafford"
<> wrote:
> "Roger Stafford" <> wrote in mes=
sage >
> > .....
> > =A0int('y^2*((x1*y2-x2*y1+(x2-x1)*y)/(y2-y1))^4/4','y')
> > .....
> =A0 Peter, when I wrote that expression for the line integral of Q(x,y) =
=3D x^4*y^2/4 from (x1,y1) to (x2,y2) I had in mind still obtaining a close=
d expression in terms of these points' coordinates for use in an exact summ=
ation. =A0As a problem in numerical integration that would not be the right=
 way to proceed. =A0For example, it would blow up if y1 were equal to y2. =
=A0It would be better to write something like this:
> =A0int('Q(x,y)*sin(a12)','s',0,'s12')
> for integration along each segment where s is the length along the segmen=
t with
> =A0s12 =3D sqrt((x2-x1)^2+(y2-y1)^2)
> =A0a12 =3D atan2(y2-y1,x2-x1)H
> =A0x =3D x1 + s*cos(a12)
> =A0y =3D y1 + s*sin(a12)
> =A0dy =3D sin(a12)*ds
> =A0 An analogous numerical line integration procedure exists for polynomi=
als by computing their area integrals in terms of polygon segments projecte=
d triangularly to the origin. =A0As in the case of your Q(x,y), the result =
of the first integration along the projecting lines to the origin is an eas=
ily-found explicit expression. =A0The second integration along the polygona=
l line segments at the far end of these triangles could then be done numeri=
> Roger Stafford

Hi, Roger.

I understood the original question to be asking for a numerical
evaluation of the integral, not a closed-form symbolic solution.  The
Q polynomial coefficients could be calculated automatically by the
user's own code (no toolbox required), and their contributions along
each edge would be summed numerically inside of a loop over the edges,
again without requiring any external toolbox.  Certainly things get a
lot more complicated if you want an explicit formula derived in terms
of the polygon vertex locations.  I guess I was misleading when I
referred to the "formulas", by which I meant the formulas (finite
sums) needed for obtaining a numerical result.