内心、外心、重心、垂心的区分

  1. 内心(内切圆的圆心,三个角的角平分线的交点)
    性质:到三条边距离相等。
    在这里插入图片描述

  2. 外心(外接圆的圆心,三条中垂线的交点)
    性质:到三个顶点距离相等
    在这里插入图片描述

  3. 重心(三条中心的交点)
    性质: 重心是三条中线的三等分点(重心到顶点距离为重心到对边中点距离的2倍)
    在这里插入图片描述

  4. 垂心(三条高所在直线的交点)
    在这里插入图片描述

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
头文件 Shape.h: ```c++ #ifndef SHAPE_H #define SHAPE_H class Shape { public: virtual double area() const = 0; virtual std::string type() const = 0; virtual std::pair<double, double> centroid() const = 0; virtual std::pair<double, double> orthocenter() const = 0; virtual std::pair<double, double> circumcenter() const = 0; virtual std::pair<double, double> incenter() const = 0; virtual std::string pointRelation(double x, double y) const = 0; }; #endif // SHAPE_H ``` cpp文件 Shape.cpp: ```c++ #include "Shape.h" std::string Shape::pointRelation(double x, double y) const { if (area() == 0) { return "Inside"; } double s1 = (x - centroid().first) * (orthocenter().first - centroid().first) + (y - centroid().second) * (orthocenter().second - centroid().second); double s2 = (x - incenter().first) * (circumcenter().first - incenter().first) + (y - incenter().second) * (circumcenter().second - incenter().second); if (s1 * s2 <= 0) { return "Outside"; } double dis = (x - circumcenter().first) * (x - circumcenter().first) + (y - circumcenter().second) * (y - circumcenter().second); if (dis < (circumcenter().first - incenter().first) * (circumcenter().first - incenter().first) + (circumcenter().second - incenter().second) * (circumcenter().second - incenter().second)) { return "Inside"; } else if (dis > (circumcenter().first - orthocenter().first) * (circumcenter().first - orthocenter().first) + (circumcenter().second - orthocenter().second) * (circumcenter().second - orthocenter().second)) { return "Outside"; } else { return "On the boundary"; } } ``` 其中包括了计算面积、判断形状类型、计算重心垂心外心内心以及点和形状之间的关系。由于这些函数都是纯虚函数,因此需要在继承 Shape 类的具体形状类中进行实现。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值