首页 > 代码库 > 外接圆模板
外接圆模板
double dis(Point a){ return a.x*a.x+a.y*a.y;}struct Circle Circumcircle(){ Circle tmp; double a,b,c,c1,c2; double xa,ya,xb,yb,xc,yc; a = sqrt(dis(p[3]-p[1])); b = sqrt(dis(p[1]-p[2])); c = sqrt(dis(p[2]-p[3])); //根据s = a*b*c/R/4,求半径 tmp.r = (a*b*c)/(area()*4.0); xa = p[3].x; ya = p[3].y; xb = p[1].x; yb = p[1].y; xc = p[2].x; yc = p[2].y; c1 = (dis(p[3])-dis(p[1]))/2; c2 = (dis(p[3])-dis(p[2]))/2; tmp.center.x = (c1*(ya-yc)-c2*(ya-yb))/((xa-xb)*(ya-yc)-(xa-xc)*(ya-yb)); tmp.center.y = (c1*(xa-xc)-c2*(xa-xb))/((ya-yb)*(xa-xc)-(ya-yc)*(xa-xb)); return tmp;}
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。