Analysis
算法是,先根据给定两点求出圆心,然后使用向量的旋转依次求出各点。
Accepted Code
type
point=record
x,y:extended;
end;
var
p:array[1..150] of point;
i,k,n,n1,n2:longint;
alpha,beta,r:extended;
o:point;
function rotate(st,en:point;deg,r:extended):point;
var
k,rot:point;
begin
k.x:=en.x-st.x;
k.y:=en.y-st.y;
rot.x:=r*(k.x*cos(deg)-k.y*sin(deg));
rot.y:=r*(k.x*sin(deg)+k.y*cos(deg));
rot.x:=rot.x+st.x;
rot.y:=rot.y+st.y;
rotate:=rot;
end;
begin
readln(n,n1,n2);
readln(p[n1].x,p[n1].y);
readln(p[n2].x,p[n2].y);
alpha:=pi*(n2-n1)/n;
r:=sqrt(sqr(p[n1].x-p[n2].x)+sqr(p[n1].y-p[n2].y))/(2*sin(alpha));
beta:=pi/2-alpha;
o:=rotate(p[n2],p[n1],beta,1/(2*sin(alpha)));
k:=n1;
repeat
k:=(k+n-2) mod n+1;
p[k]:=rotate(o,p[k mod n+1],2*pi/n,1);
until k=n1;
for i:=1 to n do
writeln(p[i].x:0:6,' ',p[i].y:0:6);
end.