hdu 1700 (计算几何 向量的坐标变换)

Description

There is a cycle with its center on the origin.
Now give you a point on the cycle, you are to find out the other two points on it, to maximize the sum of the distance between each other
you may assume that the radius of the cycle will not exceed 1000.
 

Input

There are T test cases, in each case there are 2 decimal number representing the coordinate of the given point.
 

Output

For each testcase you are supposed to output the coordinates of both of the unknow points by 3 decimal places of precision 
Alway output the lower one first(with a smaller Y-coordinate value), if they have the same Y value output the one with a smaller X. 

NOTE
when output, if the absolute difference between the coordinate values X1 and X2 is smaller than 0.0005, we assume they are equal.
 

Sample Input

 
     
2 1.500 2.000 563.585 1.251
 

Sample Output

 
     
0.982 -2.299 -2.482 0.299 -280.709 -488.704 -282.876 487.453
 


【数学证明】 

  设R是圆半径,A,B,C是三角形的角,由正弦定理得a/sinA =b/sinB=c/sinC=2R 
故a+b+c=2R(sinA+sinB+sinC),当R确定求周长a+b+c最大,归结为求sinA+sinB+sinC的最大. 
设Y=sinA+sinB+sinC,先固定角A, 
Y=sinA+sinB+sinC=sinA+2sin((B+C)/2)cos((B-C)/2) 
=sinA+2cos(A/2)cos((B-C)/2) 
因为A是定值,故只有B=C时,Y才有最大值,同理分别再固定角B,C,则当C=A,A=B时, 
Y才有最大值,故A=B=C=60时,Y值最大,即周长a+b+c最大. 
也即同圆或等圆中周长最大的三角形是等边三角形.


//hdu 1700  向量的坐标变换
#include 
#include 
const double PI=acos(-1.0);
const double angle=2.0*PI/3.0;
struct Point{
	double x,y;
};
bool operator>(const Point &p1,const Point &p2){
	if (p1.y==p2.y) return p1.x>p2.x;
	return p1.y>p2.y;
}
long t;
double x,y;
Point p1,p2;
Point change(double angle){
	Point p;
	p.x=x*cos(angle)-y*sin(angle);
	p.y=x*sin(angle)+y*cos(angle);
	return p;
}
int main(){
	scanf("%d",&t);
	while (t--){
		scanf("%lf%lf",&x,&y);
		p1=change(angle);
		p2=change(-angle);
		if (p1>p2){ Point p=p1; p1=p2; p2=p;}
		printf("%.3f %.3f %.3f %.3f\n",p1.x,p1.y,p2.x,p2.y);
	}
	return 0;
}

其他方法:

http://www.haogongju.net/art/1845750


坐标旋转公式证明:http://wenku.baidu.com/view/8d1a7aeae009581b6bd9eb58.html

你可能感兴趣的:(acm,计算几何)