其他分享
首页 > 其他分享> > 计算几何板子

计算几何板子

作者:互联网

struct node{
    double x,y;
};
node a,b,c;
//求两个点之间的长度
double len(node a,node b) {
    double tmp = sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
    return tmp;
}
//给出三个点,求三角形的面积  海伦公式: p=(a+b+c)/2,S=sqrt(p(p-a)(p-b)(p-c))
double Area(node a,node b,node c){
    double lena = len(a,b);
    double lenb = len(b,c);
    double lenc = len(a,c);

    double p = (lena + lenb + lenc) / 2.0;
    double S = sqrt(p * (p - lena) * (p - lenb) * (p - lenc));
    return S;
}
//三角形求每条边对应的圆心角
void Ran() {
    double lena = len(a,b);
    double lenb = len(b,c);
    double lenc = len(a,c);
    double A = acos((lenb * lenb + lenc * lenc - lena * lena) / (2 * lenb * lenc));
    double B = acos((lena * lena + lenc * lenc - lenb * lenb) / (2 * lena * lenc));
    double C = acos((lena * lena + lenb * lenb - lenc * lenc) / (2 * lena * lenb));
}
//求外接圆半径r = a * b * c / 4S 
double R(node a,node b,node c) {
    double lena = len(a,b);
    double lenb = len(b,c);
    double lenc = len(a,c);
    double S = Area(a,b,c);
    double R = lena * lenb * lenc / (4.0 * S);
}

 

标签:lenc,lenb,lena,node,double,len,板子,计算,几何
来源: https://www.cnblogs.com/smallhester/p/11361297.html