zoukankan      html  css  js  c++  java
  • 三角形的面积

    著名的海伦公式,利用三角形的三条边进行三角形面积求解问题

    struct Point{

      int x;

      int y;

         //int z; 如果是空间中的点

    };

    double count_triangle_area(Point a, Point b, Point c) {
        double area = -1;
        double side[3];
       side[0] = sqrt(
    pow(a.x - b.x, 2) + pow(a.y - b.y, 2));
        side[1] = sqrt(pow(a.x - z.x, 2) + pow(a.y - z.y, 2));
        side[2] = sqrt(pow(b.x - z.x, 2) + pow(b.y - z.y, 2)); 
    //side[
    0] = sqrt(pow(a.x - b.x, 2) + pow(a.y - b.y, 2) + pow(a.z - b.z, 2));
    //side[1] = sqrt(pow(a.x - c.x, 2) + pow(a.y - c.y, 2) + pow(a.z - c.z, 2));
    //side[2] = sqrt(pow(c.x - b.x, 2) + pow(c.y - b.y, 2) + pow(c.z - b.z, 2));
       if (side[0] + side[1] <= side[2] || side[0] + side[2] <= side[1] || side[1] + side[2] <= side[0]) 
    return area;
    double p = (side[0] + side[1] + side[2]) / 2;
    area = sqrt(p*(p - side[0])*(p - side[1])*(p - side[2]));
    return area;
    }
  • 相关阅读:
    Gym
    Gym
    Gym
    Gym
    Gym
    hdu2586 LCA带边权的Targan算法
    bryce1010专题训练——LCA
    POJ1470 LCA (Targan离线)
    bryce1010专题训练——LCT&&树链剖分
    模板——2.7 欧拉函数
  • 原文地址:https://www.cnblogs.com/strongYaYa/p/6781557.html
Copyright © 2011-2022 走看看