计算几何模板

在这里记录下比较有用的计算几何模板,以便于以后自己查找,持续更新

坐标点数据类型

struct Point{
    double x, y;  
};

已知三点,求外界圆心

Point Cross( Point A, Point B, Point c ){
    Point o;
    double a1 = B.x - A.x, b1 = B.y - A.y, c1 = a1*a1+b1*b1;
    double a2 = C.x - A.x, b2 = C.y - A.y, c2 = a2*a2+b2*b2;
    double d = a1 * b2 - a2 * b1; // det( AB, AC )
    o.x = A.x + (c1 * b2 - c2 * b1) / d;
    o.y = A.y + (a1 * c2 - a2 * c1) / d;
    return o;
}
原文地址:https://www.cnblogs.com/yefeng1627/p/2989130.html