给出两个点A,B 求一点C 使得 A,B,C
按逆时针顺序构成等边三角形。
思路吧AB看成一个向量,逆时针旋转60度即可。用到atan2函数,求一条直线与x正方向的夹角(弧度表示)。
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <string>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define INF (1<<30)
#define prln(x) printf("%lld...\n",x)
#define pr(x) printf("%lld...",x)
#define EPS 1e-10
#define rep(i,n) for(int (i)=(0);(i)<(n);(i)++)
#define Rep(i,n) for(int (i)=(1);(i)<=(n);(i)++)
#define PI acos(-1.0)
double ang,x[3],y[3],len;
int main()
{
int T;
scanf("%d",&T);
while(T--){
scanf("%lf %lf %lf %lf",&x[0],&y[0],&x[1],&y[1]);
ang = atan2(y[1]-y[0],x[1]-x[0]);
len = sqrt((y[1]-y[0])*(y[1]-y[0])+(x[1]-x[0])*(x[1]-x[0]));
x[2] = x[0]+len*cos(PI/3+ang);
y[2] = y[0]+len*sin(PI/3+ang);
printf("(%.2lf,%.2lf)\n",x[2],y[2]);
}
return 0;
}