作三角形ABC每个内角的三等分线,相交成三角形DEF,则DEF是等边三角形。给出A、B、C 3个的位置确定D、E、F 3个点的位置
涉及知识:
1.向量的旋转
2.两条直线求交点(已知两点)
3.两向量求夹角
/******************************************** Author :Crystal Created Time : File Name : ********************************************/ #include <cstdio> #include <cstdlib> #include <iostream> #include <algorithm> #include <cstring> #include <climits> #include <string> #include <vector> #include <cmath> #include <stack> #include <queue> #include <set> #include <map> #include <sstream> #include <cctype> using namespace std; typedef long long ll; typedef pair<int ,int> pii; #define MEM(a,b) memset(a,b,sizeof a) #define CLR(a) memset(a,0,sizeof a); const int inf = 0x3f3f3f3f; const int MOD = 1e9 + 7; const double eps = 1e-10; #define LOCAL // 两条直线求交点 // 两条直线求夹角 //向量的旋转 struct Point { /* data */ double x,y; Point (double x = 0, double y = 0):x(x),y(y){} }; typedef Point Vector; Vector operator + (Vector A, Vector B){return Vector(A.x + B.x, A.y + B.y);} Vector operator - (Vector A, Vector B){return Vector(A.x - B.x, A.y - B.y);} Vector operator * (Vector A, double p){return Vector(A.x * p, A.y *p);} Vector operator / (Vector A, double p){return Vector(A.x / p, A.y / p);} bool operator < (const Point& a , const Point& b){ return a.x < b.x || (a.x == b.x && a.y < b.y); } int dcmp(double x){ if(fabs(x) < eps) return 0; return x < 0 ? -1 : 1; } bool operator == (const Point& a, const Point& b){ return dcmp(a.x - b.x) == 0 && dcmp(a.y - b.y) == 0; } double dot(Vector A, Vector B){return A.x*B.x + A.y*B.y;} //点乘 double Length(Vector A){ return sqrt(dot(A,A));}; //向量的模 double Angle(Vector A, Vector B){ return acos(dot(A,B)/Length(A)/Length(B));};//向量的夹角 double Cross(Vector A, Vector B){ return A.x*B.y - A.y*B.x;}//叉乘 double Area(Point A, Point B, Point C){return Cross(B-A,C-A);}//三角形面积 Vector Rotate(Vector A, double rad){ // 向量a逆时针旋转rad弧度后的坐标 return Vector(A.x*cos(rad) - A.y*sin(rad),A.x*sin(rad)-A.y*cos(rad)); } //求直线交点 Point getline_intersection(Point P, Vector V, Point Q, Vector W){ Vector U = P - Q; double t = Cross(W,U)/Cross(V,W); return P+V*t; } Point get(Point a, Point b, Point c){ Vector v1 = c - b; double a1 = Angle(a-b,v1); v1 = Rotate(v1, a1/3); Vector v2 = b - c; double a2 = Angle(a-c, v2); v2 = Rotate(v2, -a2/3); return getline_intersection(b, v1, c, v2); } int main() { #ifdef LOCAL freopen("in.txt", "r", stdin); // freopen("out.txt","w",stdout); #endif int t;cin >> t; Point a,b,c,d,e,f; while(t--){ cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y; d = get(a,b,c); e = get(b,c,a); f = get(c,a,b); printf("%lf %lf %lf %lf %lf %lf\n",d.x , d.y , e.x , e.y, f.x, f.y); } return 0; }