上传者: qq_41608020
|
上传时间:2024/8/28 10:17:11
|
文件大小:23KB
|
文件类型:cpp
吉如一几何板子
2018worldfinal金牌吉老师几何板子structpoint{dbx,y;pointoperator+(constpoint&k1;)const{return(point){k1.x+x,k1.y+y};}pointoperator-(constpoint&k1;)const{return(point){x-k1.x,y-k1.y};}pointoperator*(dbk1)const{return(point){x*k1,y*k1};}pointoperator/(dbk1)const{return(point){x/k1,y/k1};}intoperator==(constpoint&k1;)const{returncmp(x,k1.x)==0&&cmp;(y,k1.y)==0;}pointturn(dbk1){return(point){x*cos(k1)-y*sin(k1),x*sin(k1)+y*cos(k1)};}pointturn90(){return(point){-y,x};}booloperator<(constpointk1)const{inta=cmp(x,k1.x);if(a==-1)return1;elseif(a==1)return0;elsereturncmp(y,k1.y)==-1;}dbabs(){returnsqrt(x*x+y*y);}dbabs2(){returnx*x+y*y;}dbdis(pointk1){return((*this)-k1).abs();}pointunit(){dbw=abs();return(point){x/w,y/w};}voidscan(){doublek1,k2;scanf("%lf%lf",&k1;,&k2;);x=k1;y=k2;}voidprint(){printf("%.11lf%.11lf\n",x,y);}dbgetw(){returnatan2(y,x);}pointgetdel(){if(sign(x)==-1||(sign(x)==0&&sign;(y)==-1))return(*this)*(-1);elsereturn(*this);}intgetP()const{returnsign(y)==1||(sign(y)==0&&sign;(x)==-1);}};
本软件ID:10947599