三角形外心与垂心
转载请注明出处,谢谢http://blog.csdn.net/acm_cxlove/article/details/7854526 by---cxlove
POJ 1329 Circle Through Three Points
http://poj.org/problem?id=1329
题目:就是求外心,但是要输出外接圆方程,输出真DT
将三角形BEJ沿B点,逆时针旋转90度,这样子BE与BA重合,而且BJ与BC共线
而M是AJ的中点,而且BC==BJ,那么BM是三角形AJC的中位线,即BM平行于AC
而BM是经过旋转90度的,则原先BM垂直AC,同理可得其它边。
则点O为三角形ABC的垂心
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<cstdlib>#include<cmath>#include<set>#include<map>#include<queue>#include<stack>#include<string>#include<vector>#include<ctime>#define LL long long#define eps 1e-8#define inf 999999.0#define zero(a) abs(a)<eps#define N 20#define MOD 100000007#define pi acos(-1.0)using namespace std;struct Point{ double x,y; Point(){} Point(double tx,double ty){x=tx;y=ty;}}a,b,c;Point Orthocenter(Point p0,Point p1,Point p2){ double a1,b1,a2,b2,c1,c2; a1 = p2.x-p1.x; b1=p2.y-p1.y;c1 = 0; a2 = p2.x-p0.x; b2=p2.y-p0.y;c2 = (p1.x-p0.x)*a2+(p1.y-p0.y)*b2; double d = a1 * b2 - a2 * b1; return Point(p0.x+(c1*b2-c2*b1)/d,p0.y+(a1*c2-a2*c1)/d);}int main(){ int t; scanf("%d",&t); while(t--){ scanf("%lf%lf%lf%lf%lf%lf",&a.x,&a.y,&b.x,&b.y,&c.x,&c.y); Point central=Orthocenter(a,b,c); printf("%.4f %.4f\n",central.x,central.y); } return 0;}