From: <her...@ru...> - 2001-03-22 20:53:27
|
Thank everyone for the quick answers... they helped a lot! - Heriberto Delgado (her...@ru...) -----Original Message----- From: mes...@li... [mailto:mes...@li...]On Behalf Of Stephen J Baker Sent: Jueves, 22 de Marzo de 2001 12:49 p.m. To: io...@cr... Cc: mes...@li... Subject: Re: [Mesa3d-dev] Seriously off-topic question... Oe Thu, 22 Mar 2001 her...@ru... wrote: > > Hello! I'm really sorry if this question bothers you in any way, but it > seems this > is the only place I can ask it and actually receive a reasonable answer. You'd stand a VERY good chance of getting an answer if you posted it to the 'gdalgorithms' list. They *thrive* on questions like this. gda...@li... Subscribe at Sourceforge. > Is there any way I can calculate the area of a triangle defined by his > vertices (x1,y1) - (x2,y2) - (x3,y3) WITHOUT the use of SQRT() in any > part of the formula? Yes. (That was easy!) ...oh - you want to know *HOW* as well...OK. Here are the steps needed to calculate the area of a 2D polygon. It doesn't matter if the polygon is listed in a clockwise or counter-clockwise order, it can be convex or concave, or even self-intersect. /* x & y are arrays containing the x and y coordinates of the polygon vertices. npoints is the number of points in each list. */ double area ( int npoints, double *x, double *y ) { double area = 0.0 ; for ( int i = 0 ; i < npoints ; i++ ) { int ii = (i+1) % npoints ; area += x[i] * y[ii] - x[ii] * y[i] ; } return fabs ( area / 2.0 ) ; } ---- Steve Baker (817)619-2657 (Vox/Vox-Mail) L3Com/Link Simulation & Training (817)619-2466 (Fax) Work: sj...@li... http://www.link.com Home: sjb...@ai... http://web2.airmail.net/sjbaker1 _______________________________________________ Mesa3d-dev mailing list Mes...@li... http://lists.sourceforge.net/lists/listinfo/mesa3d-dev |