三角形相关(数论)

  • 面积
    double x1, x2, x3, y1, y2, y3;
    scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3)
    double a = sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
    double b = sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));
    double c = sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2));

    double p = (a+b+c)/2;
    double s = s=sqrt(p*(p-a)*(p-b)*(p-c));

    printf("%.3lf\n", s);
  • 外心(中垂线交点)
	double x1, x2, x3, y1, y2, y3;
 	scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3)
    double a1=2*(x2-x1);
    double b1=2*(y2-y1);
    double c1=x2*x2+y2*y2-x1*x1-y1*y1;
    
    double a2=2*(x3-x2);
    double b2=2*(y3-y2);
    double c2=x3*x3+y3*y3-x2*x2-y2*y2;
    
    double x=(c1*b2-c2*b1)/(a1*b2-a2*b1);
    double y=(a1*c2-a2*c1)/(a1*b2-a2*b1);
    printf("%.3lf %.3lf\n", x, y);
  • 内心(角平分线交点)
	double x1, x2, x3, y1, y2, y3;
    scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3)
    double A = sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));
    double B = sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));
    double C = sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
    double S = A+B+C;
    double x = (A*x1+B*x2+C*x3)/S;
    double y = (A*y1+B*y2+C*y3)/S;
    printf("%.3lf %.3lf\n", x, y);
  • 重心(中线交点)
    double x1, x2, x3, y1, y2, y3;
    scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3)
    double x = (x1+x2+x3)/3;
    double y = (y1+y2+y3)/3;
    printf("%.3lf %.3lf\n", x, y);
  • 垂心(高线交点)
    double x1, x2, x3, y1, y2, y3;
    scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3)
    double a1 = x2-x3;
    double b1 = y2-y3;
    double c1 = a1*y1-b1*x1;

    double a2 = x1-x3;
    double b2 = y1-y3;
    double c2 = a2*y2-b2*x2;
    
    double x = (a1*c2-a2*c1)/(a2*b1-a1*b2);
    double y = (b1*c2-b2*c1)/(a2*b1-a1*b2);

    printf("%.3lf %.3lf\n", x, y);
  • 判断三点顺逆时针
	double x1, x2, x3, y1, y2, y3;
    scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3);
    double ans = (x2-x1)*(y3-y1)-(y2-y1)*(x3-x1);
    if(ans<0) {
        puts("顺时针");
    }else if(ans>0) {
        puts("逆时针");
    }else {
        puts("共线");
    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值