原
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。
暴力
S=12ah海伦公式
S=p(p−a)(p−b)(p−c)−−−−−−−−−−−−−−−−−√p=a+b+c2正弦定理
S=12absinC=abc4R焦点三角形
椭圆
S=b2tanθ2双曲线
S=b2tanθ2叉积
S=12a⃗×b⃗=12(x1y2−x2y1)S=12∣∣∣∣∣∣∣∣ix1x2jy1y2kz1z2∣∣∣∣∣∣∣∣
PS:数学老师窝对不起您。。。
#include#include#include#include#define D double using namespace std; structpoint { D x,y,z;point (D xx =0,D yy =0,D zz =0) {x = xx,y = yy,z = zz;};point operator - (constpoint &t) {returnpoint(x - t.x,y - t.y,z - t.z);}; }A,B,C,F; Dlength(D x,D y,D z) {returnsqrt(x * x + y * y + z * z); } D S(point A,point B,point C) {point U = B - A,DD = C - A;returnlength(U.y * DD.z - U.z * DD.y,- U.x * DD.z + U.z * DD.x,U.x * DD.y - U.y * DD.x); } int main() { A = (point){4,0,3}; B = (point){0,0,0}; F = (point){0,5,0}; C = (point){4,5,0}; D S1 = S(A,B,C),S2 = S(A,B,F),S3 = S(A,F,C),S4 = S(B,F,C);printf ("%0.2f %0.2f %0.2f %0.2f\n",S1,S2,S3,S4); }
//二维的情况,假设三个顶点坐标分别为(x[i],y[i]),(x[j],y[j]),(x[k],y[k])doubleareaTri_2dimension(i