home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!pipex!warwick!uknet!cvedg!medusa.prime.com!mrj
- From: mrj@CIS.Prime.COM (Mohammad Reza Jahanbin)
- Newsgroups: comp.graphics
- Subject: Re: Calculating polygon areas
- Summary: Proof of.
- Message-ID: <1992Dec17.154323.17206@medusa.prime.com>
- Date: 17 Dec 92 15:43:23 GMT
- References: <1992Dec16.173613.5737@medusa.prime.com>
- Sender: news@medusa.prime.com
- Reply-To: mrj@CIS.Prime.COM
- Organization: Computervision R&D Ltd
- Lines: 94
-
- In article 5737@medusa.prime.com, mrj@CIS.Prime.COM (Mohammad Reza Jahanbin) writes:
- >
- > There is a more general form of the above:
- >
- > Area = 0.5 \sum_{i=0}^{n} (P_i X P_{i+1})
- >
- > s.t. i+1 = (i+1) mod n i.e. when i = n then P_{i+1} = P_0
- >
- > Where X denotes a vector cross product.
- >
- > This holds for 2-d or 3-d (coplanar), convex or concave, polygons with n+1 vertices
- > P_0,...,P_n. Note, if the Area is negative then the order of points are describing a left handed polygon.
- >
- > The proof is simple. If anyone is interested I'll post it to the net.
-
- Since I have had a number of people asking me for this proof I am posting it:
-
-
- _______
- /. .\
- / . . \ a2
- / .C. \
- Pn /..bn..o..b2..\
- \ . . / P2
- an \ b0 b1. /
- \. ./ a1
- ---------
- P0 a0 P1
-
-
-
- Consider the above polygon with n+1 vertices. The vertices are
- P0...Pn. C is any point inside the polygon such that all vertices are
- "visible" from C.
-
- Assume the polygon is triangulated into n+1 triangles P0P1C, P1P2C,
- ..., PiP(i+1)C, ..., PnP0C. Now the area of the polygon is equal to
- the sum of the areas of triangles. This holds wheather or not the
- polygon is convace or convex, due to the choice of C.
-
-
- Let the area of the ith triangle PiP(i+1)C be Ai. Clearly
-
- Ai = 0.5 * |ai X bi|
- where
- ai = P(i+1) - Pi and (1)
- bi = C - Pi
-
- So the area of the polygon, A(p) is:
-
- A(p) = sum{i=0}^{n} Ai
- = 0.5 * sum{i=0}^{n} (|ai X bi|) (2)
-
- For a coplanar polygon all the vectors ai X bi are in the same direction so
- Eqn.(2) can be written as:
-
- A(p) = 0.5 * |sum{i=0}^{n} (ai X bi)| (2a)
-
-
-
- Using Eqn.(1) and (2a)
-
- sum{i=0}^{n} (ai X bi) = sum{i=0}^{n} (P(i+1) - Pi) X (C - Pi)
- = sum{i=0}^{n} (((P(i+1) - Pi) X C) - (P(i+1) X Pi) + (Pi X Pi))
- \-----/
- =0
- = sum{i=0}^{n} ((P(i+1) - Pi) X C) + sum{i=0}^{n} (Pi X P(i+1)) (3)
- \------------------------------/
- = 0
-
- Note: it can be shown (using Tensor notaion or otherwise) that:
-
- sum{i=0}^{n} ((P(i+1) - Pi) X C) = 0
-
- for a closed polygon.
-
-
- So from (2a) and (3)
-
- A(p) = 0.5 * |sum{i=0}^{n} (Pi X P(i+1))| (4)
-
- Since (4) is independent of C it must hold true for both concave and convex
- polygons.
-
-
-
-
-
- ---
- float o=0.075,h=1.5,T,r,O,l,I;int _,L=80,s=3200;main(){for(;s%L||
- (h-=o,T= -2),s;4 -(r=O*O)<(l=I*I)|++ _==L&&write(1,(--s%L?_<L?--_
- %6:6:7)+"World! \n",1)&&(O=I=l=_=r=0,T+=o /2))O=I*2*O+h,I=l+T-r;}
-
- mohammed.
-