题意:圆心在原点,一个坐标(x,y)在圆上,通过这个点画一个三角形在圆内,三角形其顶点都在圆上,要求三角形的周长最大,输出满足这样条件的三角形的另两个坐标.....
思路:有一个公式是把一个向量平移多少角度的......a向量=(x,y),要将a向量旋转120度
x1=x*cos(120.0/180.0*PI)-y*sin(120.0/180.0*PI);
y1=y*cos(120.0/180.0*PI)+x*sin(120.0/180.0*PI);
平移过后就变成了(x1,y1)......
公式:(x*cosθ- y * sinθ, y*cosθ + x * sinθ)
需要注意的是,是向量平移,而不是坐标旋转.........
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
using namespace std;
#define PI 3.1415926535
//(x*cosθ- y * sinθ, y*cosθ + x * sinθ)
int main()
{
int text;
scanf("%d",&text);
while(text--)
{
double x,y,x1,y1;
scanf("%lf%lf",&x,&y);
x1=x*cos(120.0/180.0*PI)-y*sin(120.0/180.0*PI);
y1=y*cos(120.0/180.0*PI)+x*sin(120.0/180.0*PI);
//double x1=x,y1=y;
x=x1*cos(120.0/180.0*PI)-y1*sin(120.0/180.0*PI);
y=y1*cos(120.0/180.0*PI)+x1*sin(120.0/180.0*PI);
if(fabs(y1-y)<0.0005)
{
if(x<x1)
printf("%.3lf %.3lf %.3lf %.3lf\n",x,y,x1,y1);
else
printf("%.3lf %.3lf %.3lf %.3lf\n",x1,y1,x,y);
}
else if(y<y1)
printf("%.3lf %.3lf %.3lf %.3lf\n",x,y,x1,y1);
else
printf("%.3lf %.3lf %.3lf %.3lf\n",x1,y1,x,y);
}
return 0;
}