三点坐标求三角形面积(数学)

 1 struct point{double x, y;}p[105];
 2 
 3 double xmult(point p1,point p2,point p0)
 4 {
 5     return (p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y);
 6 }
 7 
 8 double area_triangle(point p1,point p2,point p3)
 9 {
10     return fabs(xmult(p1,p2,p3))/2;
11 }
12 
13 for(int i = 0; i < m; i++)
14         {
15             for(int j = 0; j < m; j++)
16             {
17                 for(int k = 0; k < m; k++)
18                 {
19                     S = area_triangle(p[i],p[j],p[k]);
20                 }
21             }
22         }
View Code

 

posted @ 2013-09-08 14:13  GLSilence  阅读(555)  评论(0编辑  收藏  举报