莫勒定理,证明如下:
请结合下图看代码:
#include#include #include using namespace std;#define pi acos(-1.0)double lawofcosine(double a, double b, double c){ return acos((a*a+b*b-c*c)/(2.0*a*b));}double getangle(double x1, double y1, double x2, double y2){ return atan2(1.0*(y2-y1),1.0*(x2-x1));}double getdis(double x1, double y1, double x2, double y2){ return sqrt((y1-y2)*(y1-y2)+(x1-x2)*(x1-x2));}double solveequation_x(double x1, double y1, double x2, double y2, double k1, double k2){ return (y1-y2+k2*x2-k1*x1)/(k2-k1);}typedef struct point{ double x, y;} p;int main(){ p A, B, C, D, E, F; int n; cin>>n; while(n--) { cin>>A.x>>A.y>>B.x>>B.y>>C.x>>C.y; double a,b,c; //cout << A.x << ' ' << A.y << ' ' << B.x << ' ' << B.y << ' ' << C.x << ' ' << C.y << endl; a = getdis(B.x,B.y,C.x,C.y); b = getdis(C.x,C.y,A.x,A.y); c = getdis(B.x,B.y,A.x,A.y); //cout << "dis" << ' ' << a << '!' << b << '!' << c << endl; double alpha = lawofcosine(b,c,a); double beta = lawofcosine(a,c,b); double gama = lawofcosine(a,b,c); //cout << "angle" << ' ' << alpha * 180 / pi << '@' << beta * 180 / pi << '@' << gama * 180 / pi<
变成解析几何就太麻烦了,可是欧氏几何又没有现成的关系