为啥代码里打问号那块y是负的才是对的???
题目说的那个绕中心转指什么啊 卡自转还是卡绕中心转啊??? (理论上不加 - 我写的是自转版本
#include <bits/stdc++.h>
using namespace std;
const int N=1e4+5;
const double Pi=3.141592653589793;
struct node
{
double x,y;
bool friend operator < (const node a,const node b)
{
return a.y==b.y?a.x<b.x:a.y<b.y;
}
}p[N<<2];
inline node vec(node a,node b)
{
node res;
res.x=b.x-a.x;
res.y=b.y-a.y;
return res;
}
inline bool X_mul(node vec1,node vec2)//vec1在vec2 1逆时针 0顺时针
{
return vec1.x*vec2.y>=vec1.y*vec2.x;
}
inline bool cmp(node a,node b)
{
return X_mul(vec(p[1],a),vec(p[1],b));
}
inline double dis(node a,node b)
{
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
node stc[N<<2];
int main()
{
int n;
scanf("%d",&n);
double r,a,b;
scanf("%lf%lf%lf",&a,&b,&r);
a=a/2.0-r;
b=b/2.0-r;
double len=sqrt(a*a+b*b);
for(int i=0;i<n;i++)
{
double cita,x,y;
scanf("%lf%lf%lf",&x,&y,&cita);
p[i*4+1].x=x+len*sin(cita+atan2(b,a));
p[i*4+1].y=-y+len*cos(cita+atan2(b,a));//????
p[i*4+2].x=x+len*sin(cita+atan2(b,-a));
p[i*4+2].y=-y+len*cos(cita+atan2(b,-a));
p[i*4+3].x=x+len*sin(cita+atan2(-b,a));
p[i*4+3].y=-y+len*cos(cita+atan2(-b,a));
p[i*4+4].x=x+len*sin(cita+atan2(-b,-a));
p[i*4+4].y=-y+len*cos(cita+atan2(-b,-a));
for(int j=1;j<=4;j++)
{
if(p[j+i*4]<p[1])
swap(p[j+i*4],p[1]);
}
}
n<<=2;
sort(p+2,p+n+1,cmp);
//for(int i=1;i<=n;i++)cout<<p[i].x<<" "<<p[i].y<<endl;
int top=0;
stc[++top]=p[1];
for(int i=2;i<=n;i++)
{
while(top>1)
{
if(X_mul(vec(stc[top],p[i]),vec(stc[top-1],stc[top])))
{
--top;
}
else
{
break;
}
}
stc[++top]=p[i];
}
stc[++top]=p[1];
double ans=0.0;
for(int i=2;i<=top;i++)
{
ans+=dis(stc[i],stc[i-1]);
cout<<stc[i-1].x<<" "<<stc[i-1].y<<endl;
}
ans+=2.0*Pi*r;
printf("%.2f",ans);
return 0;
}